PHP code example of conceptho / yii2-onesignal
1. Go to this page and download the library: Download conceptho/yii2-onesignal library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
conceptho / yii2-onesignal example snippets
'components' => [
// ...
'onesignal' => [
'appId' => 'ONESIGNAL_APP_ID',
'apiKey' => 'ONESIGNAL_API_KEY',
]
]
$message = [
"headers" => [
"en" => "Notification Example"
],
"contents" => [
"en" => "Click for more info"
]
];
$options = [
"template_id" => "your-template-id",
"url" => "https://github.com/romulo1984/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();
// 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);