heyharpreetsingh/fcm
最新稳定版本:1.0.0
Composer 安装命令:
composer require heyharpreetsingh/fcm
包简介
Laravel package to send push notification on mobile(android, ios), and web using Firebase Cloud Messaging.
README 文档
README
Description
Send a push notification to user mobile, and web using FCM (Firebase Cloud Messaging).
Installing via Composer
composer require heyharpreetsingh/fcm
Next, Register the service provider in file bootstrap/providers.php for L11 AND config/app.php in the providers key for l10
Heyharpreetsingh\FCM\Providers\FCMServiceProvider::class
Next, Generate new private key from your Firebase:
In order to get this file, let’s go to your Firebase projects page, then select your project and as shown below, go to Project Settings.
Click on the Service accounts tab, then Generate new private key.
A file named -firebase-adminsdk-.json get generated, and it is your ServiceAccount.json file! Rename it (or change the path) and you’re ready to go.
⚠️ Your file can be generated only 1 time, if you create a new key, it will be a different one. Although, your previous key/file will still working until you decide to delete it (click on Manage service account permissions).
Next, Put your ServiceAccount.json file in your project storage directory and add the name of json file in your project .env file:
FCM_GOOGLE_APPLICATION_CREDENTIALS=path/to/serviceAccountKey.json
Send a push notification on mobile(android, ios), and web.
use a FCMFacade to send a notification
use Heyharpreetsingh\FCM\Facades\FCMFacade; FCMFacade::send([ "message" => [ "token" => "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", //device token "notification" => [ "body" => "This is an FCM notification message!", "title" => "FCM Message" ] ] ]);
You can pass additional data using the official doc of FCM.
- https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send
- https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Message
If you have any issue or suggestion feel free to contact.
License
Open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 78
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-14

