preneesh/yii2-firebase-notifications

Sending Firebase Notification from Yii2 Application

dev-master 2020-05-12 09:27 UTC

This package is not auto-updated.

Last update: 2024-04-24 04:46:31 UTC


README

Send firebase notification from Yii2 application

==

Send firebase notification from Yii2 application This extension enables to send firebase notification to single user to give user specific updates.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist preneesh/yii2-firebase-notifications "dev-master"

or add

"preneesh/yii2-firebase-notifications": "dev-master"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code :

Firebase cloud messageing Server key is required to use the extension, which can be obtained from Firebase console -> Project Overview -> Settings -> Cloud Messaging

use preneesh\FirebaseNotifications\Notification;

$service = new Notification('YOUR_KEY');

$message = array();
$message['title']= "New Offer";
$message['body']= "New Year offer for the all products";

#unique token to be captured from android app and stored against user for sending notification to specific user
$tokens = "d-Uh6MC1eTk:APA91bHjvSR3BDjfBqt4-ZkPbu69aije4HCzcKqvIpcBJof8Zc7z8jVeVb1WLGEjfgd6POBfW-qGUcSsESiOAOKbFnOHt_m1rk-deElMgIsojS7gpF7trgYmsLjrxICsZg7LRgPXyn6b-eqCk9nE";

$service->send($tokens,$message);