If you have implemented a custom subscription element (like a button or link) on your website, you can trigger the browser's native permission prompt by calling the Pushwoosh.subscribe() API method.
When a user clicks your custom element, execute the following JavaScript function:
Pushwoosh.subscribe();
Here is an example of a simple HTML button that triggers the subscription prompt when clicked:
<button onclick="Pushwoosh.subscribe()">Subscribe to Notifications</button>
Important:
* Ensure the Pushwoosh Web SDK is fully initialized on your page before this function is called.
* A common mistake is to use Pushwoosh.push(['subscribe']). This is incorrect and will result in an Error: Unknown command! in the browser console. Always use the direct Pushwoosh.subscribe() method to initiate the subscription process.
Comments
0 comments
Please sign in to leave a comment.