Contacts

How to make push notifications on a website for Chrome (part 1)

Since 2015, the technology began to rapidly gain popularity Push API from Chrome. Increasingly, when visiting various news (and not only news) sites, visitors are presented with the following system frame with the request:

Google Chrome system window asking for permission to deliver notifications from the site.

I sincerely consider this channel for delivering content (or attracting users, whatever you want to call it) one of the most promising. Perhaps even in a couple of years, these push notifications will be the same obligatory attribute of every self-respecting news site, which RSS and public pages on social networks are today.

However, today this technology is still quite young and there are few guidelines for its use not only on the domestic Internet, but also on the foreign one. For an example, you don’t have to go far — even Google itself, when it announced the Push API, released a meager press release that made me cry. And only now, after spending several hours rummaging through Google’s FAQs for developers, you can collect information to put together at least working scripts for sending Push notifications to your readers.

How to make such Push notifications for your website? There are two ways: use third-party services (they already exist and some of them are very good) or create your own solution. Since I am a supporter of minimal use of third-party services on the site, our path in the City was predetermined.

But, for the sake of fairness, it’s worth saying a few words about external solutions. I admit, I haven’t really studied this market (the reason is mentioned just above), but I can’t help but mention the OneSignal service, the most attractive feature of which is that their services are absolutely free - they make money by selling data about visitors to the client’s website. There is also a service called Jeapie, they have very competent marketing and, as a rule, good reviews. However, it is worth noting that at one time, from their services, Medusa — the platform was simply not ready for the number of push notifications that had to be sent for Medusa’s huge audience.

Implementation. Obtaining credentials from Google.

In the source data, a site written in Rails 3.2.8 and the task is to make a notification pusher for Chrome on it.

The first step is to transfer the site to HTTPS (secure hypertext protocol), that is, create an SSL certificate for your site. Without it, push notifications will not work (I haven’t tested it with regular http, but that’s what they say everywhere). I won’t write about what SSL is, what it’s used with, how to put a certificate on a server and connect it - the Internet is replete with such articles. I can only recommend StartSSL for these purposes. This is a good Certification Authority, which all browsers I know are friends with, with a deliberately simple registration and verification procedure (you only need to know minimal English) to receive an absolutely free entry-level SSL certificate, into which you can include five more (sic!) subdomains.

So, we have received the certificate and configured our Nginx or Apache accordingly. Now in the address bar of the browser, next to the address of our site, the cutest little padlock glows green, the inscription https://, and, if you don’t mind the money, also the name of the organization.

Did you like the article? Share it