dantart/yii2-onesignal
Composer 安装命令:
composer require dantart/yii2-onesignal
包简介
Yii2 component for OneSignal.com integration
README 文档
README
Yii2 component for OneSignal.com integration. Any contribution is highly encouraged!
This component is a rocketfirm/yii2-onesignal fork.
Installation
Preferred way to install is through Composer.
composer require dantart/yii2-onesignal
Configuration
Add following code to your configuration file (main.php):
'components' => [ // ... 'onesignal' => [ 'appId' => 'ONESIGNAL_APP_ID', 'apiKey' => 'ONESIGNAL_API_KEY', ] ]
Usage
Run following command to send notifications:
$message = [ "headers" => [ "en" => "Notification Example" ], "contents" => [ "en" => "Click for more info" ] ]; $options = [ "template_id" => "your-template-id", "url" => "https://github.com/dantart/yii2-onesignal" ]; $filterOne = ["field" => "tag", "key" => "your_tag_here", "relation" => "=", "value" => "your_tag_value_here"]; $filterOne = ["field" => "tag", "key" => "your_tag_here", "relation" => "=", "value" => "your_tag_value_here"]; $notification = \Yii::$app->onesignal->notifications()->create($message["headers"], $message["contents"], $options); $notification->filter($filterOne); $notification->operatorOr(); $notification->filter($filterTwo); $notification->send();
Other methods:
// Notifications \Yii::$app->onesignal->notifications()->getAll($params); \Yii::$app->onesignal->notifications($id)->getOne(); //Players (device) \Yii::$app->onesignal->players()->getAll($params); \Yii::$app->onesignal->players($id)->getOne(); \Yii::$app->onesignal->players($id)->edit($params); \Yii::$app->onesignal->players($id)->addTag($tagName, $tagValue); \Yii::$app->onesignal->players($id)->addTag($tagsArray); \Yii::$app->onesignal->players($id)->removeTag($tagName);
Visit official onesignal.com documentation for more details.
统计信息
- 总下载量: 56
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-01