Push notifications
Class \Lib\Push
Introduction
This class provides a unique method to send push notification to one or more devices simultaneously on a given date.
Notifications are stored in a queue following their chosen sending date.
The queue is then depilated progressively according to the dates of dispatch.
Note
The history of the sendings can be consulted in the backoffice on the page /historique/load of your application.
Basic Usage
<?php
$push_params['target'] = array($user['deviceuid']);
$push_params['badge'] = "1";
$push_params['url'] = "";
$push_params['sound'] = "";
$push_params['inapp'] = "";
$push_params['expire_soft'] = "";
$push_params['expire_hard'] = "";
$push_params['priority'] = "";
$push_params['datas']['is_notif_from_ws'] = '1';
$push_params['datas']['type'] = 'sent';
$now = new \DateTime();
$message = "test push notification";
\Lib\Push::send($message, $push_params, $now->format('Y-m-d H:i:s'));
Methods
send
<?php public static function send(string $message, array $params, datetime $datetosend, string $src = "WS")
Description
Add a push notification to queue.
Parameters
message
The message to display inside the notificationparams
An array of additional parametersdatetosend
The date inY-m-d H:i:s
format.src
An optional parameter used to specify the origin of the notification (backoffice, webservice)
Return
Returns a notification id.
Updated about 7 years ago