I'm getting above error, while trying to open new link while clicking the web push notification.
My code is working fine, i mean i am able to open the link after clicking the notification but getting this error in console, also when i am putting any hardcoded url then its showing not error in console.
Any help would be appreciated.
This is my service-worker.js code
var link;
try{
self.addEventListener('push', function(e) {
var data = e.data.json();
var title = data.title;
var options = {
body: data.body
};
if(data.link){
link = data.link;
}
if(data.badge){
options.badge = data.badge;
}
if(data.icon){
options.icon = data.icon;
}
if(data.image){
options.image = data.image;
}
e.waitUntil(self.registration.showNotification(title, options));
});
}
catch(error){
console.log('error while sending push notification');
}
self.addEventListener('notificationclick', function(event) {
event.notification.close();
event.waitUntil(clients.openWindow(link));
});