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