davibr / apn-push
Fork of apn-push
v3.0.0
2016-12-26 14:37 UTC
Requires
- php: ^7.0
- ext-curl: *
Requires (Dev)
- phpunit/phpunit: ^5.6.0
README
Send push notifications to apple devices (iPhone, iPad, iPod).
Requirements
Now library work only with HTTP/2 protocol, and next libraries is necessary:
Installation
Add AppleApnPush in your composer.json:
{ "require": { "apple/apn-push": "~3.0.0" } }
Now tell composer to download the library by running the command:
$ php composer.phar update apple/apn-push
Easy usage
You can use builder for create sender for next send push notifications to device:
<?php use Apple\ApnPush\Certificate\Certificate; use Apple\ApnPush\Protocol\Http\Authenticator\CertificateAuthenticator; use Apple\ApnPush\Sender\Builder\Http20Builder; use Apple\ApnPush\Model\Alert; use Apple\ApnPush\Model\Aps; use Apple\ApnPush\Model\Payload; use Apple\ApnPush\Model\Notification; use Apple\ApnPush\Model\DeviceToken; use Apple\ApnPush\Model\Receiver; use Apple\ApnPush\Exception\SendNotification\SendNotificationException; // Create certificate and authenticator $certificate = new Certificate(__DIR__.'/cert.pem', ''); $authenticator = new CertificateAuthenticator($certificate); // Build sender $builder = new Http20Builder($authenticator); $builder->addDefaultVisitors(); $sender = $builder->build(); // Create payload $alert = new Alert('hello ;)'); $aps = new Aps($alert); $payload = new Payload($aps); // Create notification $notification = new Notification($payload); $receiver = new Receiver( new DeviceToken('6b4d687c1292f1ff05b5653951be4e5f838ce6d39d6b1be1801fe8dcc35713c9'), 'you.app.id' ); try { $sender->send($receiver, $notification); } catch (SendNotificationException $e) { print 'Fail send message: '.$e->getMessage()."\n"; }
License
This library is under the MIT license. See the complete license in library
LICENSE
Reporting an issue or a feature request
Issues and feature requests are tracked in the Github issue tracker.
Contributors:
Thanks to [everyone participating] (https://github.com/ZhukV/AppleApnPush/graphs/contributors) in the development of this AppleApnPush library!
- Ryan Martinsen [popthestack] (https://github.com/popthestack)