January 12, 2022

Web Push Prompt Settings in JS

The process of implementing web push notifications is fairly straightforward: you will need to upload to your website a few lines of code to activate the feature.

Things to know before you start:

  • We strongly recommend using HTTPS, as browsers may block notifications from domains using the HTTP protocol. 
  • If you are not sure whether the website is on HTTP or on HTTPS, please ask your website administrator about it or contact our customer support.
  • Using raw device tokens for targeting specific devices is not the most reliable way, because FCM push tokens tend to change from time to time, and it’s hard to tell how often it occurs.

To Call Web Push Notification One-click Subscription Prompt on your website, you need to properly identify your user and fire an event on your web page.

IMPORTANT: Include those snippets on every page in your app, immediately before the closing </body> tag to initialize JS API and identify your user.

Connecting the library:

                <script type="text/javascript" src="//js.wooxy.com/js/v2/JS_SCRIPT.js" charset="UTF-8"></script>
            

Contact identificator:

                <script type="text/javascript">
    let contact = new _wooxyContact('{{identifier}}');
</script>
            

Step-by-step instructions:

                <script type="text/javascript">
    contact.ShowPushPrompt();
</script>
            
Parameters
ShowPushPrompt();
'required'
Call Web Push Notification One-click Subscription Prompt on any page or by user action.

After inserting the code on your site, make your first JS API call and check the integration status.

  • Navigate to the Integrations page (Menu -> Integrations).

  • Select the “JS code” section.

  • When the first successful JS API call is done, the installation will be validated, and the status will change to “Connected.”

  • If the website status is “Not connected”, it is necessary to check the applied settings once again.

  • If the website status is “Connected”, you will be able to create and update contacts, manage their data and subscription.

Connected site to JS