【问题标题】:Push notification: How can I send push notification to a specific device using Pubnub?推送通知:如何使用 Pubnub 向特定设备发送推送通知?
【发布时间】:2015-05-29 10:07:17
【问题描述】:

这是我在服务器端使用的nodejs代码,我只使用一个chennal。

代码:

var pubnub = require("pubnub")({
ssl           : true,  
publish_key   : "pub-c-e2f2e008-92ce-4abc-a9fc-xxxxxxxxxxxx",
subscribe_key : "sub-c-3c272090-0370-11e5-aefa-xxxxxxxxxxxx",
geo           : true
});

exports.sendNotification=function(req,res){
var responseData={
                message:"Send notifications",
                data:null
            };

var message = {
"aps":{
    "alert":"Your Message: sent from nodejs server",
    "sound":"push1.wav"
 }
};
pubnub.publish({ 
channel   : 'apns',
message   : message,
callback  : function(e) { 
                console.log( "SUCCESS!", e );
                res.json(responseData); 
            },
error     : function(e,data) { 
                console.log( "FAILED! RETRY PUBLISH!", e ); 
                responseData.message="FAILED! RETRY PUBLISH!";
                res.json(responseData);
            }

});
}

【问题讨论】:

    标签: ios node.js push-notification apple-push-notifications pubnub


    【解决方案1】:

    检查this documentation

    设备正在注册频道上的推送。如果要针对特定​​设备,则必须使用多个通道。

    我还建议使用this method of sending pushes,因为在添加 GCM 功能的情况下,您只需将一条消息发送到两个设备都会接收的队列

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-08
      • 1970-01-01
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多