Skip to content

Web push notification SDK and service worker example

Notifications You must be signed in to change notification settings

hyipgate/web-push-notitication-sdk

Repository files navigation

Folders strcuture:

  • sources: Development source code
  • distributions: Complete source code (After build)

How to build:

npm run build

Deployment:

Public the files in distributions folder

How to integrate:

  • Add service-worker.js file into your website ({{path-to-this-file}})

    • serivce-worker.js file's content:
    importScripts('https://{{domain.com}}/service-worker.js');
  • Add this script to the head tag on all pages of your site that user can subscribe to.

    <script src="https://{{domain.com}}/webpush-sdk.js"></script>
    <script>
        window.webpushInit({
            service_worker: "{{path-to-this-file}}/service-worker.js",
            tags: {
                "source": "dantri.vn",
                "any_tag": "any_value"
            }
        })
    </script>

About

Web push notification SDK and service worker example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published