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

Overview

Notificato Build Status of Master

Notificato takes care of push notifications in your PHP projects.

Italian: notificato è: participio passato English: notified

Why use Notificato instead of X?

Notificato has some advantages not all other PHP push libraries have:

  1. Supports multiple APNS certificates, so you can push to multiple Apps/Passbook Passes
  2. Takes excellent care of PHPs buggy SSL-sockets, handles quirks and error responses correctly
  3. Well tested with unit tests and nice Object-Oriented structure

Installation

Installation with Composer is recommended. Run the require command to add Notificato to your project:

composer require wrep/notificato

Suggestion: There is also a Notificato for Symfony bundle available, highly recommended for Symfony2 & Symfony3 users.

Getting started

  1. Take a look at the snippet below for a impression how Notificato works
  2. Read the documentation it will help you with common use cases
  3. Check out the API docs for a deeper understanding what Notificato is capable of
<?php
// This imports the Composer autoloader
require_once('vendor/autoload.php');

use Wrep\Notificato\Notificato;

class GettingStarted
{
	/**
	 * This example sends one pushnotification with an alert to Apples production push servers
	 */
	public function sendOnePushNotification()
	{
		// First we get a Notificato instance and tell it what certificate to use as default certificate
		$notificato = new Notificato('./certificate.pem', 'passphrase-to-use');

		// Now we get a fresh messagebuilder from Notificato
		//  This message will be send to device with pushtoken 'fffff...'
		//  it will automaticly be associated with the default certificate
		//  and we will set the red badge on the App icon to 1
		$message = $notificato->messageBuilder()
								->setDeviceToken('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')
								->setBadge(1)
								->build();

		// The message is ready, let's send it!
		//  Be aware that this method is blocking and on failure Notificato will retry if necessary
		$messageEnvelope = $notificato->send($message);

		// The returned envelope contains usefull information about how many retries where needed and if sending succeeded
		echo $messageEnvelope->getFinalStatusDescription();
	}

	/**
	 * This example reads all unregistered devices from Apples feedback service
	 */
	public function readFeedbackService()
	{
		// First we get the a Notificato instance and tell it what certificate to use as default certificate
		$notificato = new Notificato('./certificate.pem', 'passphrase-to-use');

		// Now read all "tuples" from the feedback service, be aware that this method is blocking
		$tuples = $notificato->receiveFeedback();

		// The tuples contain information about what device unregistered and when it did unregister.
		//  Don't forget to check if the device reregistered after the "invaidated at" date!
		foreach ($tuples as $tuple)
		{
			echo 'Device ' . $tuple->getDeviceToken() . ' invalidated at ' . $tuple->getInvalidatedAt()->format(\DateTime::ISO8601) . PHP_EOL;
		}
	}
}

$gettingStarted = new GettingStarted();
$gettingStarted->sendOnePushNotification();
$gettingStarted->readFeedbackService();

Contribute

We'll love contributions, read Contribute.md for some more info on what you can do and stuff that you should know if you want to help!

License & Credits

Notificato is released under the MIT License by Mathijs Kadijk, so feel free to use it in commercial and non-commercial projects.

