You are viewing our old blog site. For latest posts, please visit us at the new space. Follow our publication there to stay updated with tech articles, tutorials, events & more.

Push Notification for Web

0.00 avg. rating (0% score) - 0 votes
What is Push Notification?
If I say, web is heading towards ‘PUSH based’ content serving rather than tradition ‘PULL based’, hope you agree or you may not. Let me clear you the difference b/w both by giving an example:-
Mr. X is working in an organization. He is well settled but fed-up with his job and now, looking for a change. He opens up any search engine and types his requirement. Search engine lists a number of job search portals but he is not aware of the right portal and thus wastes his time by going through each one of them. Here, did you notice one thing?? Search engine pulled you towards it to search upon your requirement and job portals as well. This is pull based content serving.
But in case of PUSH based content serving web is now smart and analyzing its user base, their behavior, their preferences and thus only serving the relevant content to them through their devices. This is basically called the ‘contextual content delivering’ which makes sense in today’s perspective where ‘time is everything’. Now job portals are well aware of Mr. X’s job preferences or requirements as he was a frequent user. Oh Yes!!. Now Mr. X gets a job alert notification on his device which is quite relevant to his preferences well.
Is Push Notification new to web?
When we used to talk about what features are missing on web than those in mobile native apps, Push Notification was always on Count but Chrome Browser implemented the solution of problem by introducing PUSH and NOTIFICATION APIs for the very first time from version 42 onwards.
Service Providers for Push notifications?
Google itself is a service provider for push notification and provides through Google Cloud Messaging (GCM) server. Apple Push Notification Server (APNS) is also a provider for push notifications.
PUSH notification has dependencies on other new technologies like web manifest and Service workers. We need to have basic idea of service worker and app manifest in order to proceed. Service worker is a script that runs in the background of your page in a separate thread even after your page is closed which handles the push event accordingly.
The procedure behind is, user has to get a registration id for push service from GCM end point and then it is stored in the database server through your web/app server. Now once your app server wants to send you push messages, it gets the registration ids from database and interacts with the GCM server (push service provider) to send the given push messages to the given registration ids.
We recently implemented the feature in one of our internal projects and came across few speed breakers:
  1. It does not work on Incognito mode.
Solution: do not open it in incognito mode because it prevents/blocks the pop-ups. During the initial setup only, it won’t popup for push notification subscription.
  1. It does not work on Chrome versions which are less than 42.
Solution: PUSH, NOTIFICATION APIs were introduced Chrome 42 onwards. So don’t even expect.
  1. Very first time, webpage asks you permission for push notification access. If you deny, it won’t show the popup again.
Solution: You need to manually go to chrome Content Settings > Notifications>Manage Exceptions>Remove it from deny list.
  1. Push Notification does not work on HTTP servers. It requires HTTPS server. There is a reason behind. It uses the technology Service Workers which are so powerful that any third party in b/w client and server can make misuse of it for any purpose.
References: –

One thought on “Push Notification for Web

Comments are closed.