Download the PHP package reliefapps/notification-bundle without Composer
On this page you can find all versions of the php package reliefapps/notification-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reliefapps/notification-bundle
More information about reliefapps/notification-bundle
Files in reliefapps/notification-bundle
Package notification-bundle
Short Description A Bundle providing services to send push notifications
License MIT
Informations about the package notification-bundle
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
NB: Before version 1, backward compatibility may be broken. It is advised to force a single version of the bundle has shown here
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
Step 3 : Configure the Bundle
In your project, add at the end of the file app/config/config.yml
the following configuration :
Optional (but recommended) :
For improved error management for iOS notifications, you will need http2 support for cURL on your machine. See this tutorial.
Once you have followed this tutorial, check that cURL supports HTTP/2 by running :
If it works, you can remove the line :
in your app/config/config.yml
file.
Usage
Step 1: Create a Device Entity
First you will need to create you own Device Entity extending this Bundle's ReliefappsNotificationBundle:Device entity.
Then complete your app/config/config.yml
file with :
Step 2: Register some devices
In a strategic api controller (login, homepage), register the device UUID and token :
Step 3: Create a notification Body
The class NotificationBody allows you to create the content of a push notification.
Step 4: Send a push notification
You are ready to send your first Push Notification !
The function sendPush takes an array of devices and a notification body, and sends the Push notifications to the devices !
If a token is invalid, it will be set to null on your database automatically.
Advanced Configuration
Contexts
The configuration presented above does not allow you to switch servers (to switch between dev and prod) or to change apns_topic and certificates (to manage multiple applications from a single backend).
To solve this issue, we introduced the Object Context. A context is a set of configurations that can be used independently.
Contexts are defined in your :
All fields that are not filled in the context will be filled with the default configuration.
You can call the context by its name with the PushManager.
For more info, lookup Reliefapps\NotificationBundle\Resources\Utils\ContextManager and Reliefapps\NotificationBundle\Resources\Model\Context.
Additional fields
You may want to add some data to the notification wanted to be sent.
Documentation
Payloads
Entity : Reliefapps\NotificationBundle\Resources\Model\NotificationBody
Key | Description | iOS | Android |
---|---|---|---|
title | Title | [x] | [x] |
body | Main text | [x] | [x] |
ledColor | Led color on front of the phone | [ ] | [x] |
image | Path to the icon to use in the app | [ ] | [x] |
imageType | Shape of the notification icon | [ ] | [x] |
notId | Id of the notification to distinguish them | [ ] | [x] |
actions | List of action | [ ] | [x] |
badge | Badge number on app icon | [x] | [ ] |
category | iOS category tag (defined in your app) | [x] | [ ] |
Android Action
Entity : Reliefapps\NotificationBundle\Resources\Model\AndroidAction
Key | Description | iOS | Android |
---|---|---|---|
icon | Icon (name of an app drawable ressource) | [ ] | [x] |
title | Action text | [ ] | [x] |
callback | Function to call as the button is clicked | [ ] | [x] |
foreground | Open the app after click ? (default true) | [ ] | [x] |
inline | Use quick reply field ? (default false) | [ ] | [x] |