【问题标题】:How do i send push notifications to all of my devices using Cordova push plugin如何使用 Cordova 推送插件向我的所有设备发送推送通知
【发布时间】:2015-09-17 10:43:53
【问题描述】:

我使用 cordova 推送插件创建了一个应用程序,但是每次我想发送推送通知时,我都必须获取该设备的注册 ID 并在我的 APN for ios 中设置它。有没有办法自动保存id? 这是我的 apn 节点服务器代码:

 var apn = require('apn');

var options = { };

var token =  'Device Number';

var apnConnection = new apn.Connection(options);

var myDevice = new apn.Device(token);

var message = new apn.Notification();

message.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1hour from now.
message.badge = 1;
message.sound = "ping.aiff";
message.alert = "\uD83D\uDCE7 \u2709 You have a new message";
message.payload = {'messageFrom': 'Caroline'};

//Potentially get rid of the notification in pushNotification
apnConnection.pushNotification(message, myDevice);\

干杯

【问题讨论】:

    标签: cordova push-notification cordova-plugins


    【解决方案1】:

    您应该将注册 ID 保存在某个数据库中,然后发送给所有这些。您不能“按原样”进行广播推送

    【讨论】:

    • 好的,谢谢,我可以将它们全部保存在一个数组中吗?如果是这样,我该怎么做?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-08
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-03
    相关资源
    最近更新 更多