简体   繁体   English

Node.js-无法将Apple推送通知发送到开发设备以进行调试

[英]Node.js- Can not send Apple Push Notifications to development devices for debug purposes

I am maintaining a Node.js application and new to Node.js. 我正在维护一个Node.js应用程序,这是Node.js的新功能。 This application sends push notifications to ios devices. 此应用程序将推送通知发送到ios设备。

For this purpose there is a config file that contains the apn settings ; 为此,有一个包含apn设置的配置文件。

    apnConfig: {

        providerOptions: {
          token: {
          key: path.join(__dirname, 'keys', 'xxx.p8'),
          keyId: 'XXXXXX',
          teamId: 'XXXX'
          },
          production: true  
}

And this is where I read the config file; 这是我读取配置文件的地方;

var provider = new apn.Provider(conf.apnConfig.providerOptions);

I have a .p8 key file for communicate server with APNs. 我有一个.p8密钥文件,用于与APN通信服务器。 Apple says "You can use this key for both development and production". 苹果说:“您可以使用此密钥进行开发和生产。”

My problem is that notifications can not be sent to development devices. 我的问题是通知无法发送到开发设备。 In the production environment there is no problem. 在生产环境中没有问题。 Notifications can be sent to production devices 通知可以发送到生产设备

I want to send notification both of the devices. 我想同时发送两个设备的通知。 Technically there must be no problem with a single .p8 key files . 从技术上讲,单个.p8密钥文件必须没有问题。

It writes production: true in the config file. 它在配置文件中写入production: true Does it cause the problem ? 它会引起问题吗?

Can you help please ? 你能帮忙吗? Thanks 谢谢

You need to have two different tokens to be able to send to production and development device. 您需要具有两个不同的令牌才能发送到生产和开发设备。 My advice would be for you to save somewhere with your device token, if it's a prod device or a dev device, so you know which token you can use. 我的建议是,如果您是生产设备或开发设备,则将其与设备令牌一起保存在某个地方,以便您知道可以使用哪个令牌。

Hope it helped you! 希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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