Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. function subscribeUser() {
  2. const applicationServerKey =
  3. urlB64ToUint8Array(applicationServerPublicKey);
  4. swRegistration.pushManager.subscribe({
  5. userVisibleOnly: true,
  6. applicationServerKey: applicationServerKey
  7. })
  8. .then(function(subscription) {
  9. console.log('User is subscribed.');
  10.  
  11. updateSubscriptionOnServer(subscription);
  12.  
  13. isSubscribed = true;
  14.  
  15. updateBtn();
  16. })
  17. .catch(function(err) {
  18. console.log('Failed to subscribe the user: ', err);
  19. updateBtn();
  20. });
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement