2017 © Pedro Peláez
 

yii2-extension yii2-push-notification

Yii2 apns/gcm push notification

image

develandoo/yii2-push-notification

Yii2 apns/gcm push notification

  • Friday, February 16, 2018
  • by dav93
  • Repository
  • 10 Watchers
  • 33 Stars
  • 1,150 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 6 Versions
  • 40 % Grown

The README.md

Yii2 apns/gcm push notification

INSTALLATION

Run, (*1)

composer require develandoo/yii2-push-notification

or add, (*2)

 "develandoo/yii2-push-notification": "^1.0"

CONFIGURATION

in your main.php your configuration would look like this, (*3)

    'components' => [
         'push' => [
             'class' => 'develandoo\notification\Push',
             'options' => [
                 'returnInvalidTokens' => true //default false
             ],
             'apnsConfig' => [
                 'environment' => Push::APNS_ENVIRONMENT_PRODUCTION or Push::APNS_ENVIRONMENT_SANDBOX,
                 'pem' => 'PEM_FILE_ABS_URL',
                 'passphrase' => 'YOUR_PASS_PHRASE', //optional
             ],
             'gcmConfig' => [
                 'apiAccessKey' => 'YOUR_GCM_API_KEY'
             ]
         ]
     ]

EXAMPLE

$push = Yii::$app->push;

// ios signle token example
$push->ios()->send('token', [
    'custom-key' => 'custom-value',
    'aps' => [
        'alert' => [
            'loc-key' => 'i18n_key',
            'loc-args' => ['arg1'],
        ]
    ],
    'badge' => 1,
    'sound' => 'default'
]);

// ios multiple tokens example
$push->ios()->send(['token1,token2'], [
    'custom-key' => 'custom-value',
    'aps' => [
        'alert' => 'STRING_MESSAGE'
    ],
    'badge' => 1,
    'sound' => 'default'
]);

// android example
$push->android()->send(['token1,token2'], [
    'key' => 'i18n_key',
    'args' => ['arg1'],
    'custom-key'=>'custom-value'
]);

// mixed tokens example
$push->send([
    'ios-tokens1',
    'android-token1',
    'android-token2',
    'ios-token2'
], $payload);

// firebase (both ios and android are supported) multiple tokens example
$push->firebase()->send(['token1','token2'], [
    // Background (closed) application data.
    'notification' => [
        'body' => 'Background application message',
        'title' => 'AppName',
        'sound' => 'default',
    ],
    // Foreground (running) application data.
    'data' => [
        'custom-key' => 'Any custom data could be delivered into foreground application. '
        . 'In order to simulate push notification, this data should be used inside "local notification" by client application.',
    ],
]);

EXCEPTION CASES

  • Apns environment is invalid.
  • Apns pem is invalid.
  • Gcm api access key is invalid.
  • Gcm in not enabled.
  • Apns in not enabled.

© DEVELANDOO 2017, (*4)

The Versions

16/02 2018

dev-master

9999999-dev https://github.com/develandoo/yii2-push-notification

Yii2 apns/gcm push notification

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

yii2 notification push develandoo

16/02 2018

1.1.1

1.1.1.0 https://github.com/develandoo/yii2-push-notification

Yii2 apns/gcm push notification

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

yii2 notification push develandoo

16/02 2018

1.1.0

1.1.0.0 https://github.com/develandoo/yii2-push-notification

Yii2 apns/gcm push notification

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

yii2 notification push develandoo

29/03 2017

1.0.1

1.0.1.0 https://github.com/develandoo/yii2-push-notification

Yii2 apns/gcm push notification

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

yii2 notification push develandoo

29/03 2017

dev-ssl_address

dev-ssl_address https://github.com/develandoo/yii2-push-notification

Yii2 apns/gcm push notification

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

yii2 notification push develandoo

17/01 2017

1.0.0

1.0.0.0 https://github.com/develandoo/yii2-push-notification

Yii2 apns/gcm push notification

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

yii2 notification push develandoo