Issues
  • SSL3_WRITE_PENDING warnings while sending lot of push-alerts

    SSL3_WRITE_PENDING warnings while sending lot of push-alerts

    WARNING

    fwrite(): SSL operation failed with code 1. OpenSSL Error messages: error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry

    /Wrep/Notificato/Apns/Gateway.php at line 107. {"messageEnvelope":"[object](Wrep\Notificato\Apns\MessageEnvelope: {})","binaryMessage":null,"bytesSend":0,"retryMessageEnvelope":"[object](Wrep\Notificato\Apns\MessageEnvelope: {})"}

    bug 
    opened by chekalsky 16
  • Android GCM push messages support

    Android GCM push messages support

    enhancement 
    opened by mac-cain13 9
  • Execution time

    Execution time

    Hi,

    Everytime I execute the function, I get:

    Fatal error: Maximum execution time of 30 seconds exceeded in ..../Wrep/Notificato/Apns/Gateway.php on line 173
    

    The push notification is sent, but the server code never resumes. It just keeps running until our server maximum settings.

    opened by pedro380085 9
  • Problem with loading private key

    Problem with loading private key

    Though my setup is correct, i always got this error

    Passphrase given, but the private key in XXX is not encrypted, please make sure you are using the correct certificate/passphrase combination.
    

    Commenting Certificate.php on line 171. solved the problem..

    Push notification sent without problem.

    opened by dexcell 7
  • "Call to a member function setStatus() on a non-object" in Gateway.php

    PHP Fatal error: Call to a member function setStatus() on a non-object in /var/www/sfbackend/releases/20131030144915/vendor/wrep/notificato/src/Wrep/Notificato/Apns/Gateway.php on line 192

    I sometimes get this error. Not sure about it origins but it makes sense because method retrieveMessageEnvelope can return null while on line 192 we have setStatus() call on that return value.

    opened by eXtreme 6
  • Support for variable length of push token

    Support for variable length of push token

    Hi,

    Using Notificato we received some push tokens that were not a hexadecimal with a length of 64. In the APNs documentation it says:

    IMPORTANT
    APNs device tokens are of variable length. Do not hard-code their size.
    

    Is there a specific reason to check on the length. Can you remove this check otherwise?

    // Check if the length of the devicetoken is correct
    if (64 != strlen($deviceToken)) {
         throw new \InvalidArgumentException('Invalid device token given, incorrect length: ' . $deviceToken . ' (' . strlen($deviceToken) . ')');
    }
    
    opened by Tayfun74 5
  • Push notification is not being delivered to device

    Push notification is not being delivered to device

    When I require this package via composer it gives me dependency error for openssl. Now I have updated version of openssl on my mac but it is still giving this error;

    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Installation request for wrep/notificato ^1.2 -> satisfiable by wrep/notificato[1.2.0].
        - wrep/notificato 1.2.0 requires lib-openssl * -> the requested linked library openssl has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    

    I is not clear from the message that which openssl version is required. Here my current version of openssl; OpenSSL 1.0.2h 3 May 2016 Please let me know if can change any version to make it work?

    opened by tahirwaseer 4
  • Certificate Name (CN) not correctly defining APNS environment

    Certificate Name (CN) not correctly defining APNS environment

    Noticed now Apple are naming their APNS certificates differently.

    They are named Apple Push Services rather than specificly Production or Development

    https://github.com/mac-cain13/notificato/blob/master/src/Wrep/Notificato/Apns/Certificate.php#L149

    As they are now merging the two, unsure how accurately it would detect the correct environment to use, however got it working by adding an extra condition to catch the updated name and point to production.

    opened by chorsnell 4
  • Error: You MUST recompile PHP with a larger value of FD_SETSIZE

    Error: You MUST recompile PHP with a larger value of FD_SETSIZE

    Hi, I am having the following error poping up:

    PHP Warning: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE. It is set to 1024, but you have descriptors numbered at least as high as 1048. --enable-fd-setsize=2048 is recommended, but you may want to set it to equal the maximum number of open files supported by your system, in order to avoid seeing this error again at a later date. in /data/web/virtuals/clients/client1/web1094/web/v2/vendor/wrep/notificato/src/Wrep/Notificato/Apns/Gateway.php:152

    I know its not related directly to Notificato, but I was wondering if anybody had this issu and if there is some kind of workaround.

    Thanks

    opened by adusak 3
  • Add category field

    Add category field

    This is quite an important field you can't set right now.

    Suggested in https://github.com/mac-cain13/notificato/pull/44

    easy pick 
    opened by mac-cain13 3
  • Legacy APNS push notifications

    Legacy APNS push notifications

    Hello,

    Does notificato have a chance to migrate to the Apple replacement HTTP/2 API? https://developer.apple.com/news/?id=uzyxiriy

    Thanks All the best

    opened by sglessard 0
  • Wrep/Notificato/Apns/Gateway.php READ_TIMEOUT

    Wrep/Notificato/Apns/Gateway.php READ_TIMEOUT

    Hi is there a reason why the variable READ_TIMEOUT in SslSocket is not configurable? What we're seeing now is a timeout of 1 second on each push notification request to apple.. because the reply is always empty...

    Push notifications are most of the time fire & forget imho, the reply doesn't matter ...

    Will fork this library and put the variable to 0 but would be nice if this configurable and that I can continue to use this library.

    Thanks!

    opened by jrots 2
  • Add support for new fields like expiration and priority

    Add support for new fields like expiration and priority

    See https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Appendixes/BinaryProviderAPI.html

    opened by mac-cain13 0
  • Make Notification Factory cache certificates, or make the factory implement an interface

    Make Notification Factory cache certificates, or make the factory implement an interface

    I get "bad password" errors when I send multiple notifications in the same process - using a new message builder for each one, creating a new certificate for each (via Notificato::createCertificate method). Simple solution was to cache the certificate objects so they can be used again. But it would be nice if the CertificateFactory supported this. It only caches a default one. I'd like to key the cache off of the pem location. Was going to implement my own CertificateFactory for this, but turns out the setCertificateFactory typehints to the concrete implementation of Apns\CertificateFactory. I can make my own factory and use it outside the scope of this library, but thought I would recommend it to the repo... sorry, no time for PRs!

    enhancement 
    opened by stevenmyhre 1
Releases(1.2.1)
Owner
Mathijs Kadijk
CTO @getmibo — We're hiring ✨
Mathijs Kadijk
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 149 Dec 7, 2021
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 Jan 2, 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 10, 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 62 Jan 4, 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 2 Dec 1, 2021
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 201 Jan 13, 2022
Push Notifications using Laravel

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

Webelight Solutions 24 Jan 13, 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 Jan 9, 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 Jan 13, 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
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 186 Sep 26, 2021
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 499 Jan 13, 2022
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 Dec 24, 2021
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 3 Aug 31, 2021
Laravel Subscribable Notifications

Laravel Subscribable Notifications This package allows you to subscribe your app Users to your app Notifications and dispatch them without specifying

Andrés Santibáñez 120 Jan 5, 2022
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 16 Jan 12, 2022
Flexible Flash notifications for Laravel

Introduction Laravel Notify is a package that lets you add custom notifications to your project. A diverse range of notification design is available.

Arthur Monney 1k Jan 11, 2022
A package to simplify automating future notifications and reminders in Laravel

Laravel Snooze Schedule future notifications and reminders in Laravel Why use this package? Ever wanted to schedule a future notification to go out at

Thomas Kane 599 Jan 11, 2022
📨 Facebook Notifications Channel for Laravel

Facebook Notifications Channel for Laravel This package makes it easy to send notifications using the Facebook Messenger with Laravel. Contents Instal

Laravel Notification Channels 134 Jan 12, 2022