Standalone PHP library for easy devices notifications push.

Overview

NotificationPusher Gitter

Standalone PHP library for easy devices message notifications push.

Latest Stable Version License Total Downloads Build Status

SensioLabsInsight

Feel free to contribute! Thanks.

Contributors

Installation

composer require sly/notification-pusher

This repository uses PSR-0 autoload. After installation with composer please adjust you autoloading config if needed or include vendor/autoload.php in your index.php.

Requirements

  • PHP 5.6+
  • PHP Curl and OpenSSL modules
  • Specific adapters requirements (like APNS certificate, GCM (FCM) API key, etc.)

WARNING Version v3.0 would support only php 7.0+. Please, update your composer config if needed.

Today available adapters

  • APNS (Apple)
  • GCM (Android) and FCM (Android)

Documentation and examples

Todo

  • Rewrite tests in PHPUnit 8+. (contributions are welcome!)
  • Add new features (custom APNS payloads, GCM and FCM custom options, etc.)
  • Add new adapters (like Blackberry and Windows phones)
  • Write more documentation and examples!

1.x users

Old version is still available from 1.x branch, with dedicated declared tag.

Bitdeli Badge

Comments
  • getFeedback() empty?

    getFeedback() empty?

    I did successfully send a push notification to my device in production mode. I wanted to check feedback data, if I uninstalled the app. Now I uninstalled it, and installed another push enabling app (as suggested to update the APNS feedback server).

    Now when I send the push, it is successfully delivered, but I have not received any feedback. The getFeedback() is empty.

    This is my code (simplified):

        $pushManager = new PushManager('prod');
    
        $push = new Push($the_adapter, new Device('my device token'), new Message('Some message', $options));
        $pushManager->add($push);
        $pushManager->push();
    
        exit(var_dump($pushManager->getFeedback($the_adapter))); // no feedback recieved
    

    UPDATE: Even trying this with an invalid token returns no feedback

    invalid question wontfix 
    opened by simplenotezy 13
  • Sending push to Android device succeed but did not receive the notification

    Sending push to Android device succeed but did not receive the notification

    I've followed the guide at https://github.com/Ph3nol/NotificationPusher/blob/master/doc/gcm-fcm-adapter.md, and got success response:

    array(5) {
      ["message_id"]=>
      string(35) "0:1526899807216245%882441d2f9fd7ecd"
      ["multicast_id"]=>
      int(7747457543145750552)
      ["success"]=>
      int(1)
      ["failure"]=>
      int(0)
      ["canonical_ids"]=>
      int(0)
    }
    

    But my device didn't receive any notification.

    Any suggestion? Thanks!

    question 
    opened by dongmai 12
  • APNS doesn't send messages with diacritics

    APNS doesn't send messages with diacritics

    Hi!

    I'm trying to send message with accents (i.e. "Deutche stadt Köln", "Polskie miasto Łódź") and push notification doesn't appear in ipad/iphone. Without diacritics ("Deutche stadt Koln", "Polskie miasto Lodz") i get the push notification in my phone without any problems.

    2.x dependencies 
    opened by kwn 12
  • GCM Adapter bug

    GCM Adapter bug

    With the new 2.3.2 library version you change GCMAdapter line 148 from $serviceMessage->setData($data); to $serviceMessage->setNotification($data);

    but this is not generally correct because Data Message an Notification Message are quite different in android application (Google official documentation: https://firebase.google.com/docs/cloud-messaging/concept-options)

    Actually we rollbak to 2.3.1 release to fix this problem. Can you restore old code or otherwise offer a setter methods to support both android notification mode?

    bug asap 
    opened by domenico-renna 10
  • Is it possible to send multiple messages to multiple devices without closing the connection?

    Is it possible to send multiple messages to multiple devices without closing the connection?

    I guess at the moment after each push, the connection is closed. Is it possible to implement some kind of batch functionality where the connection is only closed when all messages are sent?

    enhancement 2.x 
    opened by boosis 10
  • Firebase support

    Firebase support

    Actually Google drops support for GCM and now you can't create new projects for GCM.

    So now the preferred way to send push notifications is using Firebase is there any approach for manage this change?

    enhancement 2.x dependencies 
    opened by devjoca 9
  • Adds support for 'content-available' key from commit 9a1a1b3 in ZendServ...

    Adds support for 'content-available' key from commit 9a1a1b3 in ZendServ...

    I updated the ZendService_Apple_Apns library to use the latest addition to APN - the 'content-available' key added in iOS7 (see Table 3-1)

    This PR enables support for this.

    opened by Illizian 9
  • How set

    How set "notification" param in GCM adapter

    Hello! How I can setup for GCM Adapter this options

    "notification" : {
          "body" : "great match!",
          "title" : "Portugal vs. Denmark",
          "icon" : "myicon"
        }
    

    In \ZendService\Google\Gcm\Message isset method

     /**
         * Set notification
         *
         * @param array $data
         * @return Message
         */
        public function setNotification(array $data)
        {
    

    But in Sly\NotificationPusher\Adapter

     /**
         * Get service message from origin.
         *
         * @param array $tokens Tokens
         * @param BaseOptionedModel|\Sly\NotificationPusher\Model\MessageInterface $message Message
         *
         * @return \ZendService\Google\Gcm\Message
         * @throws \ZendService\Google\Exception\InvalidArgumentException
         */
        public function getServiceMessageFromOrigin(array $tokens, BaseOptionedModel $message)
        {
            $data            = $message->getOptions();
            $data['message'] = $message->getText();
    
            $serviceMessage = new ServiceMessage();
            // IF I USE THAT, THAN CAN SEND DATA FROM $message->getOptions()
            // $serviceMessage->setNotification($data); // I ADDED IT!!!! HOW setNotification() call???
            $serviceMessage->setRegistrationIds($tokens);
            $serviceMessage->setData($data);
            $serviceMessage->setCollapseKey($this->getParameter('collapseKey'));
            $serviceMessage->setRestrictedPackageName($this->getParameter('restrictedPackageName'));
            $serviceMessage->setDelayWhileIdle($this->getParameter('delayWhileIdle', false));
            $serviceMessage->setTimeToLive($this->getParameter('ttl', 600));
            $serviceMessage->setDryRun($this->getParameter('dryRun', false));
    
            return $serviceMessage;
        }
    
    bug enhancement 
    opened by juratitov 7
  • FCM Adapter

    FCM Adapter

    I've implemented the FCM Adapter for this great library.

    I can't take any real credit, essentially I have simply merged the classes derived from the following project

    https://github.com/jenky/laravel-push-notification

    Which is built on top of this library anyway.

    enhancement 
    opened by turbo124 7
  • Support for Android - FCM

    Support for Android - FCM

    Hi! The zendframework/zendservice-google-gcm has already updated its code to support FCM. Could you update dependencies on your composer.json to support this?

    enhancement 
    opened by bathan 7
  • Apns notifications not working

    Apns notifications not working

    Hi,

    I'm experiencing some problems with apns adapter to send push notifications. Some notifications never get to the devices, I get some invalid token errors and some no error at all, but none of them are getting to the user.

    For example:

    ./np push --certificate=/path/to/certificate.pem apns [deviceToken] "Notification test"

    Generates this message and output:

    object(ZendService\Apple\Apns\Message)#70 (10) {
      ["id":protected]=>
      string(40) "0918e534cfda09bdb5dacce2ab5494680b0e1942"
      ["token":protected]=>
      string(64) "8fc76feb6e889e70afe286104820cf39f7584b32363473898ac38773b97e596a"
      ["expire":protected]=>
      NULL
      ["alert":protected]=>
      object(ZendService\Apple\Apns\Message\Alert)#69 (8) {
        ["body":protected]=>
        string(31) "Notification test"
        ["actionLocKey":protected]=>
        NULL
        ["locKey":protected]=>
        NULL
        ["locArgs":protected]=>
        NULL
        ["launchImage":protected]=>
        NULL
        ["title":protected]=>
        NULL
        ["titleLocKey":protected]=>
        NULL
        ["titleLocArgs":protected]=>
        NULL
      }
      ["badge":protected]=>
      NULL
      ["sound":protected]=>
      string(13) "bingbong.aiff"
      ["contentAvailable":protected]=>
      NULL
      ["category":protected]=>
      NULL
      ["urlArgs":protected]=>
      NULL
      ["custom":protected]=>
      array(0) {
      }
    }
    object(ZendService\Apple\Apns\Response\Message)#71 (2) {
      ["id":protected]=>
      int(918)
      ["code":protected]=>
      int(8)
    }
    

    Curiously says invalid token when the token has just been registered with a clean app installation. The other case is

    ./np push apns [deviceToken2] "Notification test 2" --certificate=/path/to/certificate2.pem

    And the message and response:

    object(ZendService\Apple\Apns\Message)#70 (10) {
      ["id":protected]=>
      string(40) "bae22dd83c3c69a4e45dab9f5bda53d45447ffe0"
      ["token":protected]=>
      string(64) "c653c0d678c5c3084329e6d4b867d8bc9bdfd59f7a90ca5b312d392da44fd225"
      ["expire":protected]=>
      NULL
      ["alert":protected]=>
      object(ZendService\Apple\Apns\Message\Alert)#69 (8) {
        ["body":protected]=>
        string(31) "Notification test 2"
        ["actionLocKey":protected]=>
        NULL
        ["locKey":protected]=>
        NULL
        ["locArgs":protected]=>
        NULL
        ["launchImage":protected]=>
        NULL
        ["title":protected]=>
        NULL
        ["titleLocKey":protected]=>
        NULL
        ["titleLocArgs":protected]=>
        NULL
      }
      ["badge":protected]=>
      NULL
      ["sound":protected]=>
      string(13) "bingbong.aiff"
      ["contentAvailable":protected]=>
      NULL
      ["category":protected]=>
      NULL
      ["urlArgs":protected]=>
      NULL
      ["custom":protected]=>
      array(0) {
      }
    }
    object(ZendService\Apple\Apns\Response\Message)#71 (2) {
      ["id":protected]=>
      NULL
      ["code":protected]=>
      int(0)
    }
    

    And neither of the notifications were delivered to the devices... anyone can help? That's not like the issue #61 because I'm sending these notifications one at a time.

    opened by khrizt 7
  • apple push notification not sending

    apple push notification not sending

    i am using this but push notification is not being sent to ios devices , it sends to android without any issue but with ios doesn't send do u know how to solve? i use https://packagist.org/packages/davibennun/laravel-push-notification in lumen framework and i found an article : https://onesignal.com/blog/ios-13-introduces-4-breaking-changes-to-notifications/ @seyfer can u help me in this please . I am trying with same cetficate using pushtry.com and push gets delivered but not from the backend server , not even using cli mode

    2.x asap help-wanted 
    opened by sarveshamrit 2
  • APNs provider API requirement starts March 31

    APNs provider API requirement starts March 31

    Last Friday Apple send to our company this mail message:

    The HTTP/2‑based Apple Push Notification service (APNs) provider API lets you take advantage of great features, such as authentication with a JSON Web Token, improved error messaging, and per‑notification feedback. If you still send push notifications with the legacy binary protocol, make sure to upgrade to the APNs provider API as soon as possible. APNs will no longer support the legacy binary protocol after March 31, 2021.

    We are using your great library to send android/ios push notification (version 2.3.1) can you confirm as that your library support the new apple specification?

    If you don't support that specification in 2.3.1 or newer release of your library do you plan to support that in the next one?

    2.x asap help-wanted 
    opened by domenico-renna 11
  • Zend dependencies are abandoned

    Zend dependencies are abandoned

    Composer outputs:

    Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead. Package zendframework/zend-validator is abandoned, you should avoid using it. Use laminas/laminas-validator instead. Package zendframework/zend-json is abandoned, you should avoid using it. Use laminas/laminas-json instead. Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead. Package zendframework/zend-uri is abandoned, you should avoid using it. Use laminas/laminas-uri instead. Package zendframework/zend-loader is abandoned, you should avoid using it. Use laminas/laminas-loader instead. Package zendframework/zend-http is abandoned, you should avoid using it. Use laminas/laminas-http instead. Package zendframework/zendservice-google-gcm is abandoned, you should avoid using it. No replacement was suggested. Package zendframework/zendservice-apple-apns is abandoned, you should avoid using it. No replacement was suggested.

    2.x asap help-wanted 
    opened by risototh 5
  • Different Exception Handlung GCM <> Apns?

    Different Exception Handlung GCM <> Apns?

    Hi, due to live-server problems i've noted that GCM errors get a "PushException" while Apns Error just throw something deep down the zend framework. I propose to handle it the same as in gcm.php:

    --- a/vendor_patches/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/Apns.php
    +++ b/vendor_patches/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/Apns.php
    @@ -23,6 +23,7 @@ use ZendService\Apple\Apns\Client\Message as ServiceClient;
     use ZendService\Apple\Apns\Message as ServiceMessage;
     use ZendService\Apple\Apns\Message\Alert as ServiceAlert;
     use ZendService\Apple\Apns\Response\Message as ServiceResponse;
    +use ZendService\Apple\Exception\RuntimeException as ServiceRuntimeException;
    ·
     /**
      * APNS adapter.
    @@ -96,7 +97,7 @@ class Apns extends BaseAdapter implements FeedbackAdapterInterface
    ·
                     $this->response->addOriginalResponse($device, $response);
                     $this->response->addParsedResponse($device, $responseArr);
    -            } catch (\RuntimeException $e) {
    +            } catch (ServiceRuntimeException $e) {
                     throw new PushException($e->getMessage());
                 }
             }
    
    enhancement 2.x help-wanted 
    opened by tbsmark86 0
  • Deprecation Notice: Class Sly\Sly\NotificationPusher\Adapter\ApnsAPI

    Deprecation Notice: Class Sly\Sly\NotificationPusher\Adapter\ApnsAPI

    Deprecation Notice: Class Sly\Sly\NotificationPusher\Adapter\ApnsAPI located in ./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/ApnsAPI.php does not comply with psr-4 autoloading standard

    https://github.com/Ph3nol/NotificationPusher/blob/master/src/Sly/NotificationPusher/Adapter/ApnsAPI.php#L9

    bug 2.x help-wanted 
    opened by go24dev 0
  • Use of various abandoned/renamed packages

    Use of various abandoned/renamed packages

    Using this require:

        "require": {
            "sly/notification-pusher": "^2.3"
        },
    

    There are a lot of warnings spewed

    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Package operations: 23 installs, 0 updates, 0 removals
      - Installing psr/log (1.1.2): Loading from cache
      - Installing symfony/debug (v4.4.5): Loading from cache
      - Installing symfony/polyfill-ctype (v1.14.0): Loading from cache
      - Installing symfony/filesystem (v4.4.5): Downloading (100%)         
      - Installing doctrine/inflector (1.3.1): Downloading (100%)         
      - Installing zendframework/zend-json (3.1.2): Downloading (100%)         
      - Installing zendframework/zend-stdlib (3.2.1): Downloading (100%)         
      - Installing psr/container (1.0.0): Loading from cache
      - Installing container-interop/container-interop (1.2.0): Downloading (100%)         
      - Installing zendframework/zend-validator (2.13.0): Downloading (100%)         
      - Installing zendframework/zend-escaper (2.6.1): Downloading (100%)         
      - Installing zendframework/zend-uri (2.7.1): Downloading (100%)         
      - Installing zendframework/zend-loader (2.6.1): Downloading (100%)         
      - Installing zendframework/zend-http (2.11.2): Downloading (100%)         
      - Installing zendframework/zendservice-google-gcm (2.1.1): Downloading (100%)         
      - Installing zendframework/zendservice-apple-apns (1.4.1): Downloading (100%)         
      - Installing symfony/process (v4.4.5): Downloading (100%)         
      - Installing symfony/service-contracts (v2.0.1): Loading from cache
      - Installing symfony/polyfill-php73 (v1.14.0): Loading from cache
      - Installing symfony/polyfill-mbstring (v1.14.0): Loading from cache
      - Installing symfony/console (v4.4.5): Loading from cache
      - Installing symfony/options-resolver (v4.4.5): Downloading (100%)         
      - Installing sly/notification-pusher (v2.3.6): Downloading (100%)         
    zendframework/zend-json suggests installing zendframework/zend-json-server (For implementing JSON-RPC servers)
    zendframework/zend-json suggests installing zendframework/zend-xml2json (For converting XML documents to JSON)
    zendframework/zend-validator suggests installing psr/http-message (psr/http-message, required when validating PSR-7 UploadedFileInterface instances via the Upload and UploadFile validators)
    zendframework/zend-validator suggests installing zendframework/zend-db (Zend\Db component, required by the (No)RecordExists validator)
    zendframework/zend-validator suggests installing zendframework/zend-filter (Zend\Filter component, required by the Digits validator)
    zendframework/zend-validator suggests installing zendframework/zend-i18n (Zend\I18n component to allow translation of validation error messages)
    zendframework/zend-validator suggests installing zendframework/zend-math (Zend\Math component, required by the Csrf validator)
    zendframework/zend-validator suggests installing zendframework/zend-i18n-resources (Translations of validator messages)
    zendframework/zend-validator suggests installing zendframework/zend-servicemanager (Zend\ServiceManager component to allow using the ValidatorPluginManager and validator chains)
    zendframework/zend-validator suggests installing zendframework/zend-session (Zend\Session component, ^2.8; required by the Csrf validator)
    zendframework/zend-http suggests installing paragonie/certainty (For automated management of cacert.pem)
    symfony/service-contracts suggests installing symfony/service-implementation
    symfony/console suggests installing symfony/event-dispatcher
    symfony/console suggests installing symfony/lock
    Package zendframework/zend-json is abandoned, you should avoid using it. Use laminas/laminas-json instead.
    Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
    Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
    Package zendframework/zend-validator is abandoned, you should avoid using it. Use laminas/laminas-validator instead.
    Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
    Package zendframework/zend-uri is abandoned, you should avoid using it. Use laminas/laminas-uri instead.
    Package zendframework/zend-loader is abandoned, you should avoid using it. Use laminas/laminas-loader instead.
    Package zendframework/zend-http is abandoned, you should avoid using it. Use laminas/laminas-http instead.
    Package zendframework/zendservice-google-gcm is abandoned, you should avoid using it. No replacement was suggested.
    Writing lock file
    Generating autoload files
    

    It would look like https://github.com/Ph3nol/NotificationPusher/blob/master/composer.json#L33-L34 want updating....

    bug 2.x help-wanted 
    opened by reedy 1
Owner
Cédric Dugat
@MinutPass CTO/Co-founder.
Cédric Dugat
Send push notifications to apple devices (iPhone, iPad, iPod).

Apple Apn Push Send push notifications to apple devices (iPhone, iPad, iPod). Support authenticators: Certificate Json Web Token Supported protocols:

Vitaliy Zhuk 157 Dec 1, 2022
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
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
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
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
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
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
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
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
Push Notifications using Laravel

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

Webelight Solutions 26 Jul 22, 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 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
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 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
: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
Sends notifications via one or more channels (email, SMS, ...).

Notifier Component The Notifier component sends notifications via one or more channels (email, SMS, ...). Resources Documentation Contributing Report

Symfony 610 Jan 3, 2023
Laravel Security Notifications

This package adds security notifications to warn your users when significant security events occur so that they aren't the next victim of an attacker.

Anteris 5 Feb 8, 2022
Laravel package to launch toast notifications.

Laravel package to launch toast notifications. This package provides assistance when using toast notifications. Using the iziTOAST package, which allo

Anthony Medina 7 Nov 25, 2022