The built-in subscription prompt widget hides itself as soon as the user clicks anywhere outside it. That behaviour is hardcoded in the widget — there is no initialization option to disable it.
To get a dialog that stays open until the user makes a choice, do not enable the built-in widget: render your own UI and trigger the subscription yourself.
How to implement
- Initialize the SDK without the prompt/popup widgets — simply leave
subscribePopupandsubscribeWidgetout of yourinitparameters (or setenable: false), and do not import/runPWSubscribePopupWidgetorPWSubscriptionPromptWidget. - Build your own modal with your own HTML/CSS/JS, so you fully control when it closes.
- When the user clicks your “Allow” button, call the SDK’s
subscribe()method — this shows the native browser permission prompt and registers the subscriber.
const pushwoosh = new Pushwoosh();
pushwoosh.push(['init', {
applicationCode: 'XXXXX-XXXXX',
serviceWorkerUrl: '/service-worker.js'
// no subscribePopup / subscribeWidget -> no auto-closing widget
}]);
// call from your own "Allow" button handler:
myAllowButton.addEventListener('click', () => {
pushwoosh.subscribe();
});Note: Pushwoosh.push(['subscribe']) is not a valid command and will throw Unknown command! — use the subscribe() method on the Pushwoosh instance. Init parameters for the standard widgets are subscribePopup and subscribeWidget; there is no customPopup parameter.
See the documentation on Custom subscription popup for the available styling options.
Comments
0 comments
Please sign in to leave a comment.