To prompt for the push subscription from your own custom page, call the Pushwoosh.subscribe() method on it.
This method requests the user's permission for push notifications. If the user is already subscribed, the method stops executing.
If the user has not subscribed yet:
- Permission for push notifications is requested.
- If the user allows notifications, the
onSubscribeevent is triggered.
By default, Pushwoosh.subscribe() is executed automatically when autoSubscribe: true is set during SDK initialization. Call it manually if you initialized the SDK with autoSubscribe: false:
<button onclick="Pushwoosh.subscribe()">Subscribe</button>
<script>
Pushwoosh.push(['onSubscribe', function(api) {
console.log('User successfully subscribed');
}]);
</script>
If the default Pushwoosh subscription prompt still appears next to your custom one, disable it in the init block with subscribePopup: { enable: false }.
See the Web Push SDK 3.0 integration guide for more information.
Comments
0 comments
Please sign in to leave a comment.