Fix the Push data Set issue 72/132272/2
authorHyeKyoung Hwang <cookie@samsung.com>
Fri, 2 Jun 2017 05:01:49 +0000 (14:01 +0900)
committerHyeKyoung Hwang <cookie@samsung.com>
Fri, 2 Jun 2017 05:08:10 +0000 (14:08 +0900)
[ Problem]If the PWA is resume, not init, PWA can't set the push data
[ Cause] ewk_context_send_push_message is just call when it init
[ Soulution ] When tab is added, ewk_context_send_push_message is called
[ Verify] PWA can get the push data

Change-Id: Ibf8ef4d9e1f38fc37df4b87d7a8b8d60bff92245
Signed-off-by: HyeKyoung Hwang <cookie@samsung.com>
services/WebEngineMin/WebEngineMin.cpp

index 8d99159f02044fc2945dd3fddee8380d49f3e264..6023fc81ce91c7fced3eea3a0994456c6fe5c402 100755 (executable)
@@ -142,7 +142,7 @@ void WebEngineMin::init(Evas_Object* guiParent)
 
 void WebEngineMin::windowRequest(const char* url)
 {
-    BROWSER_LOGD("[%s:%d] url=%s", __PRETTY_FUNCTION__, __LINE__,url);
+    BROWSER_LOGD("[%s:%d] url=%s", __PRETTY_FUNCTION__, __LINE__, url);
     app_control_h app_control;
     app_control_create(&app_control);
     app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);
@@ -356,6 +356,15 @@ TabId WebEngineMin::addTab(const std::string& uri,
     TabOrigin)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+
+    auto pwaData = *getPWADataSignal();
+    auto pwaInstanceId = *getPWAInstanceIDSignal();
+    if (!pwaInstanceId.empty() && !pwaData.empty()) {
+        ewk_context_send_push_message(m_ewkContext, (char*)pwaData.c_str());
+        BROWSER_LOGD("[%s:%d] ewk_context_send_push_message=%s", __PRETTY_FUNCTION__, __LINE__, pwaData.c_str());
+    }
+    ewk_context_push_message_callback_set(m_ewkContext, _push_cb, this);
+
     setURI(uri);
     return 0;
 }
@@ -416,8 +425,9 @@ void WebEngineMin::_rotate_prepared(void * data, Evas_Object *, void *)
     if (data) {
         auto *self = static_cast<WebEngineMin *>(data);
         self->rotatePrepared();
-    } else
+    } else {
         BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__);
+    }
 }
 
 void WebEngineMin::__notification_reply_cb(void* data, Evas_Object*, void* event_info)