tecsvit / yii2-apns
Extension for sending Apple push notification
Installs: 95
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.5.0
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2025-05-25 04:17:19 UTC
README
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); ?>