Pushwoosh WebSDK Lite
Users subscribe to push notifications through the Pushwoosh endpoint (https://.chrome.pushwoosh.com/) in a separate window, so the SDK works for HTTP and with no need to add a ServiceWorker to your project.
1. Install the WebSDK Lite
1.1. Via html
1.2. Via npm
npm install web-push-notifications-lite --save
2. Integrate the WebSDK Lite
2.1. Via html
Add the following script to your website’s html:
where
- pw_application_code – the app code of your app in Pushwoosh,
- pw_autosubscribe – the parameter to enable automatic opening of the subscription window after the script is launched. To initialize the SDK manually, add the onload parameter to the script as follows:
2.2. Via npm
import {instance as pushwooshLite} from 'web-push-notifications-lite'; pushwooshLite.init('####-####', true);
Exports
- klass – a class of PushwooshLite;
- instance – the instance of the PushwooshLite class to use it as a singleton;
- LOCAL_STORAGE_ALLOW_NOTIFICATION_FLAG – a key to flag user interaction with the SDK in localStorage.
Public methods
- init(appCode: string, autosubscribe: boolean) – the method to initialize the SDK, where
- appCode – the app code of your app in Pushwoosh,
- autosubscribe – the parameter to enable automatic opening of the subscription window after the SDK is initialized;
- showSubscriptionWindow() – the method to open the subscription window.