jwage / php-apns
Object Oriented PHP Apple Push Notification Integration Library
Installs: 273 470
Dependents: 0
Suggesters: 0
Security: 0
Stars: 99
Watchers: 11
Forks: 30
Open Issues: 3
Requires
- php: >=5.3.0
- ext-openssl: *
- ext-zip: *
This package is auto-updated.
Last update: 2020-01-17 07:16:04 UTC
README
PHP Apple Push Notification Service Library
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');