Send push notifications to apple devices (iPhone, iPad, iPod).

Overview

Apple Apn Push

SensioLabsInsight Scrutinizer Code Quality Build Status

Send push notifications to apple devices (iPhone, iPad, iPod).

Support authenticators:

  • Certificate
  • Json Web Token

Supported protocols:

  • HTTP/2

Requirements

Now library work only with HTTP/2 protocol, and next libraries is necessary:

  • cURL
  • The protocol HTTP/2 must be supported in cURL.
  • PHP 7.1 or higher

Installation

Add AppleApnPush in your composer.json:

{
    "require": {
        "apple/apn-push": "~3.0"
    }
}

Now tell composer to download the library by running the command:

$ php composer.phar update apple/apn-push

Documentation

The source of the documentation is stored in the docs folder in this package:

Read the Documentation

Develop and testing via Docker

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 in the development of this AppleApnPush library!

Note: if you want to be a contributor to this library, we can send the OpenSource license of PhpStorm for development this library. For this, please contact me via email zhuk2205[dot]gmail.com

Thanks

Very thank for JetBrains for providing the OpenSource license for development this library with PhpStorm.

Comments
  • Added guard for using custom data in constructor of payload.

    Added guard for using custom data in constructor of payload.

    When using withCustomData() we are throwing an exception if the value is not a of scalar type.

    But not when the object custructor is used for setting the custom payload. This should fix that.

    feature 
    opened by morloderex 12
  • [Feature request] Sending multiple requests without a foreach

    [Feature request] Sending multiple requests without a foreach

    Currently i'm looping through each of my device tokens in a foreach loop.

    I would be great if there was some way that i could take this array with my prebuild message. And send it along by opening up only 1 connection instead of opening up 1 + n connections 1 foreach token to send to.

    @ZhukV Can you collaborate on this?

    opened by morloderex 9
  • JWT authentication refresh token

    JWT authentication refresh token

    Is there a way to save the current JWT somewhere and use it for at least the next 20 minutes. Apple says the following in their documentation APNs reports an error if you recreate your tokens more than once every 20 minutes. (https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns).

    I did not find a way to do this directly, outside of implementing the AuthenticatorInterface and implementing the logic myself.

    Any ideas?

    opened by Tayfun74 8
  • Message: Cannot resolve available JWT Signature Generator

    Message: Cannot resolve available JWT Signature Generator

    I am trying to use your apn-push package in CakePHP 3.6 with PHP 7.2.1

    Following use declarations: use Apple\ApnPush\Certificate\Certificate; use Apple\ApnPush\Protocol\Http\Authenticator\CertificateAuthenticator; use Apple\ApnPush\Sender\Builder\Http20Builder; use Apple\ApnPush\Jwt\Jwt; use Apple\ApnPush\Protocol\Http\Authenticator\JwtAuthenticator;

    Following code snippet: $authFile = 'AuthKey_JXKR3NB68G.p8'; $root = WWW_ROOT; $path = "{$root}/files/{$authFile}";

    	$jwt = new Jwt('V2LV7426WZ', 'JXKR3NB68G', $path);
    	Log::write('notice',$jwt);
    	$authenticator = new JwtAuthenticator($jwt);
    

    The last line result in the message in the title. I know teamIdentifier, keyID and .p8 file are good since I use them in a Swift server successfully. Any ideas?

    Kind regards, André Hartman, Belgium

    opened by ahartman 8
  • Add Apple push notification feedback service

    Add Apple push notification feedback service

    Implemented the Apple push notification feedback service. Tried to implement it in a way that seemed consistent with the rest of the library. Can make modifications if you think something needs tweaking.

    Usage:

    use Apple\ApnPush\Connection;
    use Apple\ApnPush\Feedback;
    
    $connection = new Connection\Feedback($certificate, $passphrase, $sandbox);
    $feedback   = new Feedback\Service($connection);
    
    $devices = $feedback->getInvalidDevices();
    

    $devices is an array of Feedback\Device:

    Array
    (
        [0] => Apple\ApnPush\Feedback\Device Object
            (
                [timestamp:protected] => 1371130770
                [tokenLength:protected] => 32
                [deviceToken:protected] => afafafafafafafafafafafafafafafafafafafafafafafafafafafafafafafaf
            )
    
    )
    
    opened by popthestack 8
  • Allow localized and non-localized text to exist in same payload

    Allow localized and non-localized text to exist in same payload

    The body and loc-* keys are not mutually exclusive. Same with title and title-loc-* keys. For example, you may want to send a push notification with non-localized text for older clients that do not have the loc-* keys in their bundle. This change allows localized and non-localized keys to coexist in same payload.

    opened by jhammer 3
  • Added support of 'apns-push-type' header

    Added support of 'apns-push-type' header

    Apple introduced a new header 'apns-push-type' which is required for devices running iOS 13 and later, or watchOS 6 and later.

    (Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later. Ignored on earlier system versions.) The type of the notification. The value of this header is alert or background. Specify alert when the delivery of your notification displays an alert, plays a sound, or badges your app's icon. Specify background for silent notifications that do not interact with the user.

    Please, see Sending Notification Requests to APNs for more details.

    opened by melya 3
  • add support for mutable-content attribute in Aps

    add support for mutable-content attribute in Aps

    Supporting mutable-content attribute, which lets you customize the content of a remote notification before it is delivered to the user. https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension

    opened by Azwartin 3
  • Add support for `url-args` for macOS Safari web push

    Add support for `url-args` for macOS Safari web push

    When sending web push to Safari in macOS, APNs expects the property url-args to be present in the aps body, even if it's just an empty array.

    If it's not included, the following error will be triggered:

    ["Failed to parse remote notification payload: payload must contain a \"url-args\" array inside the \"aps\" dictionary"]

    Relevant section in Apple's documentation:

    https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/NotificationProgrammingGuideForWebsites/PushNotifications/PushNotifications.html#//apple_ref/doc/uid/TP40013225-CH3-SW12

    opened by rjmahieu 2
  • Alert can be an String

    Alert can be an String

    Hi, I have an app using notifications and for whatever reason, it only parse the alert as a string, not a Dictionary, It works and it appear as possible in apple documentation, so I think this library should give an option to send a String type Alert.

    This is the apple documentation ( it says "Dictionary (or String)" ) https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363

    I have implemented the code to add it, I will send the fork. As the Alert doesn't have fields, I have assumed that the title and the body are parsed in one line separated by a space.

    opened by angelgonzalo 2
  • Sound information for critical alerts

    Sound information for critical alerts

    Is it possible to extend Aps class to allow to set sound dictionary for a critical alert? Currently the $sound attribute is private and has type string.

    Keys to include in the sound dictionary

    Key | Value Type | Description -- | -- | -- critical | Number | The critical alert flag. Set to 1 to enable the critical alert. name | String | The name of a sound file in your app’s main bundle or in the Library/Sounds folder of your app’s container directory. Specify the string "default" to play the system sound. For information about how to prepare sounds, see UNNotificationSound. volume | Number | The volume for the critical alert’s sound. Set this to a value between 0.0 (silent) and 1.0 (full volume).

    https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification

    Thanks!

    opened by bio 2
