agent/firepush-php

A PHP package for send real time push notification in client user agent with firebase

dev-master 2022-02-04 16:54 UTC

This package is not auto-updated.

Last update: 2025-01-05 07:27:35 UTC


README

Small PHP library for send Cloud Messaging

Install Library:

composer require agent/firepush-php

Access Google Firebase Console

Firebase gives you functionality like analytics, databases, messaging and crash reporting so you can move quickly and focus on your users. (See Enable Project)

Start Agent Object:

$firepush = new Agent\Firepush\Service('AAAAWj6Hc4E:LONG-SERVER-CLOUD-MESSAGE-KEY');

💻 The class will connect via api to the project in console.firebase.google.com

Send Signle Device push notice to client

$firepush->to('client_token');

$notify = array(
           'title' => 'FCM Message',
           'body' => 'FCM Message Text',
           'icon' => 'http://myproject.com/icon.png',
           'link' => 'http://myproject.com'
         );

$firepush->notification($notify);
                    
$firepush->send();     

//or concatenate:

$firepush->to('client_token')->notification($notify)->send()
               

🚀 The system Send the notification in device set in to()

Send Multiple Device push notice to client


$clients_token = array(
// array of token to send
);

$firepush->to($clients_token);

$notify = array(
           'title' => 'FCM Message',
           'body' => 'FCM Message Text',
           'icon' => 'http://myproject.com/icon.png',
           'link' => 'http://myproject.com'
         );

$firepush->notification($notify);
                    
$firepush->send();     

//or concatenate:

$firepush->to($clients_token)->notification($notify)->send()
               

🚀 The system Send the notification in ALL device set in to array()

Retrive Single/Multiple Messages ID


CODE FOR SEND NOTIFICETION
                    
$firepush->send();     

// After send:

$firepush->getMessageIds();
               

🚀 The system retrive all message id from call