rocketfirm/yii2-onesignal

Yii2 component for OneSignal.com integration

0.0.4 2020-05-04 11:43 UTC

This package is auto-updated.

Last update: 2024-03-16 02:50:43 UTC


README

Yii2 component for OneSignal.com integration. Any contribution is highly encouraged!

Installation

Preferred way to install is through Composer.

composer require rocketfirm/yii2-onesignal

Configuration

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',
		]
	]
]

Usage

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.