Apple Push Notification Service:通過蘋果服務器向app用戶推送消息,無需啟動app。
蘋果官方文檔:http://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW9
標准URI
PEAR的優勢:一鍵安裝到php/lib/php目錄,require即可使用,很方便。
PHP PEAR上有一個Services_Apns,github上有一個Services_APNS,但都無法使用,所以我開發了一個,安裝步驟如下:
pear channel-discover sinkcup.github.io/ sinkcup/Services_Apple_PushNotification
使用步驟:
1、登錄蘋果開發者後台,下載dev或prod證書,合並成pem文件。在ios app裡添加push權限,獲得device token。參考:http://www.cnblogs.com/gpwzw/archive/2012/03/31/Apple_Push_Notification_Services_Tutorial_Part_1-2.html
2、demo(參考)
<?= => => = new Services_Apple_PushNotification(= = => => => => = $o->?>
輸出:
()
我的PEAR 頻道:http://sinkcup.github.io/pear/
Services_Apple_PushNotification項目代碼:https://github.com/sinkcup/Services_Apple_PushNotification