PHP Classes
elePHPant
Icontem

File: README.md

Recommend this page to a friend!
  Classes of Edgar Asatryan  >  YII2 notymo  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: YII2 notymo
Send iOS and Android push notifications
Author: By
Last change:
Date: 2 years ago
Size: 2,496 bytes
 

 

Contents

Class file image Download

yii2-notymo Build Status Scrutinizer Code Quality Code Coverage

The iOS and Android push notification extension for Yii2.

Installation

The suggested installation method is via composer:

$ composer require nstdio/yii2-notymo: "dev-master"

or add

"nstdio/yii2-notymo": "dev-master"

to the require section of your composer.json file.

Usage

Defining as application component

// web.php or console.php
'component' => [
    
    // ...
    
    'notymo'  => [
        'class'        => 'nstdio\yii2notymo\PushNotification',
        'push'         => [
            // If you d?n't want to use one of the services we can just skip them loading.
            // It's obvious that the skipped service is not necessary to configure.
            // 'skipApns' => true,
            // 'skipGcm'  => true,
            'apns' => [
                'live'        => true, // Whether to use live credentials.
                'cert'        => 'path/to/apns_live_cert.pem',
                'sandboxCert' => 'path/to/apns_sandbox_cert.pem',
            ],
            'gcm'  => [
                'apiKey' => 'api_key' // Here goes GCM Service API key. 
            ],
        ],
        'dataProvider' => [
            'class'      => 'nstdio\yii2notymo\provider\SQLDataProvider',
            'table'      => 'device_token', // The table from which the data will be obtained.
            'identifier' => 'user_id', // The identifier that defines the criteria for what data will be obtained. In this case, it is the column name from the table.
            'apns'       => 'apns_token', // The column name for APNS device tokens.
            'gcm'        => 'gcm_token', // The column name for GCM device tokens.
        ],
    ],
],

// For example SiteController.php
use nstdio\notymo\Message;
// ...

$userIds = [1, 2, 3, 4, 5];

/ @var \nstdio\yii2notymo\PushNotification $push */
$push = Yii::$app->notymo;

$msg = new Message();
$msg->setMessage("Test msg.");

$push->send($msg, $userIds); // Message will be sent to mentioned users.