• This repository has been archived on 12/Apr/2019
  • Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP Apple Push Notification Service library.

PHP APNS

PHP Apple Push Notification Service Library

Build Status Scrutinizer Quality Score Code Coverage Latest Stable Version Total Downloads Dependency Status

Install

Install PHP APNS using composer:

composer require jwage/php-apns

Generate Safari Notification Package

use JWage\APNS\Certificate;
use JWage\APNS\Safari\PackageGenerator;

$certificate = new Certificate(file_get_contents('apns.p12'), 'certpassword');
$packageGenerator = new PackageGenerator(
    $certificate, '/base/pushPackage/path', 'yourdomain.com'
);

// returns JWage\APNS\Safari\Package instance
$package = $packageGenerator->createPushPackageForUser('userid');

// send zip file to the browser
echo $package->getZipPath();

Sending Notifications

use JWage\APNS\Certificate;
use JWage\APNS\Client;
use JWage\APNS\Sender;
use JWage\APNS\SocketClient;

$certificate = new Certificate(file_get_contents('apns.pem'));
$socketClient = new SocketClient($certificate, 'gateway.push.apple.com', 2195);
$client = new Client($socketClient);
$sender = new Sender($client);

$sender->send('devicetoken', 'Title of push', 'Body of push', 'http://deeplink.com');