Recommend this page to a friend! |
![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum (1) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2022-05-13 (Less than 1 hour ago) ![]() | Not enough user ratings | Total: Not yet counted | Not yet ranked |
Version | License | PHP version | Categories | |||
firebase-push 1.0 | GNU General Publi... | 5 | PHP 5, Wireless and Mobile, Web services |
Description | Author | |
This package can send push notifications to mobile device users. |
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 notification image url
$model->setImage("https://img.com/path/to/foo.png");
$model->setClickAction($click);
$model->setReference($ref);
$model->setBroadcast($id);
$model->setMeta($array);
$model->setBadge($int);
$model->setIsBackground($bool);
$model->setSound($sound);
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Doc. | Documentation |
![]() |
/ | src |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
Version Control | Unique User Downloads | |||||||
100% |
|
User Comments (1) | |||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.