PHP code example of autoxloo / yii2-apns
1. Go to this page and download the library: Download autoxloo/yii2-apns library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
autoxloo / yii2-apns example snippets
// ...
'components' => [
// ...
'apnsNotification' => [
'class' => \autoxloo\yii2\apns\APNSNotification::class,
'appleCertPath' => __DIR__ . '/wxv_cert.pem',
'apiUrl' => 'https://api.push.apple.com/3/device', // default
'apiUrlDev' => false,
'apnsPort' => 443, // default
'pushTimeOut' => 10, // default
],
],
// ...
'components' => [
// ...
'apnsNotification' => [
'class' => \autoxloo\yii2\apns\APNSNotification::class,
'appleCertPath' => __DIR__ . '/wxv_cert.pem',
'apiUrl' => 'https://api.development.push.apple.com/3/device',
'apiUrlDev' => false,
'apnsPort' => 443, // default
'pushTimeOut' => 10, // default
],
],
$token = 'some device token';
$payload = [
'some key1' => 'some value1',
'some key2' => 'some value2',
];
$response = \Yii::$app->apnsNotification->send($token, $payload);
$tokens = [
'some device token',
'some other device token',
];
$payload = [
'some key1' => 'some value1',
'some key2' => 'some value2',
];
$response = \Yii::$app->apnsNotification->sendToMany($tokens, $payload);
php composer.phar
// ...
'components' => [
// ...
'apnsNotification' => [
'class' => \autoxloo\yii2\apns\APNSNotification::class,
'appleCertPath' => __DIR__ . '/wxv_cert.pem',
'apiUrl' => 'https://api.push.apple.com/3/device', // default
'apiUrlDev' => 'https://api.development.push.apple.com/3/device', // default
'apnsPort' => 443, // default
'pushTimeOut' => 10, // default
],
],