apns-php 使用生产配置文件发送推送通知 [英] apns-php sending push notifications using production profile

查看:95
本文介绍了apns-php 使用生产配置文件发送推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用apns-php来实现推送通知服务,最近遇到了这个问题:

We use apns-php to implement push notification service and have faced this problem recently:

推送通知适用于我们的开发配置文件,不适用于生产.

Push notifications work with our Development Profile and not work for Production.

我们没有从苹果服务器中得到任何错误,我们可以看到它们运行良好.这是日志

We get no errors from apple servers and we can see that they work fine. Here's the log

2012/05/09 07:26:50 [trace] [push_notification] APNS: INFO: Trying ssl://gateway.push.apple.com:2195...
2012/05/09 07:26:51 [trace] [push_notification] APNS: INFO: Connected to ssl://gateway.push.apple.com:2195.
2012/05/09 07:26:51 [trace] [push_notification] APNS: Added recipient iPad with YSA_ID:209
2012/05/09 07:26:51 [trace] [push_notification] APNS: Added recipient iPad with YSA_ID:323
2012/05/09 07:26:51 [trace] [push_notification] APNS: Added recipient iPad with YSA_ID:326
2012/05/09 07:26:51 [trace] [push_notification] APNS: INFO: Sending messages queue, run #1: 3 message(s) left in queue.
2012/05/09 07:26:51 [trace] [push_notification] APNS: STATUS: Sending message ID 1 [custom identifier: YSA-Notification-ID#181] (1/3): 121 bytes.
2012/05/09 07:26:51 [trace] [push_notification] APNS: STATUS: Sending message ID 2 [custom identifier: YSA-Notification-ID#181] (1/3): 121 bytes.
2012/05/09 07:26:51 [trace] [push_notification] APNS: STATUS: Sending message ID 3 [custom identifier: YSA-Notification-ID#181] (1/3): 121 bytes.
2012/05/09 07:26:52 [trace] [push_notification] APNS: INFO: Disconnected.

如您所见,没有错误.但是 iPad 上没有收到通知.

So as you can see there are no errors. But no notifications received on the iPad.

也许之前有人遇到过这个问题?任何帮助将不胜感激.

Maybe somebody faced this problem before? Any help would be highly appreciated.

谢谢!

推荐答案

我在某处读到可以将两个 SSL 证书放入一个 PEM 文件中.不幸的是,这个提示似乎不正确......

Somewhere I've read that both the SSL certificates could be put into a single PEM file. Unfortunately that hint didn't seem to be correct...

我发现在单个 PEM 文件中同时拥有生产和沙盒 SSL 证书会导致生产环境无声无息地失败.

I found that having both the production and the sandbox SSL certificate in a single PEM file causes the production environment to silently fail.

解决方案是将 PEM 拆分为两个单独的文件,并相应地将其传递给服务器:

Solution is to split the PEM into two separate files and pass it to the server accordingly:

$server=new ApnsPHP_Push_Server(ApnsPHP_Abstract::ENVIRONMENT_SANDBOX, 'server_certificates_bundle_sandbox.pem');

$server=new ApnsPHP_Push_Server(ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION, 'server_certificates_bundle_production.pem');

之后,一切正常.

这篇关于apns-php 使用生产配置文件发送推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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