PHP Classes

PHP Firebase Push Notification: Send push notifications to mobile device users

Recommend this page to a friend!
  Info   View files Documentation   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-05-16 (3 months ago) RSS 2.0 feedNot enough user ratingsTotal: 64 This week: 2All time: 10,115 This week: 107Up
Version License PHP version Categories
firebase-push 1.0GNU General Publi...5PHP 5, Wireless and Mobile, Web services
Description Author

This package can send push notifications to mobile device users.

It can send HTTP requests to the Google Firebase API Web server to request to send push notifications to one or more users of mobile devices.

The package can configure the push notification messages to set several types of parameters.

Currently, this package supports the following parameters:

- Message priority

- Message title

- Message body

- Message image

- Message icon

- Message link

- Message badge

- Link click action in the recipient mobile device

- Make the recipient user's mobile device vibrate

- Make the recipient user's mobile device play a sound

- Etc.

Picture of Ujah Chigozie peter
  Performance   Level  
Name: Ujah Chigozie peter <contact>
Classes: 16 packages by
Country: Nigeria Nigeria
Age: 31
All time rank: 249013 in Nigeria Nigeria
Week rank: 16 Up1 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 7x

Details

A simple php class to help you send firebase push notification from php curl. It will allow you to push cloud messaging through firebase in 3 different way.

1. Send to a single device id 2. Send to a multiple device ids 3. Send to a specific topic subscribers

Installation

Installation is super-easy via Composer:

composer require peterujah/php-firebase-notification

initialize the firebase class with your google api key

use Peterujah\NanoBlock\FirebaseServiceModel;
use Peterujah\NanoBlock\FirebaseService;

define("GOOGLE_FCM_API_KEY", "AAAAtXpvsYU:APXXX");
$model = new FirebaseServiceModel();
$service = new FirebaseService(GOOGLE_FCM_API_KEY);

Sending a message to a single device id can be done like this.

$model->setTo("f-bbVq2uCgY:APA91bF0s7jk5lXXy");
$model->setTitle("I code it here");
$model->setMessage("Will you like to join us?");
$response = $service->notify($model);
var_export($response);

Sending a message to a multiple user IDs can be done like this

$model->setTo(array("User-A", "User-B", "User-C"));
$model->setTitle("I code it here");
$model->setMessage("Will you like to join us?");
$response = $service->notify($model);
var_export($response);

Sending a message by topic IDs/name can be done like this

$model->setIsTopic(FirebaseServiceModel::TOPIC);
$model->setTo("TOPIC_GROUP_ID_NAME");
$model->setTitle("I code it here");
$model->setMessage("Will you like to join us?");
$response = $service->notify($model);
var_export($response);

Methods

Set the notification payload node type. The default is FirebaseServiceModel::NODE_NOTIFICATION

$model->setNode(FirebaseServiceModel::NODE_NOTIFICATION | FirebaseServiceModel::NODE_DATA);

Sets the notification to send to topic. The default is false, pass FirebaseServiceModel::TOPIC or true, to enable topic.

$model->setIsTopic(FirebaseServiceModel::TOPIC);

Sets the notification body, default is message

$model->setBody($body);

Sets the notification image url.

$model->setImage("https://img.com/path/to/foo.png");

Sets the notification click action for android.

$model->setClickAction($click);

Sets the notification refernce for custom use.

$model->setReference($ref);

Sets the notification additional meta data for custom use.

$model->setMeta($array);

Sets the notification badge id.

$model->setBadge($int);

Sets the notification background state.

$model->setIsBackground($bool);

Sets the notification sound type.

$model->setSound($sound);
  Files folder image Files  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file FirebaseService.php Class Class source
  Plain text file FirebaseServiceModel.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:64
This week:2
All time:10,115
This week:107Up
User Comments (1)
 
For more information send a message to info at phpclasses dot org.