laravel-notification-channels / fcm

Firebase Cloud Messaging (FCM) notifications channel for Laravel
https://laravel-notification-channels.com/
MIT License
476 stars 123 forks source link

Link Not Getting Passed (Web Push) #128

Closed haleyngonadi closed 1 year ago

haleyngonadi commented 1 year ago

I, unfortunately, can't seem to get the web push to work with a link. Can you please confirm if this code is correct?

 public function toFcm()
    {
        return FcmMessage::create()
            ->setData(['type' => 'date_change', 'route' => 'Show'])
            ->setNotification(
                \NotificationChannels\Fcm\Resources\Notification::create()
                    ->setTitle($title)
                    ->setBody($message)
                    ->setImage('https://i.ytimg.com/vi/NS4f-BumfeQ/maxresdefault.jpg')
            )

            ->setWebpush(
                \NotificationChannels\Fcm\Resources\WebpushConfig::create()
                    ->setFcmOptions(WebpushFcmOptions::create()->setAnalyticsLabel('analytics_web')->setLink('https://google.com'))
            );
    }
haleyngonadi commented 1 year ago

Figured this out – FCMOptions just aren't available when the app is in the background.