Releases(v2.2.2)
  • v2.2.1(Nov 9, 2015)

  • v2.2.0(Nov 9, 2015)

    Create a new certificate system.

    Before create connection, you should create a certificate and inject it to connection.

    This feature was be created, because in any system, the certificated saved to database or another storages, and we should be able to get certificate content and inject to connection.

    Create a base certificate and connection:

    use Apple\ApnPush\Certificate\Certificate;
    use Apple\ApnPush\Notification\Connection;
    
    $certificate = new Certificate('/path/to/certificate.pem', 'you_passphrase');
    $connection = new Connection($certificate, $sandbox);
    

    And create a certificate from content:

    use Apple\ApnPush\Certificate\ContentCertificate;
    use Apple\ApnPush\Notification\Connection;
    
    $content = $storage->getCertificateContent('...');
    $passPhrase = $storage->getCertificatePassPhrase('...');
    
    $certificate = new ContentCertificate($content, $passPhrase);
    $connection = new Connection($certificate, $sanbox);
    

    How it works (ContentCertificate):

    Before connect to Apple Apns, system create a temporary file in you system and put certificate content to it. If connection closed, certificate file will be deleted (control on __destruct).

    Source code(tar.gz)
    Source code(zip)
  • v2.1.6(Aug 19, 2015)

Owner
Vitaliy Zhuk
Vitaliy Zhuk
Takes care of Apple push notifications (APNS) in your PHP projects.

Notificato Notificato takes care of push notifications in your PHP projects. Italian: notificato è: participio passato English: notified Why use Notif

Mathijs Kadijk 223 Sep 28, 2022
Standalone PHP library for easy devices notifications push.

