semantechs/notification

用于处理所有类型通知的推送代理

v2.1.5 2024-09-26 19:31 UTC

README

打开 composer.json 并添加以下行

"autoload": {

    ....

    "psr-4": {

        ....

        "Sementechs\\Notification\\": "vendor/semantechs/notification/src/"

    }

},

在配置文件夹中的 app.php 中添加以下行

'providers' => ServiceProvider::defaultProviders()->merge([

    ....

    Sementechs\Notification\NotificationServiceProvider::class,

])->toArray(),

将您的 Firebase 服务账户文件放置在存储文件夹中,并在 .env 文件中添加文件名

FIREBASE_CREDENTIALS=file_name.json

BROADCAST_DRIVER=puhser

PUSHER_APP_ID=

PUSHER_APP_KEY=

PUSHER_APP_SECRET=

PUSHER_HOST=

PUSHER_PORT=443

运行以下命令

composer dump-autoload

php artisan vendor:publish --tag=laravel-assets

php artisan migrate

可用方法

  1. 发送通知

$notificationObject = [ 'sender_id' => 1, 'receiver_ids' => [ 1, 2, 3 ], 'channel' => 'web', // web, mobile 'body' => [ 'title' => 'Title', 'body' => 'Detail' ], 'type' => 'admin' // admin, user ];

NotificationController::sendNotification($notificationObject);

  1. 获取所有通知

$type = web/user

NotificationController::getAllNotifications($type, $userId)

  1. 读取所有通知

$data = 所有通知的对象

NotificationController::readAll($data)