Closed sarozpradhan64 closed 11 months ago
Under the hood we use: https://github.com/kreait/laravel-firebase
You may want to look into their documentation to see how to configure for your needs.
For anyone else trying to get this to work, try this in your notification:
$notification_content = [
'title' => 'Notification Title',
'body' => 'Notification body',
'image' => 'URL to the icon for the notification' ,
];
return (new FcmMessage(notification: new FcmNotification(
...$notification_content
)))->custom([
'webpush' => [
'fcm_options' => [
'link' => route('welcome'),
]
]
]);
Then in your firebase service worker, add the following:
messaging.onBackgroundMessage((payload) => {
// Customize notification here
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
icon: payload.notification.image ?? "/icon-256x256.png",
click_action: payload.data.link,
};
self.registration.showNotification(notificationTitle, notificationOptions);
});
https://github.com/laravel-notification-channels/fcm#usage