All Projects → edamov → Pushok

edamov / Pushok

Licence: mit
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)

Projects that are alternatives of or similar to Pushok

Appleapnpush
Send push notification to Apple Devices (iPhone, iPad)
Stars: ✭ 134 (-48.46%)
Mutual labels:  iphone, ipad, apns
DartBible-Flutter
cross-platform mobile bible app [Android & iOS / iPhone / iPad]; written in Dart programming language
Stars: ✭ 26 (-90%)
Mutual labels:  iphone, ipad
ejabberd mod apns
An ejabberd module to send PUSH messages to iOS devices through APNS
Stars: ✭ 31 (-88.08%)
Mutual labels:  push-notifications, apns
jyutping
Cantonese Jyutping Keyboard for iOS. 粵語粵拼輸入法鍵盤
Stars: ✭ 23 (-91.15%)
Mutual labels:  iphone, ipad
node-apn-http2
Communicate with Apple Push Notification Service via native Node.js v8.8.1+ HTTP2 module (node-apn drop-in)
Stars: ✭ 25 (-90.38%)
Mutual labels:  push-notifications, apns
aioapns
An efficient APNs Client Library for Python/asyncio
Stars: ✭ 60 (-76.92%)
Mutual labels:  push-notifications, apns
Hostess.swift
A Swift implementation of NSHost that works on iOS, OS X and tvOS. Hostess.swift is safe to use in a framework because it does not require a bridging header. Hostess is Swift 4.0 (or newer) only and replaces the Swift 2.x only Host.swift.
Stars: ✭ 27 (-89.62%)
Mutual labels:  iphone, ipad
HapticGenerator
Easy peasy haptic generation in iOS.
Stars: ✭ 32 (-87.69%)
Mutual labels:  iphone, ipad
ios code sign
iOS 签名简介
Stars: ✭ 23 (-91.15%)
Mutual labels:  iphone, ipad
mod push appserver
Simple and extendable appserver for XMPP pushes (aka. XEP-0357)
Stars: ✭ 24 (-90.77%)
Mutual labels:  push-notifications, apns
Deviice
Swift library to easily check the current device and some more info about it.
Stars: ✭ 51 (-80.38%)
Mutual labels:  iphone, ipad
BDLocalizedDevicesModels
Apple devices model names localized.
Stars: ✭ 23 (-91.15%)
Mutual labels:  iphone, ipad
apns2
Node client for connecting to Apple's Push Notification Service using the new HTTP/2 protocol with JSON web tokens
Stars: ✭ 66 (-74.62%)
Mutual labels:  push-notifications, apns
azure-notificationhubs-java-backend
Azure Notification Hubs SDK for Java
Stars: ✭ 31 (-88.08%)
Mutual labels:  push-notifications, apns
Gunfish
No description or website provided.
Stars: ✭ 35 (-86.54%)
Mutual labels:  push-notifications, apns
spark-sdk-ios
DEPRECATED Particle iOS Cloud SDK. Use -->
Stars: ✭ 52 (-80%)
Mutual labels:  iphone, ipad
blobile
Blases Loaded - Unofficial Live Blaseball Game Viewer for iOS, Android, and Web
Stars: ✭ 16 (-93.85%)
Mutual labels:  iphone, ipad
OTResizableView
OTResizableView is a UIView library that can be resized with fingers.
Stars: ✭ 47 (-81.92%)
Mutual labels:  iphone, ipad
ALButtonMenu
A simple, fully customizable menu solution for iOS.
Stars: ✭ 45 (-82.69%)
Mutual labels:  iphone, ipad
nativesapp
Simple WhatsApp clone just for training purposes - Course Angular Native at www.udemy.com/angular-native
Stars: ✭ 19 (-92.69%)
Mutual labels:  iphone, ipad

Pushok

PHP >= 7.2 Build Status Latest Version on Packagist Total Downloads Coverage Status Quality Score Software License

Pushok is a simple PHP library for sending push notifications to APNs.

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 >= 7.2
  • 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.

Install

Via Composer

$ composer require edamov/pushok

Getting Started

Using JWT token. See Handling Notification Responses from APNs for more info.

<?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). Only the initilization differs from JWT code (above). Remember to include the rest of the code by yourself.

<?php

$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
];

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

...

Note : Please see this post about ssl verification

Options to fiddle around. See Sending Notification Requests to APNs

<?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

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].