Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var unsubPropeller = function() {
  2. navigator.serviceWorker.getRegistration().then(x => x.unregister());
  3. updateUnsubLink();
  4. };
  5.  
  6.  
  7. if ((navigator.permissions !== undefined) && (navigator.permissions.query)) {
  8. navigator.permissions.query({name: 'notifications'}).then(function(permission) {
  9. permission.onchange = function() {
  10. if(permission.state === 'granted') {
  11. getConsent('Do you want to receive marketing and offers from our ad network via push notifications?');
  12. }
  13. };
  14. });
  15. }
  16.  
  17. var getConsent = function(message) {
  18. var result = confirm(message);
  19.  
  20. if(!result) {
  21. unsubPropeller();
  22. }
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement