[英]Is it possible to send with pushwoosh custom push-notification with certain parameters that are saved locally on the device
我正在Titanium中開發一個可在IOS和Android上運行的跨平台應用程序。 要發送我的推送通知,我正在考慮使用Pushwoosh,但我願意征求建議。
在應用程序上,某些參數保存在本地,這將影響推送通知的內容。 現在是否可以將這些本地保存的參數獲取到Pushwoosh,以便我可以發送自定義通知,我該怎么做?
是的,它稱為有效負載。
不確定PushWoosh如何與有效載荷配合使用...但是您可以使用Parse。
收到“推送”消息后,您將擺脫該自定義有效負載數據(最大大小為256字節,在iOS8 +中為2 Kb數據)並將其保存到您的應用中:
Ti.Network.registerForPushNotifications({
types: [ Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND ],
success: function(e) { Ti.App.Properties.setString('token', e.deviceToken); subscribePush();},
error: function (e) { alert("error: " + JSON.stringify(e)); },
callback: function (e) {
alert('the push ' + JSON.stringify(e) ); // Works Only on RUN Device
// Store your Data in the app
Ti.App.Properties.setObject('myPushedData', e.data)
}
});
通過Pushwoosh絕對有可能-您可以通過PW控制面板和API( "data"
參數)以“鍵”:“值”格式傳遞任何自定義JSON數據以及您的推送通知。 在生成的推送有效載荷中,此數據作為"u"
參數的值傳遞。
請參閱Pushwoosh Titanium指南中的代碼示例,以了解如何從有效負載中訪問此其他自定義數據:
// Process incoming push notifications
function receivePush(e) {
alert('Received push: ' + JSON.stringify(e));
Ti.API.warn("push message received: " + JSON.stringify(e));
//send stats to Pushwoosh about push opened
PushWoosh.sendPushStat(e.data.p);
var pushwoohURL = e['data']['l'];
var a = Ti.UI.createAlertDialog({
title : 'New Message',
message : e.data.alert,
buttonNames : ['Open', 'Close']
//message : JSON.stringify(e.data) //if you want to access additional custom data in the payload
});
a.show();
a.addEventListener('click', function(e) {
if (e.index == 0) {
Titanium.Platform.openURL(pushwoohURL);
}
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.