问题
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.
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.
Thanks!
回答1:
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...
I found that having both the production and the sandbox SSL certificate in a single PEM file causes the production environment to silently fail.
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');
or
$server=new ApnsPHP_Push_Server(ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION, 'server_certificates_bundle_production.pem');
After that, everything worked fine.
回答2:
please also check whether your App Id enabled push notification
来源:https://stackoverflow.com/questions/10518688/apns-php-sending-push-notifications-using-production-profile