fa2mm / tecsvit-apns

Extension for sending Apple push notification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yii2 APNs Extension

Extension for sending Apple push notification

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist tecsvit/yii2-apns "*"

or add

"tecsvit/yii2-apns": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by:

into config file:

'components' => [
    ...
    'apns' => [
        'class' => '\tecsvit\apns\src\Sender',
        'apnsHostProd'  => 'gateway.push.apple.com',
        'apnsHostTest'  => 'gateway.sandbox.push.apple.com',
        'apnsPort'      => 2195,
        'apnsCertProd'  => dirname(__DIR__) . '/path/to/prod-serc/apple_push_notification_production.pem',
        'apnsCertTest'  => dirname(__DIR__) . '/path/to/test-serc/apple_push_notification_test.pem',
        'apnsPassphrase'=> dirname(__DIR__) . '/path/to/passphare',
        'timeout'       => 500000, //microseconds,
        'mode'          => 'prod' //'prod', 'dev' or 'test', default 'dev'
    ],
    ...
]

into your code:

/**
 * @param array $alert Example: ['alert' => 'Push Message'] 
 * @param string $token Apple token device
 * @param bool $closeAfterPush Close the connection after the push?
 */
Yii::$app->apns->send($alert, $token, $closeAfterPush); ?>

About

Extension for sending Apple push notification

License:Apache License 2.0


Languages

Language:PHP 100.0%