To gain manual control over the Custom Subscription Popup's appearance and enable users to re-subscribe after previously opting out:
-
Enable Manual Triggering: When initializing the Pushwoosh Web SDK, set the
manualToggle: true
option within thecustomPopup.options
configuration. This prevents the popup from appearing automatically on page load.Pushwoosh.init({ // ... other essential init options like applicationCode ... customPopup: { options: { manualToggle: true // ... other custom popup display options ... } } });
-
Show the Popup on Demand: Call the
Pushwoosh.subscribe()
method when you want to display the popup (e.g., in response to a user clicking a "Subscribe" button on your website).// Example: Attach to a button click document.getElementById('mySubscribeButton').addEventListener('click', function() { Pushwoosh.subscribe() .then(function(subscriptionDetails) { if (subscriptionDetails.isSubscribed) { console.log('Successfully subscribed!'); } else { console.log('Subscription was not completed or permission was denied.'); } }) .catch(function(error) { console.error('Error during subscription:', error); }); });
-
Re-subscription Behavior: With this setup, the Custom Subscription Popup will appear when
Pushwoosh.subscribe()
is called. If the user clicks "Allow" (or your equivalent positive action button) on the custom popup, the native browser permission prompt will then be shown. Importantly, the custom popup will still be displayed on subsequent calls toPushwoosh.subscribe()
even if the user had previously denied permission at the browser level or unsubscribed. This gives users a clear way to opt back into notifications if they change their mind. This is particularly useful in scenarios like prompting from within a web game (e.g., HTML5 canvas), where direct calls to the native permission API might be restricted by browsers if not initiated by a direct user interaction on a standard HTML element. The custom popup serves as this initial user interaction.
Comments
0 comments
Please sign in to leave a comment.