I have a simple scenario, to receive notification on mobile devices whenever it's generated from Server.
I know this facility is available in native iOS app and Android but I am trying to avoid native path. What I would like that:
I know there is a possibility of server side events/Web Sockets but can a web app emulate push notification features?
This means the browser can have no windows open, and you'll still receive the push message in your service worker, because the browser in running in the background. The only time a push won't be received is when the browser is completely closed, i.e. not running at all (no marking).
The web push channel is already supported by Android mobile devices, and it's in the works for iOS devices. Some browsers that currently support mobile push notifications include Chrome and Firefox on OS, Windows, OS X, Safari on OS X, and more.
The basics of push notifications A push notification is delivered instantly to a mobile device, regardless of whether the device is locked or unlocked. The push notification is delivered even if the user is in a different app or away from the app sending the push notification.
Apple does not offer a way to handle a notification that arrives when your app is closed (i.e. when the user has fully quit the application or the OS had decided to kill it while it is in the background). If this happens, the only way to handle the notification is to wait until it is opened by the user.
You can do this without a hybrid app, native app, or requiring users to install Pushover. It is possible to build a "progressive web app" that can send push notifications even after the page has been closed.
These work today in Chrome for Android (and other browsers seem to be implementing support), but there is no support on iOS.
Check out this demo, and this guide explains how to do it: https://developers.google.com/web/fundamentals/engage-and-retain/push-notifications/
as mentioned in Can a Webbased app have push notification? you might try Pushover: Simple Mobile Notifications for Android and iOS.
Able to receive notification even if browser is closed.
You cannot use WebSockets for this. You must use the more recent Push API. Currently it is supported by all major browsers, except Safari on iOS.
However adding support for the Push API from scratch is a lot of work: I suggest to use a third party service like Pushpad (I am the founder).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With