为Apple Push开发的PHP PEAR 包:Services_Apple_PushNotification
2013-09-25 14:18
344 查看
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
对于这种第三方库,PHP官方称之为PEAR,需要按照PEAR标准开发(标准URI)。
PEAR的优势:一键安装到php/lib/php目录,require即可使用,很方便。
PHP PEAR上有一个Services_Apns,github上有一个Services_APNS,但都无法使用,所以我开发了一个,安装步骤如下:
使用步骤:
1、登录苹果开发者后台,下载dev或prod证书,合并成pem文件。在ios app里添加push权限,获得device token。参考:/article/5319243.html
2、demo(参考)
输出:
我的PEAR 频道:http://sinkcup.github.io/pear/
Services_Apple_PushNotification项目代码:https://github.com/sinkcup/Services_Apple_PushNotification
苹果官方文档:http://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW9
对于这种第三方库,PHP官方称之为PEAR,需要按照PEAR标准开发(标准URI)。
PEAR的优势:一键安装到php/lib/php目录,require即可使用,很方便。
PHP PEAR上有一个Services_Apns,github上有一个Services_APNS,但都无法使用,所以我开发了一个,安装步骤如下:
pear channel-discover sinkcup.github.io/pear pear install sinkcup/Services_Apple_PushNotification
使用步骤:
1、登录苹果开发者后台,下载dev或prod证书,合并成pem文件。在ios app里添加push权限,获得device token。参考:/article/5319243.html
2、demo(参考)
<?php require_once 'Services/Apple/PushNotification.php'; $conf = array( 'password' => '12346', 'cert' => '/home/u1/cert.pem-sandbox', ); $o = new Services_Apple_PushNotification('sandbox', $conf); $deviceToken = 'aaaf818eaae8a5aa11aaaf9aa8f8aa15aaefae75a1aaaa597e51917aa2a1a111'; $data = array( 'aps' => array( 'alert' => '测试push sandbox', 'badge' => 2, 'sound' => 'default', ) ); $r = $o->send($deviceToken, $data); var_dump($r); exit; ?>
输出:
bool(true)
我的PEAR 频道:http://sinkcup.github.io/pear/
Services_Apple_PushNotification项目代码:https://github.com/sinkcup/Services_Apple_PushNotification
相关文章推荐
- 为阿里云存储开发的PHP PEAR 包:Services_Aliyun_OSS
- 为七牛云存储开发的PHP PEAR 包:Services_Qiniu
- 为七牛云存储开发的PHP PEAR 包:Services_Qiniu
- 为阿里云存储开发的PHP PEAR 包:Services_Aliyun_OSS
- 用Pear加速PHP程序开发
- [iOS/Android开发之WebService]How to write a webservices using php with json format
- Ubuntu12.04下安装配置apache+php+mysql+pear(MDB2)开发环境
- 用Pear加速PHP程序开发
- PHP发短信 PEAR 包:Services_Sms
- 改写百度云推送SDK,PHP PEAR 包:Services_Baidu_Push
- 改写百度云推送SDK,PHP PEAR 包:Services_Baidu_Push
- 用Pear加速PHP程序开发
- 用Pear加速PHP程序开发
- 用Pear加速PHP程序开发
- phpweb 怎样开发插件、发布插件资源
- php开发规范2
- Windows下搭建PHP开发环境
- PHP微信H5支付开发实例
- php web开发之分类设计
- 如何使用Visual Studio开发PHP项目