Categories

Push notifications

1. Go to Firebase console -https://console.firebase.google.com. Click add project.

 Firebase homepage 

Fill in your project name and region.

Add new project 2. Now that our project is created we are ready to configure push notifications in GrandNode. Navigate to settings in your firebase console. 

Firebase console

Go to „cloud messaging” tab and copy Server key.

Server key example screenshot

Paste it into „Private Api Key” in push notifications configuration. To do that go to Admin Panel -> Configuration -> Settings -> Push notifications settings

Push notifications settings

Go back to firebase settings -> General tab and press „Add Firebase to your web app”.

Add to webpage screenshot one

Copy settings from config json into configuration. „apiKey” into „Public Api Key” etc. It should look like this:

 Filled configuration screenshot

JSON example of push notifications

Depending on your account „storageBucket” might be empty, but it seems to be optional so don’t worry about it. After pressing „Save” in our plugins’ configuration page everything is ready, but let me write few words about those keys and other settings.

 

„Private Api Key” shouldn’t be shown to anyone, as it’s the key that will allow you to send notifications.

 

„Public Api Key” and all other fields we just filled are public and it isn’t dangerous to show them to the world. They will be visible on your page and in some scripts, because firebase needs to know that this page is ready to receive notifications from you.

 

„Widget zone” field indicates on which page registration for push notifications(aka showing the „Allow notifications” popup) should occur. We advise to leave it to „home_page_top” to avoid performance issues, but feel free to test it on your own, for example „footer” will add script to each page that has footer in it etc.

 

„Allow guest to register for notifications” is pretty self-explanatory. Disable this setting if you wan’t only registered users to be able to subscribe to your notifications.

3. Everything is set and ready to go. With default settings after someone visists your homepage you should be able to see him in „Receivers” tab in plugin configuration.

 Receivers

If there is at least one customer that subscribed to your push notficiations you are ready to send them. Go to „Send” tab, fill in the form and press „Send message” to do that. Any erros will get logged into system log. Errors are inevitable, because there always will be some users with old browser cache or that are using Internet Explorer from ancient times. History of sent messages is in „Messages” tab.

[Disclaimer for developers] If you have purchased source codes, you are able to send push

notifications programatically, by calling SendPushNotification(…) form PushNotificationsService.

Few words about receiving notifications: 

Every browser is different, but usually there will be two scenarios – either customer is currently on your website or not.

-If he is, he must have page with registration script(so with the widget zone from settings) in it open. Clicking on notification will result in no action, even if „Click Url” in „Send” form was filled.

-If he isn’t on your store, he will receive push notification. Clicking on it will result in opening specified url(depending on you filling it earlier). If his browser isn’t open at the moment of sending notification he should receive it when he opens it(again – different browsers might give different results. When tested Chrome and Firefox opened old notifications even if PC was shut down at the moment of sending notification, Opera not).

back to top