vasadibt/yii2-onesignal

This is a restful api to onesignal.

Installs: 1 735

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 3

Forks: 2

Open Issues: 0

Type:yii2-extension

1.0.1 2019-07-01 13:05 UTC

This package is auto-updated.

Last update: 2024-10-10 21:50:34 UTC


README

This is a restful api to onesignal.

Total Downloads Scrutinizer Code Quality

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist vasadibt/yii2-onesignal "dev-master"

or add

"vasadibt/yii2-onesignal": "dev-master"

to the require section of your composer.json file.

Config

Once the extension is installed, you have to configure the api component:

'components' => [
    'onesignal' => [
        'class' => '\vasadibt\onesignal\OneSignal',
        'appId' => 'your-app-id-hash-code',
        'appAuthKey' => 'SetYourAppAuthKey',
        'userAuthKey' => 'SetYourUserAuthKey',
        'enabled' => YII_ENV_PROD ? true : false,
    ],
],

Usage

Call api endpoints:

Yii::$app->onesignal->apps->getAll();

Yii::$app->onesignal->devices->getOne('asd-asd-asd-asd-asd-asd');
Yii::$app->onesignal->devices->getAll();


Yii::$app->onesignal->notifications->add([
    'include_player_ids' => ['player-hash-code-12345-123456789'],
    'contents' => ["en" => 'New message'],
]);


Yii::$app->onesignal->notifications->add([
    'included_segments' => ['All'],
    'contents' => ["en" => 'New message'],
]);