2015-09-03 19 views

回答

0

在處理傳入通知的同一個函數中。

如果您使用基於事件源的通知,那麼這將是pushNotificationReceived()函數。用所需的應用邏輯替換警報。

function pushNotificationReceived(props, payload) { 
    alert("pushNotificationReceived invoked"); 
    alert("props :: " + JSON.stringify(props)); 
    alert("payload :: " + JSON.stringify(payload)); 
} 

如果您正在使用廣播/標籤通知,它以類似的方式完成。從示例應用程序中,您可以執行以下操作,只需替換爲您所需的應用程序邏輯即可:

WL.Client.Push.onMessage = function (props, payload) { 
    WL.SimpleDialog.show("Tag Notifications", "Provider notification data: " + JSON.stringify(props), [ { 
     text : 'Close', 
     handler : function() { 
      WL.SimpleDialog.show("Tag Notifications", "Application notification data: " + JSON.stringify(payload), [ { 
       text : 'Close', 
       handler : function() {} 
       }]);  
     } 
    }]); 
}; 
+0

這可以放在'initOptions.js'中嗎? –

+0

這是應用程序的邏輯,它應該坐在main.js中...你可以把它放在你想要的任何地方,但我懷疑你的代碼將變成一個叢林...... –

相關問題