Laravel 推送通知。如何获取设备令牌? -fcm

Laravel push notification. How to get devices token? -fcm

我有一个 webview 应用程序。我在 Laravel 中编写了该项目。我想使用推送通知。但是我怎样才能得到设备令牌呢?我在哪里可以找到它?

$push->setMessage([
       'notification' => [
               'title'=>'This is the title',
               'body'=>'This is the message',
               'sound' => 'default'
               ],
       'data' => [
               'extraPayLoad1' => 'value1',
               'extraPayLoad2' => 'value2'
               ]
       ]);
$push->setApiKey('Server-API-Key');
$push->setDevicesToken(['deviceToken1'
    ,'deviceToken2',
    'deviceToken3'
]);

什么是 deviceToken1 2 3?

我在 Firebase 中创建了一个项目。我可以得到 API。但是我怎样才能找到并保存设备的令牌呢?我无法向屏幕发送通知。

所以基本上,您应该在前端使用 Firebase SDK 获取设备 ID/token,然后将其发送到您的 server/Laravel(将其保存在您的数据库中以备后用)。 根据您使用的前端,有不同的方法来获取设备 ID,您可以参考这些文档: