Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sasa-b/apns
APNS - Apple Push Notification Service PHP Client
https://github.com/sasa-b/apns
apns apns2 apple client client-library ios php php-7 php-library php7 push-notifications
Last synced: about 1 month ago
JSON representation
APNS - Apple Push Notification Service PHP Client
- Host: GitHub
- URL: https://github.com/sasa-b/apns
- Owner: sasa-b
- License: mit
- Created: 2020-08-27T14:05:16.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-31T15:26:25.000Z (10 months ago)
- Last Synced: 2024-09-28T19:40:56.669Z (about 2 months ago)
- Topics: apns, apns2, apple, client, client-library, ios, php, php-7, php-library, php7, push-notifications
- Language: PHP
- Homepage:
- Size: 87.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# apns
APNS - Apple Push Notification Service PHP Client[![PHP >= 7.0](https://img.shields.io/badge/php-%3E%3D%207.0-8892BF.svg?style=flat-square)](https://php.net/)
![](https://img.shields.io/packagist/v/sasa-b/apns2)
![](https://img.shields.io/packagist/l/sasa-b/apns2)## Requirements
```
PHP >= 7.0
lib-curl >= 7.46.0 (with http/2 support enabled)
lib-openssl >= 1.0.2e
```In case of PHP 7.0 you will need to compile PHP from source with the newer lib-curl which supports HTTP2 requests:
```
./configure --with-curl=/usr/local/include/curl --with-libdir=lib64 --with-openssl ..../make
```## Installation
```
composer require sasa-b/apns2
```## Getting Started
### Certificate Provider Trust
```php
require '/vendor/autoload.php';use SasaB\Apns\Client;
use SasaB\Apns\Provider\Certificate;use SasaB\Apns\Payload\Aps;
use SasaB\Apns\Payload\Alert;
use SasaB\Apns\Notification;$certificate = Certificate::fromFile('/PushCert.pem');
$client = Client::auth($certificate);
$notification = new Notification("{device_token}");
$notification->setAps(new Aps(new Alert('Hello World')));
$response = $client->send($notification);
echo (string) $response->getApnsId()."\n";
echo $response;
```### Token Key Provider Trust
```php
require '/vendor/autoload.php';use SasaB\Apns\Client;
use SasaB\Apns\Provider\JWT;
use SasaB\Apns\Provider\TokenKey;use SasaB\Apns\Payload\Aps;
use SasaB\Apns\Payload\Alert;
use SasaB\Apns\Notification;$tokenKey = new TokenKey('{token_key}');
$tokenKey->loadFromFile('/AuthKey.p8');$jwt = JWT::new('{team_id}', $tokenKey);
if ($jwt->hasExpired()) {
$jwt->refresh($tokenKey);
}$client = Client::auth($jwt);
$notification = new Notification("{device_token}");
$notification->setPushTopic('com.vendor.app');
$notification->setAps(new Aps(new Alert('Hello World')));
$response = $client->send($notification);
echo (string) $response->getApnsId()."\n";
echo $response;
```