dev-master
9999999-devPhp iOS push notifications provider
MIT
The Requires
- php >= 7
- lib-curl >= 7.46.0
- lib-openssl >= 1.0.2
- spomky-labs/jose ^6.1.1
The Development Requires
push apns p8
Wallogit.com
2017 © Pedro Peláez
Php iOS push notifications provider
Simple php library for iOS push notifications with token based authentication and HTTP/2, (*1)
$ composer require keithchasen/phpushious dev-master
<?php use Phpushios\Auth; use Phpushios\Message; use Phpushios\Sender; $apnsKeyId = 'NHDF3G4HS3'; $apnsAuthKey = 'path/to/APNSAuthKey_NHDF3G4HS3.p8'; $teamId = 'CH63KE89LH'; $secret = null; $bundleId = 'com.somebundle.id'; $env = 'production'; $userToken = 'ae01912dee52f0dc41b16a2fa9d68ff631dc9112b7d629f24008f466e1efef2d'; $auth = new Auth($apnsAuthKey); $authToken = $auth->setAuthToken($apnsKeyId, $secret, $teamId); $pushSender = new Sender($env, $authToken, $bundleId); $message = new Message(); $messageToSend = 'push message with p8'; $pushSender->addReceiver($userToken); $message->setAlert($messageToSend); $payload = $message->setPayload(); $pushSender->sendPush($payload);
<?php
use Phpushios\Auth;
use Phpushios\Message;
use Phpushios\Sender;
$apnsKeyId = 'NHDF3G4HS3';
$apnsAuthKey = 'path/to/APNSAuthKey_NHDF3G4HS3.p8';
$teamId = 'CH63KE89LH';
$secret = null;
$bundleId = 'com.somebundle.id';
$env = 'development';
$tokens = [
['token' => 'a3r1n3c8596f56f39921f79c55c91a061ea5042ab7be00620e7df0c76069aa7a', 'badge' => 12],
['token' => 'a3r1n3c8596f56f39921f79c55c91a061ea5042ab7be00620e7df0c76069aa7b', 'badge' => 32],
['token' => 'a3r1n3c8596f56f39921f79c55c91a061ea5042ab7be00620e7df0c76069aa7c', 'badge' => 42],
['token' => 'a3r1n3c8596f56f39921f79c55c91a061ea5042ab7be00620e7df0c76069aa7d', 'badge' => 55],
['token' => 'a3r1n3c8596f56f39921f79c55c91a061ea5042ab7be00620e7df0c76069aa7e', 'badge' => 11],
];
$auth = new Auth($apnsAuthKey);
$authToken = $auth->setAuthToken($apnsKeyId, $secret, $teamId);
$pushSender = new Sender($env, $authToken, $bundleId);
$message = new Message();
$messageToSend = 'push message with p8';
foreach ($tokens as $token) {
$pushSender->addReceiver($token['token']);
$message->setAlert($messageToSend);
$message->setBadgeNumber($token['badge']);
$payload = $message->setPayload();
$pushSender->sendPush($payload);
$pushSender->removeReceiversToken($token['token']);
}
Php iOS push notifications provider
MIT
push apns p8