chatsikm/firebase-broadcast-driver-demo

一个用于Laravel的Firebase广播驱动示例

dev-master 2022-12-05 12:09 UTC

This package is not auto-updated.

Last update: 2024-09-24 19:24:28 UTC


README

FireBase广播驱动
Latest Stable Version Total Downloads

安装

  • composer require ctf0/firebase-broadcast-driver

  • 该包内部使用kreait/firebase-php向Firebase发送数据。

配置

// config/broadcasting

return [
    'connections' => [
        // ...

        'firebase' => [
            'driver'          => 'firebase',
            'type'            => 'firestore', // database or firestore
            '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联系。