Testing Dengage SDK on Localhost

Testing Dengage SDK on Localhost

In this article, we will guide you through the process to implement the SDK and service worker on your Localhost web for testing purposes.

Below are the steps to set up SDK and service worker on localhost.

1. Log in to the admin panel of your account and navigate to the settings >Application


2. Create a new web application and specify the localhost URL with the name of the directory.

 

3. After filling in all required information you will see the setup guide as below. Copy the script code and download the service worker.



4. Open the main index page of the website in the localhost directory and add the script code to the head section. Copy the downloaded file in the main directory of the localhost.



5. In your website .js file add the following code to register the service worker, define the name of the service worker and scope with the directory name.

  1. <script >
  2. if ('serviceWorker' in navigator) {
  3.   navigator.serviceWorker.register('./dengage-webpush-sw.js', {scope: './'})
  4.   .then((reg) => {
  5.     // registration worked
  6.     console.log('Registration succeeded. Scope is ' + reg.scope);
  7.   }).catch((error) => {
  8.     // registration failed
  9.     console.log('Registration failed with ' + error);
  10.   });
  11. }
  12. </script >
6. If the service worker registers successfully you will see this message in the console of your browser.




    • Related Articles

    • Postman API Testing

      Dengage allows you to generate sample API requests for all of our endpoints via  Postman . This reference article covers the Dengage Rest API Testing, what it is, how to set up and as well as how to edit and send requests. What is Postman? Postman is ...
    • Where can I see latest SDK version?

      The following link provides where the documentation is available for the SDK version. You can use the following links relevant to the technologies to see the required SDK version. IOS SDK Android SDK Huawei SDK React Native Cordova Flutter
    • Dengage Wordpress integration

      In this article, we will guide you through the process to implement the SDK and service worker on your WordPress website. Below are the steps to set up SDK and service worker on wordpress. 1. log in to the admin panel of your account and navigate to ...
    • Firebase SDK Setup

      Please follow this link to our Firebase SDK Setup: https://dev.dengage.com/mobile-sdk/android/firebase
    • How can I implement web SDK?

      Execute the following steps to implement web SDK: Create a web application on Admin Panel. Then, the system will provide a JavaScript code and service worker file. Add the JavaScript code to your website's source code (You must put it into <head> ...