1. Go to this page and download the library: Download autoxloo/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/ */
use autoxloo\apns\AppleNotificationServer;
$appleCertPath = __DIR__ . '/wxv_cert.pem';
$token = 'some device token';
$payload = [
'some key1' => 'some value1',
'some key2' => 'some value2',
];
$apns = new AppleNotificationServer($appleCertPath);
$apns->setPushType(AppleNotificationServer::PUSH_TYPE_BACKGROUND); // sets `apns-push-type` header.
// other available set methods:
$apns->setTopic('some topic'); // sets `apns-topic` header.
$apns->setExpiration(time() + 30); // sets `apns-expiration` header.
$apns->setExpiration(0); // sets `apns-expiration` header. If the value is 0, APNs attempts to deliver
// the notification only once and doesn’t store it.
$response = $apns->send($token, $payload);
use autoxloo\apns\AppleNotificationServer;
$apns = new AppleNotificationServer($appleCertPath, 'https://api.sandbox.apple.com/3/device', false);
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.