Yii2 component for OneSignal.com integration. Any contribution is highly encouraged!
Preferred way to install is through Composer.
composer require rocketfirm/yii2-onesignal
Add following code to your configuration file (main.php):
<?php return [ 'components' => [ // ... 'onesignal' => [ 'class' => '\rocketfirm\onesignal\OneSignal', 'appId' => 'ONESIGNAL_APP_ID', 'apiKey' => 'ONESIGNAL_API_KEY', ] ] ]
After adding onesignal component to your project you can now simply add players to your OneSignal application by running following code:
<?php \Yii::$app->onesignal->players()->add($deviceType, $options);
Run following command to send notifications:
<?php \Yii::$app->onesignal->notifications()->create($message, $options)
Visit official onesignal.com documentation for more details.