tecsvit/yii2-apns

用于发送苹果推送通知的扩展

安装: 95

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 2

开放问题: 0

类型:yii2-extension

v1.1.2 2018-08-23 15:07 UTC

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); ?>