July 2018
Intermediate to advanced
354 pages
8h 51m
English
In the example code, if the subscription object does not exist, the subscribeUser function is invoked. The service worker registration object is passed as the only parameter:
registration.pushManager.getSubscription().then(function (subscription) { if(subscription === null){ subscribeUser(registration); } });
The pushManager subscribe method has a single parameter, an object with two properties, userVisibleOnly and applicationServerKey.
The subscribe function returns a promise that resolves after the user has granted permission to send notifications and the browser sends a request to the push service.
As part of the subscribe function work flow, the User Agent is required to prompt the user for permission. ...
Read now
Unlock full access