Gravitec SDK Installation for Chrome websites (desktop + mobile)

Requirements

W3C Web Push Notifications are currently only supported by Chrome 42+

HTTP and HTTPS

If some of your pages are served via HTTP instead of HTTPS, then you must follow our 8.3. 🇬🇧 Website SDK HTTP Installation instead.

We encourage you to migrate all your pages to HTTPS first and then continue using this guide.

1. Download the SDK

1.1 Download the latest version of Gravitec Chrome Web SDK after the registration of your site in the 1.3.2. 🇬🇧 Integration.

1.2 Copy push-worker.js and manifest.json from gravitec_sdk_ directory and paste it into the top-level directory (root folder) of your website.

2. Include Required Files

2.1 Link *https://cdn.gravitec.net/storage/APP_KEY/client.js* and manifest.json to each page of your website by adding some code between <head> and </head> tags. Update APP_KEY with your Gravitec AppId. Most likely, you will have to do it just once in the file, which helps to generate a layout of the site. The resulting HTML should look like this:

<head>
 <script src="<https://cdn.gravitec.net/storage/APP_KEY/client.js>" async></script>
</head>

Now user will see a window asking for permission to receive notifications from your site immediately after opening the page:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/51397fbb-60a7-4b2e-bf1f-3a191059a4e8/image-20230314-121251.png

3. Customize Gravitec (Optional)

3.1 Your custom button or event.

Call Gravitec.push(["init"]) from a javascript file that is included on every page. Create or use your button and update YOUR_CUSTOM_BUTTON_ID with your button id.

The user will see a window asking for permission to receive notifications from your site immediately after clicking on the button.

You can create your own logic and call registerPush() method.