Hi,
I am trying to display web notifications on a page and my code is working fine on desktop. It is asking for permission on page load, and if allowed, it displays the notification.
On mobile, it asks for permission on page load, but it does not display the notification after that. I have notifications enabled on mobile, otherwise it wouldn’t even ask the permission question.
I am trying to figure out whether my code is wrong or my device is not capable of showing such web notifications, unfortunately I don’t have any other device to test on right now.
My page:
https://www.tutsandtips.com/test.php
My Desktop: Windows 10 - Chrome 67
My Mobile: Samsung Galazy S3 Mini - Android 4.2.2 - Chrome 67
My code, as you can also see from View Source:
function notifications() {
var notification = new Notification('Test notification!');
}
if (!('Notification' in window)) {
alert('Notifications not supported.');
} else if (Notification.permission != 'granted') {
Notification.requestPermission(function(permission) {
if (permission == 'granted') {
notifications();
}
});
} else {
notifications();
}
Thanks for any ideas.