简体   繁体   English

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

[英]Is it possible to send with pushwoosh custom push-notification with certain parameters that are saved locally on the device

I'm developing in Titanium a cross platform app that runs on IOS and Android. 我正在Titanium中开发一个可在IOS和Android上运行的跨平台应用程序。 To send my push notification I'm considering using Pushwoosh but I'm open for suggestion. 要发送我的推送通知,我正在考虑使用Pushwoosh,但我愿意征求建议。

On the app certain parameters are saved locally that will effect the content of the push notification. 在应用程序上,某些参数保存在本地,这将影响推送通知的内容。 Is it now possible to get these locally saved parameters to Pushwoosh so I can send custom notification and how would I do that? 现在是否可以将这些本地保存的参数获取到Pushwoosh,以便我可以发送自定义通知,我该怎么做?

Yes, it's called a payload. 是的,它称为有效负载。

Not sure how PushWoosh works with payloads... but you can use Parse. 不确定PushWoosh如何与有效载荷配合使用...但是您可以使用Parse。

When you receive the Push you get out of that the custom payload data (max size is 256 bytes and in iOS8+ it's 2 Kb of data) and save it into your App: 收到“推送”消息后,您将摆脱该自定义有效负载数据(最大大小为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)
    }
});

It's definitely possible with Pushwoosh - you can pass any custom JSON data in a "key":"value" format along with your push notifications from both PW Control Panel and through API ( "data" parameter). 通过Pushwoosh绝对有可能-您可以通过PW控制面板和API( "data"参数)以“键”:“值”格式传递任何自定义JSON数据以及您的推送通知。 In the resulting push payload this data is passed as a value of the "u" parameter. 在生成的推送有效载荷中,此数据作为"u"参数的值传递。

Please refer to the code sample from Pushwoosh Titanium guide on how to access this additional custom data from the payload: 请参阅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