问题描述
我编写了后端 API 函数,它使来自 fcm(firebase 云消息传递)的 WebPush 通知几乎正常工作,但 fcm_options 链接不起作用,消息只需关闭女巫点击他。
在 github 中询问我的问题(我决定使用 laravel-firebase SDK (bug) 但在 SDK 中没有。
我使用:
PHP v8.0.0
Laravel v8.27.0
laravel-firebase v3.1
Windows 10(Microsoft Edge v89.0.774.27 测试版)
$config = WebPushConfig::fromArray([
'notification' => [
'title' => 'Backend','body' => 'Тест работы Firebase Cloud Messenger (FCM)','icon' => 'http://localhost:3000/favicon.ico','click_action' => 'https://www.google.com',],'fcm_options' => [
'link' => 'https://www.google.com'
],]);
$devicetoken = User::whereNotNull('device_token')->pluck('device_token')->all();
$notification = Notification::create($request->title,$request->body)->withImageUrl('https://picsum.photos/400/200');
$message = CloudMessage::withTarget(MessageTarget::TOKEN,$devicetoken[0])->withNotification($notification)->withWebPushConfig($config);
$messaging = app('firebase.messaging');
$messaging->send($message);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)