yii-jpush - 适配于 Yii 的极光推送扩展包php
$ composer require guanguans/yii-jpush -v
复制代码
Yii2 配置文件 config/main.php
的 components 中添加:git
'components' => [
// ...
'jpush' => [
'class' => 'Guanguans\YiiJpush\Jpush',
'appKey' => 'xxxxxxxxxxx',
'masterSecret' => 'xxxxxxxxxxx',
'logFile' => './jpush.log', // 可选
'retryTimes' => 3, // 可选
'zone' => 'default', // 可选 [default, bj]
],
// ...
]
复制代码
JPush\Client
实例<php
Yii::$app->jpush->client
复制代码
<?php
Yii::$app->jpush->client->push()
->setPlatform('all')
->addAllAudience()
->setNotificationAlert('Hello, JPush')
->send();
复制代码
<?php
$pusher = Yii::$app->jpush->client->push();
$pusher->setPlatform('all');
$pusher->addAllAudience();
$pusher->setNotificationAlert('Hello, JPush');
try {
$pusher->send();
} catch (\Exception $e) {
// try something else here
echo $e;
}
复制代码
$ composer test
复制代码
MITgithub