I've been experimenting with the code from this demo link:
https://davidwalsh.name/demo/notifications-api.php
The demo mentioned above functions perfectly on Chrome, Firefox, and Edge browsers.
I utilized the demo to create an .aspx page by simply copying and pasting the source. I only inserted a <Form..> </Form>
to make it work in an .aspx page. After uploading to godaddy, it works flawlessly in Firefox and Edge, but encounters errors in Chrome.
Could anyone suggest any reasons why it might not work in Chrome when hosted on godaddy? Despite not being proficient in Javascript, I can't seem to identify any issues.
Would the absence of SSL on my site prevent notifications from functioning properly? Researching this topic has led me down irrelevant paths.
Thank you,
Update: My .aspx page performs well on localhost in Chrome (IIS Express), as well as in Firefox and Edge. The issue arises only upon deployment to godaddy. Chrome does not prompt for notification permissions when accessing the site on godaddy. Even manually adding the URL to the notification settings doesn't resolve the problem.
-=-=-
One more thing to add. It's difficult to find relevant information online due to similar keywords used in push notifications and web notifications. I'm focusing on web notifications, and came across this statement:
Also, web notification works with both non-SSL and SSL websites.
This contradicts my assumption...unless it's outdated.
Here is the essential code snippet that functions everywhere except where it's most crucial:
Show a Notification
<script type="text/javascript">
function showNotification() {
if(window.Notification) {
Notification.requestPermission(function(status) {
console.log('Status: ', status);
var n = new Notification('Title', { body: 'I am the body text!' });
});
}
else {
alert('Your browser doesn\'t support notifications.');
}
}
</script>