NotificationPusher Standalone PHP library for easy devices message notifications push. Feel free to contribute! Thanks. Contributors Cédric Dugat (Aut

Cédric Dugat 1.2k Jan 3, 2023
Laravel package to enable sending push notifications to devices

Laravel Push Notification Package to enable sending push notifications to devices Installation Update your composer.json file to include this package

Davi Nunes 1.2k Sep 27, 2022
Standalone PHP library for easy devices notifications push.

NotificationPusher Standalone PHP library for easy devices message notifications push. Feel free to contribute! Thanks. Contributors Cédric Dugat (Aut

Cédric Dugat 1.2k Jan 3, 2023
ApnsPHP: Apple Push Notification & Feedback Provider

ApnsPHP: Apple Push Notification & Feedback Provider A full set of open source PHP classes to interact with the Apple Push Notification service for th

Immobiliare Labs 1.4k Nov 16, 2022
A PHP Library to easily send push notifications with the Pushwoosh REST Web Services.

php-pushwoosh A PHP Library to easily send push notifications with the Pushwoosh REST Web Services. First sample, creating a Pushwoosh message // Crea

gomoob 63 Sep 28, 2022
Larafirebase is a package thats offers you to send push notifications or custom messages via Firebase in Laravel.

Introduction Larafirebase is a package thats offers you to send push notifications or custom messages via Firebase in Laravel. Firebase Cloud Messagin

Kutia Software Company 264 Jan 7, 2023
Send Firebase push notifications with Laravel php framework.

FCM Notification Channel for Laravel Send Firebase push notifications with Laravel php framework. Installation You can install this package via compos

Ankur Kumar 23 Oct 31, 2022
WebPush can be used to send notifications to endpoints which server delivers Web Push

WebPush can be used to send notifications to endpoints which server delivers Web Push notifications as described in the Web Push protocol. As it is standardized, you don't have to worry about what server type it relies on.

null 1.5k Jan 7, 2023
This package makes it easy to send web push notifications with Laravel.

Web push notifications channel for Laravel This package makes it easy to send web push notifications with Laravel. Installation You can install the pa

Laravel Notification Channels 564 Jan 3, 2023
Push notifications Library for PHP

Push notifications Library for PHP Supported Protocols Protocol Supported Driver Options APNs (Token Based) ✓ APNs\Token APNs\Token\Option APNs (Certi

Norifumi SUNAOKA 3 Dec 14, 2022
Push Notifications using Laravel

laravel-push-notification Push Notifications using Laravel PushNotification::send(['deviceToken1', 'deviceToken2',..], 'Notification Message', 'Action

Webelight Solutions 26 Jul 22, 2022
:computer: Send notifications to your desktop directly from your PHP script

About JoliNotif JoliNotif is a cross-platform PHP library to display desktop notifications. It works on Linux, Windows or MacOS. Requires PHP >= 7.2 (

JoliCode 1.2k Dec 29, 2022
Notifications in PHP (notify-send, growl, etc) like that.

#Nod Notifications in PHP (notify-send, growl, etc) like that. ##Examples Letting Nod figure out the best Adapter to use (not recommend ATM, only work

Filipe Dobreira 51 Mar 26, 2019
This package allows you to send notifications to Microsoft Teams.

Teams connector This package allows you to send notifications to Microsoft Teams. Installation You can install the package using the Composer package

skrepr 20 Oct 4, 2022
This package makes it easy to send notifications using RocketChat with Laravel 9.0+.

laravel-rocket-chat-notifications Introduction This package makes it easy to send notifications using RocketChat with Laravel 9.0+. Contents Installat

Team Nifty GmbH 25 Dec 1, 2022
Service that helps you to send notifications for a series of failed exceptions.

Laravel Failure Notifier This package helps you to track your exceptions and do what you want to do with them such as sending an SMS or and Email. You

Kamyar Gerami 7 Nov 26, 2022
It's Pimcore Bundle to send notifications to Google Chat, Slack or Email from admin panel inside Pimcore

Send notifications to Discord, Google Chat, Slack and more from Pimcore It's Pimcore Bundle to send notifications to Discord, Google Chat, Slack, Tele

LemonMind.com 6 Aug 31, 2022
A very lightweight library to handle notifications the smart way.

NAMSHI | Notificator Notificator is a very simple and lightweight library to handle notifications the smart way. It took inspiration from other librar

Namshi 187 Nov 4, 2022