farjihacker / fcm-push-notify
There is no license information available for the latest version (dev-master) of this package.
Google Push Notification Library
dev-master
2019-01-09 12:58 UTC
Requires
- php: >=5.5.0
This package is auto-updated.
Last update: 2025-02-10 07:44:05 UTC
README
This is the library for sent push notification using Google Firebase(FCM) Push Notification.
Installation
Use the Composer
to install FCM-PUSH-Notify Library.
composer require farjihacker/fcm-push-notify
Usage
Step 1: Install using above command.
Step 2: Import/Use this Namespace.
use FirebaseNotify\Firebase; // Firebase Utility use FirebaseNotify\Push; // Create Message with JSON Formate
Step 3: Create Two Object.
$firebase = new Firebase("FIREBASE_API_KEY"); // Pass Your API Key as Param $push = new Push();
Step 4: Create JSON Data Object Using $push
Object.
// optional payload $payload = array(); $payload['team'] = 'India'; $payload['score'] = '5.6'; // notification title $title = "Test Title"; // notification message $message = "MSG"; // push type - single user / topic $push_type = "individual"; // whether to include to image or not $include_image = ""; $push = new Push(); $push->setTitle($title); $push->setMessage($message); if ($include_image) { $push->setImage('http://api.androidhive.info/images/minion.jpg'); } else { $push->setImage(''); } $push->setIsBackground(FALSE); $push->setPayload($payload);
Step 5: Sent Push Notification using $firebase
object.
//Get JSON Object $json = $push->getPush(); //echo "<pre>"; //print_r($json); // User Token $regId = "USER_TOKEN"; $response = $firebase->send($regId, $json); // Enable this line to check firebase success/error response. //print_r($response);
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.