The Custom Subscription Popup is configured with the subscribePopup parameter of the Web SDK init call, and it is shown or hidden through its module instance.
1. Enable manual triggering. Set manualToggle: true inside subscribePopup so the popup does not appear automatically on page load:
Pushwoosh.push(['init', {
applicationCode: 'XXXXX-XXXXX',
// ... other init options ...
subscribePopup: {
enable: true,
manualToggle: true,
text: 'Enable notifications to receive our latest updates and offers.',
confirmSubscriptionButtonText: 'Subscribe',
askLaterButtonText: 'Not now'
}
}]);
2. Show the popup on demand. The popup instance is exposed as Pushwoosh.moduleRegistry.subscribePopup and provides a toggle() method. The instance exists only after the subscribe-popup-ready event has fired, and it is not created at all if the user is already subscribed:
Pushwoosh.addEventHandler('subscribe-popup-ready', function () {
document.getElementById('mySubscribeButton').addEventListener('click', function () {
Pushwoosh.moduleRegistry.subscribePopup.toggle(true); // show
});
});
// toggle() - flips visibility
// toggle(true) - shows the popup
// toggle(false) - hides the popup
Note: Pushwoosh.subscribe() is a different method — it asks for the native browser permission directly and resolves with no value. It does not display the Custom Subscription Popup.
Re-subscription behaviour. Browsers cap how often the native permission prompt can appear, but the exact rule is not "twice, then permanent": in Chrome, once the prompt has been dismissed (closed without a choice) three times, Chrome temporarily stops showing it for that site; a single explicit Block click, on the other hand, blocks the origin until the user manually resets the permission in site settings. The Custom Subscription Popup has no such limit — it can be displayed as many times as needed until the user explicitly subscribes or blocks notifications. That makes it the right entry point for a "Subscribe" button, including cases such as an HTML5 canvas game where the native prompt must be triggered by a real interaction with a DOM element. When the user presses the popup's Subscribe button, the native permission prompt appears.
To track interactions, handle the subscribe-popup-show, subscribe-popup-accept and subscribe-popup-decline events. See the Custom Subscription Popup documentation for the full parameter list.
Comments
0 comments
Please sign in to leave a comment.