繁体   English   中英

是否可以通过pushwoosh发送带有某些参数的自定义推送通知,这些参数保存在设备本地

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM