2017 © Pedro Peláez
 

library pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

image

edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  • Monday, May 14, 2018
  • by edamov
  • Repository
  • 13 Watchers
  • 126 Stars
  • 6,383 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 31 Forks
  • 5 Open issues
  • 18 Versions
  • 20 % Grown

The README.md

Pushok

PHP >= 8.1 Build Status Latest Version on Packagist ![Total Downloads][ico-downloads] Coverage Status Quality Score ![Software License][ico-license] StandWithUkraine, (*1)

Do you like the library? Please consider donating to support Ukraine 🇺🇦

Pushok is a simple PHP library for sending push notifications to APNs., (*2)

Features

  • [X] Uses new Apple APNs HTTP/2 connection
  • [X] Supports JWT-based authentication
  • [X] Supports Certificate-based authentication
  • [X] Supports new iOS 10 features such as Collapse IDs, Subtitles and Mutable Notifications
  • [X] Uses concurrent requests to APNs
  • [X] Tested and working in APNs production environment

Requirements

  • PHP >= 8.1
  • lib-curl >= 7.46.0 (with http/2 support enabled)
  • lib-openssl >= 1.0.2e

Docker image that meets requirements can be found here. Or you can follow this tutorial to create your own docker image with curl with HTTP/2 support., (*3)

Install

Via Composer, (*4)

``` bash $ composer require edamov/pushok, (*5)


## Getting Started Using JWT token. See [Handling Notification Responses from APNs](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns) for more info. ``` php <?php require __DIR__ . '/vendor/autoload.php'; use Pushok\AuthProvider; use Pushok\Client; use Pushok\Notification; use Pushok\Payload; use Pushok\Payload\Alert; $options = [ 'key_id' => 'AAAABBBBCC', // The Key ID obtained from Apple developer account 'team_id' => 'DDDDEEEEFF', // The Team ID obtained from Apple developer account 'app_bundle_id' => 'com.app.Test', // The bundle ID for app obtained from Apple developer account 'private_key_path' => __DIR__ . '/private_key.p8', // Path to private key 'private_key_secret' => null // Private key secret ]; // Be aware of thing that Token will stale after one hour, so you should generate it again. // Can be useful when trying to send pushes during long-running tasks $authProvider = AuthProvider\Token::create($options); $alert = Alert::create()->setTitle('Hello!'); $alert = $alert->setBody('First push notification'); $payload = Payload::create()->setAlert($alert); //set notification sound to default $payload->setSound('default'); //add custom value to your notification, needs to be customized $payload->setCustomValue('key', 'value'); $deviceTokens = ['<device_token_1>', '<device_token_2>', '<device_token_3>']; $notifications = []; foreach ($deviceTokens as $deviceToken) { $notifications[] = new Notification($payload,$deviceToken); } // If you have issues with ssl-verification, you can temporarily disable it. Please see attached note. // Disable ssl verification // $client = new Client($authProvider, $production = false, [CURLOPT_SSL_VERIFYPEER=>false] ); $client = new Client($authProvider, $production = false); $client->addNotifications($notifications); $responses = $client->push(); // returns an array of ApnsResponseInterface (one Response per Notification) foreach ($responses as $response) { // The device token $response->getDeviceToken(); // A canonical UUID that is the unique ID for the notification. E.g. 123e4567-e89b-12d3-a456-4266554400a0 $response->getApnsId(); // Status code. E.g. 200 (Success), 410 (The device token is no longer active for the topic.) $response->getStatusCode(); // E.g. The device token is no longer active for the topic. $response->getReasonPhrase(); // E.g. Unregistered $response->getErrorReason(); // E.g. The device token is inactive for the specified topic. $response->getErrorDescription(); $response->get410Timestamp(); }

Using Certificate (.pem or .p12). Only the initilization differs from JWT code (above). Remember to include the rest of the code by yourself., (*6)

``` php <?php, (*7)

$options = [ 'app_bundle_id' => 'com.app.Test', // The bundle ID for app obtained from Apple developer account 'certificate_path' => DIR . '/private_key.pem', // Path to private key 'certificate_secret' => null // Private key secret ];, (*8)

$authProvider = AuthProvider\Certificate::create($options);, (*9)

..., (*10)

Note : Please see [this post](https://github.com/edamov/pushok/issues/124) about ssl verification

Options to fiddle around. See [Sending Notification Requests to APNs](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns)
``` php
<?php

$client = new Client($authProvider, $production = false);
$client->addNotifications($notifications);


// Set the number of concurrent requests sent through the multiplexed connections. Default : 20
$client->setNbConcurrentRequests( 40 );

// Set the number of maximum concurrent connections established to the APNS servers. Default : 1
$client->setMaxConcurrentConnections( 5 );


$responses = $client->push();

Testing

bash $ composer test, (*11)

Security

If you discover any security related issues, please email edamov@gmail.com instead of using the issue tracker., (*12)

Credits

License

The MIT License (MIT). Please see License File for more information., (*13)

The Versions

14/05 2018

dev-master

9999999-dev https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • lib-curl >=7.46.0
  • lib-openssl >=1.0.2.5
  • ext-curl *
  • ext-openssl *
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^7.0.0

 

The Development Requires

apns push notifications p8 php apns

14/05 2018

0.4.3

0.4.3.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^7.0.0

 

The Development Requires

apns push notifications p8 php apns

14/05 2018

0.4.2

0.4.2.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^7.0.0

 

The Development Requires

apns push notifications p8 php apns

14/05 2018

dev-feature/update-dependencies

dev-feature/update-dependencies https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^7.0.0

 

The Development Requires

apns push notifications p8 php apns

23/01 2018

dev-revert-33-update-jose-deps

dev-revert-33-update-jose-deps https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

23/01 2018

0.4.1

0.4.1.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^7.0.0

 

The Development Requires

apns push notifications p8 php apns

26/11 2017

0.4.0

0.4.0.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

02/11 2017

0.3.1

0.3.1.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

05/10 2017

0.3.0

0.3.0.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

27/09 2017

0.2.6

0.2.6.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

08/04 2017

0.2.5

0.2.5.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

08/04 2017

0.2.4

0.2.4.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

16/02 2017

0.2.3

0.2.3.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

20/01 2017

0.2.2

0.2.2.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

06/01 2017

0.2.1

0.2.1.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication

  Sources   Download

MIT

The Requires

  • php ^7.0
  • ext-curl *
  • lib-curl >=7.46.0
  • ext-openssl *
  • lib-openssl >=1.0.2.5
  • ext-gmp *
  • ext-xml *
  • ext-intl *
  • spomky-labs/jose ^6.1.1

 

The Development Requires

apns push notifications p8 php apns

10/11 2016

0.2.0

0.2.0.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT) or certificate-based authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

apns push notifications

10/11 2016

dev-feature/certificate-auth

dev-feature/certificate-auth https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT) or certificate-based authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

apns push notifications

07/11 2016

0.1.0

0.1.0.0 https://github.com/edamov/pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT) or certificate-based authentication

  Sources   Download

MIT

The Requires

 

The Development Requires

apns push notifications