kreait / firebase-php

Unofficial Firebase Admin SDK for PHP
https://firebase-php.readthedocs.io/
MIT License
2.24k stars 428 forks source link

link in fcm_options (part WebPushConfig) not working #567

Closed RomanTruhanov closed 3 years ago

RomanTruhanov commented 3 years ago

Hi all. I have a problem wich fcm_options link not working in laravel 8 and windows 10, but notification config work fine. Find old question about my problem this https://github.com/kreait/firebase-php/issues/316 read and not get right workable solusion my code is

$config = WebPushConfig::fromArray([
    'notification' => [
        'title' => 'Backend',
        'body' => 'Тест работы Firebase Cloud Messenger (FCM)',
        'icon' => 'http://localhost:3000/favicon.ico',
    ],

    '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');

$response = $messaging->send($message);
jeromegamez commented 3 years ago

What exactly is not working? Do you get an error/exception, or does the notification not arrive at the target device, or does clicking on the notification not open?

If there is an error while sending the notification, you should get an exception - if the notification doesn't arrive, then it could be a Firebase delivery issue. If the browser doesn't open the link, it could be something in the handling of the notification within the browser or your application. In both cases, I'm afraid I will not be able to adequately help, but I would say: check that the link is included in the message on the client. If it is included, try different browsers and/or check how your web app is handling the notification. 🤞🏼

RomanTruhanov commented 3 years ago

i don't get any errors my fcm message is look at this image but if clicked him just closed (don't go to link)

jeromegamez commented 3 years ago

Unfortunately, I can't tell you why this is happening and I don't know a solution to it... the official docs say that it should be working, but from this Admin SDK's perspective there's not much we can do. I just checked in the Admin Node SDK and it's defined in the same way there: https://github.com/firebase/firebase-admin-node/blob/93362d5721fc45f3fc541543813d5739eda8ba2d/src/messaging/index.ts#L148-L155

As I can't adequately help you here, I think StackOverflow or the Firebase Support would be a better way to find a solution to this - if you find a solution, please share it with us here, perhaps I can make a new FAQ item out of it! 🙏🏼

aroon9002ahmed commented 2 years ago

link not work if you open same site on google chrom .... close website page than click on message website will open