My site uses desktop notifications which have never worked on mobile devices but I've recently started to receive the following exception in Chrome Version 42.0.2311.108 on Android 4.4:
Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead. TypeError: Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.
My notification code is simple, after checking if the user has granted permissions I initialize a new Notification object as follows:
var notification = new Notification(messageOptions.title, { icon: messageOptions.icon });
How do I change this code to use the ServiceWorkerRegistration.showNotification, which comes up as undefined
, to support notifications in the mobile version of Chrome or if that isn't possible do a feature detection and prevent the exceptions from happening if this really isn't supported [yet].