Apple 推送通知不适用于分发,但适用于开发 [英] Apple push notification is not working for distribution but working for development

查看:38
本文介绍了Apple 推送通知不适用于分发,但适用于开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的应用程序中实现推送通知,在开发部分它运行良好,我收到推送通知很好.当我决定在应用商店中发布它时,我实现了它的分发(我使用证书和配置文件进行分发),我做了同样的步骤,我通过将 .p12 文件转换为 .pem,我结合了certificate.pem 和 key.pem 到另一个文件 ck.pem.在 PHP 文件中,我执行了以下操作:

I am implementing push notifications in my application, in the development part it is working fine, and I receive push notifications well. When I decided to publish it in the app store, I implemented it for distribution (I use the certificate and provisioning profile for distribution), I made the same steps and I converted the .p12 files to .pem through shall, and I combine the certificate.pem and key.pem to another file ck.pem. In the PHP file, I did the following:

$passphrase = 'The passphrase I put it in the shall';

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

// Open a connection to the APNS server
$fp = stream_socket_client(
    'ssl://gateway.push.apple.com:2195', $err,
    $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

我已经在我的 php 中将沙箱更改为 ssl://gateway.push.apple.com:2195.

I already changed sandbox to ssl://gateway.push.apple.com:2195 in my php.

我按照这些步骤创建了 production.pem.

I created production.pem with this steps.

$ openssl x509 -in aps_developer_identity.cer -inform der 
    -out PushChatCert.pem

$ openssl pkcs12 -nocerts -out PushChatKey.pem -in PushChatKey.p12

Enter Import Password: MAC verified OK Enter PEM pass phrase: Verifying - Enter PEM pass phrase:

$ cat PushChatCert.pem PushChatKey.pem > ck.pem

然后我将我的 ck.pem 上传到我的共享主机.这没有什么错误,但它不会推送通知.

and I uploade my ck.pem to my shared host. It is nothing errors but it does not push notification.

在我的 php 中它说:连接到 APNS 消息已成功发送

In my php it said : Connected to APNS Message successfully delivered

推荐答案

我相信服务器端不使用分发 PEM 文件.主要的基本规则是应用程序和服务器应该在相同的模式下运行.如果您的应用程序在调试模式下运行,那么服务器也应该使用开发 PEM 文件,就像您的应用程序在发布模式下运行一样,服务器也应该使用分发 PEM文件.

I believe in server side not using the distribution PEM file. The main fundamental rule is App and server should run in same mode.If your app is running in debug mode then server also should also use the development PEM file and same like if your app is running in release mode then server also should use distribution PEM file.

这篇关于Apple 推送通知不适用于分发,但适用于开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