ctf0 / firebase-broadcast-driver
laravel的firebase广播驱动程序
v1.3.0
2023-01-07 14:13 UTC
Requires
- illuminate/support: >=5.5 <10.0
- kreait/firebase-php: *
Suggests
- morrislaptop/firestore-php: Required to use with firestore db.
README
FireBase Broadcast Driver
安装
-
composer require ctf0/firebase-broadcast-driver -
该包内部使用
kreait/firebase-php向firebase发送数据。
配置
// config/broadcasting return [ 'connections' => [ // ... 'firebase' => [ 'driver' => 'firebase', 'type' => 'firestore', // database, firestore or messaging 'databaseURL' => env('FB_DB_URL'), // the real time database url 'creds_file' => env('FB_CREDENTIALS_FILE'), // service account json file 'collection_name' => env('FB_COLLECTION_NAME'), // ex.notifications ], ], ];
用法
-
将
BROADCAST_DRIVER=firebase添加到.env -
目前不支持laravel-echo "任何帮助都将受到欢迎" 但不用担心,您仍然会得到与其他广播驱动程序相同的有效载荷。
但是,如果您使用
vue,您可以查看firebase API 文档或vuefire,了解如何监听更改并相应地更新您的应用程序用户。
通知数据示例
{
"notifications" : {
"-LkgtAVVw0Ztwyjayd9n" : {
"channel" : "private-App.User.091b0f7e-805b-4aab-8c99-445039157783",
"data" : {
"body" : "some body",
"id" : "d54c44a2-8a42-43a4-bae0-e2b159d1533b",
"title" : "some title",
"type" : "App\\Notifications\\AlertUser"
},
"event" : "Illuminate\\Notifications\\Events\\BroadcastNotificationCreated",
"timestamp": 1564183089538
}
}
}
安全性
如果您发现任何与安全相关的问题,请发送电子邮件至ctf0-dev@protonmail.com。