dimanche 16 mai 2021

Adding Weblink to FCM Push Notification Web

I have implemented FCM push notification on Angular 8. I am using the below format to send notification to the client side.

   {
 "notification": {
 "title": "Hey There", 
 "body": "Welcome to Site",
 "web_link": "https://google.com"
 },
 "to" : "eJW_5V9f5PPK48Ta1vDS8V:APA91bETTwu2UYTzSwjlaXEjv-p4nl61S-xgZIL3hWn9s6HWUR4fghtxctA0nb4dwxkRTJ5EXveCTwDsq4EviuZrxkFQHHJtovR7LeaTfTsbpYtpOdidEWNroTKMfbwG3xV0gJBlUpe"  
}

notification is showing in the background but the link for the website is not opening. I tried different JSON formats but none of seeems to be working. The link is triggered when the site is opened by using an event. I need to trigger the link from the payload.

self.addEventListener('notificationclick', function(event) {
    event.notification.close();
    event.waitUntil(self.clients.openWindow(event.notification.data.url));
});



Aucun commentaire:

Enregistrer un commentaire