tecsvit / yii2-apns
用于发送苹果推送通知的扩展
v1.1.2
2018-08-23 15:07 UTC
Requires
- php: >=5.5.0
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-29 01:02:26 UTC
README
用于发送苹果推送通知的扩展
安装
安装此扩展的首选方式是通过 composer。
运行
php composer.phar require --prefer-dist tecsvit/yii2-apns "*"
或者在您的 composer.json
文件的 require 部分添加
"tecsvit/yii2-apns": "*"
to
使用
安装扩展后,只需在您的代码中使用即可
到配置文件
'components' => [ ... 'apns' => [ 'class' => '\tecsvit\apns\src\Sender', 'apnsHostProd' => 'gateway.push.apple.com', 'apnsHostTest' => 'gateway.sandbox.push.apple.com', 'apnsPort' => 2195, 'apnsCertProd' => dirname(__DIR__) . '/path/to/prod-serc/apple_push_notification_production.pem', 'apnsCertTest' => dirname(__DIR__) . '/path/to/test-serc/apple_push_notification_test.pem', 'apnsPassphrase'=> dirname(__DIR__) . '/path/to/passphare', 'timeout' => 500000, //microseconds, 'mode' => 'prod' //'prod', 'dev' or 'test', default 'dev' ], ... ]
到您的代码
/** * @param array $alert Example: ['alert' => 'Push Message'] * @param string $token Apple token device * @param bool $closeAfterPush Close the connection after the push? */ Yii::$app->apns->send($alert, $token, $closeAfterPush); ?>