preneesh / yii2-firebase-notifications
Sending Firebase Notification from Yii2 Application
Installs: 1 141
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-httpclient: ~2.0.0
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);