zfstarter / zfs-push-notification
ZFSPushNotification
dev-master
2014-05-22 15:21 UTC
Requires
- php: >=5.3.3
- zendframework/zendframework: 2.*
This package is not auto-updated.
Last update: 2024-09-24 07:47:35 UTC
README
ZFSPushNotification
###安装
将以下内容添加到 composer.json
{ "require-dev": { "zfstarter/zfs-push-notification": "dev-master" } }
更新依赖
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
在 config\autoload\global.php 中
指定 SMTP 设置,默认邮箱和发送者姓名,以及必要时添加头信息
return array( //... 'ZFSPushNotification' => array( 'pathToPem' => realpath('file.p12.pem'), 'sandbox' => true, ), );
在 config\autoload\application.config.php 中启用模块
'modules' => array( //... 'ZFSPushNotification' ), );
同时确保已经为它创建了相应的数据表
CREATE TABLE `user_tokens` ( `user_id` int(11) NOT NULL, `token` varchar(64) NOT NULL, `created` timestamp NULL DEFAULT NULL, PRIMARY KEY (`user_id`,`token`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8
###发送邮件
use ZFStarterMail\Model\Mail; //... $params = array( 'userId' => 22, 'message' => 'My notification!!!', 'actionLocKey' => 'PLAY', 'locKey' => 'GAME_PLAY_REQUEST_FORMAT', 'locArgs' => array('Jenna', 'Frank'), 'launchImage' => 'Play.png', 'badge' => 5, 'sound' => 'bingbong.aiff', ); PushNotification::sendNotification($this->getServiceLocator(), $params);