function updateMangeWebPushSubscriptionButton(buttonSelector) { var hideWhenSubscribed = false; var subscribeText = "Subscribe to Notifications"; var unsubscribeText = "Unsubscribe from Notifications";

getSubscriptionState().then(function(state) { var buttonText = !state.isPushEnabled || state.isOptedOut ? subscribeText : unsubscribeText;

var element = document.querySelector(buttonSelector); if (element === null) { return; }

element.removeEventListener('click', onManageWebPushSubscriptionButtonClicked); element.addEventListener('click', onManageWebPushSubscriptionButtonClicked); element.textContent = buttonText;

if (state.hideWhenSubscribed && state.isPushEnabled) { element.style.display = "none"; } else { element.style.display = ""; } }); }

How well do you really know your competitors?

Access the most comprehensive Company Profiles on the market, powered by GlobalData. Save hours of research. Gain competitive edge.

Company Profile – free sample

Thank you!

Your download email will arrive shortly

Not ready to buy yet? Download a free sample

We are confident about the unique quality of our Company Profiles. However, we want you to make the most beneficial decision for your business, so we offer a free sample that you can download by submitting the below form

By GlobalData
Visit our Privacy Policy for more information about our services, how we may use, process and share your personal data, including information of your rights in respect of your personal data and how you can unsubscribe from future marketing communications. Our services are intended for corporate subscribers and you warrant that the email address submitted is your corporate email address.

function getSubscriptionState() { return Promise.all([ OneSignal.isPushNotificationsEnabled(), OneSignal.isOptedOut() ]).then(function(result) { var isPushEnabled = result[0]; var isOptedOut = result[1];

return { isPushEnabled: isPushEnabled, isOptedOut: isOptedOut }; }); }

var OneSignal = OneSignal || []; var buttonSelector = "#my-notification-button";

/* This example assumes you've already initialized OneSignal */ OneSignal.push(function() { // If we're on an unsupported browser, do nothing if (!OneSignal.isPushNotificationsSupported()) { return; } updateMangeWebPushSubscriptionButton(buttonSelector); OneSignal.on("subscriptionChange", function(isSubscribed) { /* If the user's subscription state changes during the page's session, update the button text */ updateMangeWebPushSubscriptionButton(buttonSelector); }); });