Links

Web Push SDK Reference

.initialize

Request the notification permission and register a subscribed device.
JavaScript
/*
Params
- options: InitializeOptions
- projectId
- serviceWorkerPath
*/
FlareLane.initialize({ projectId: "<PROJECT_ID>" });

.setLogLevel

JavaScript
/*
Params
- logLevel: 'none' | 'error' | 'verbose'(default)
*/
FlareLane.setLogLevel('verbose');

.trackEvent

JavaScript
/*
Params
- type: string
- data?: Record<string, string | number>
*/
FlareLane.trackEvent('test_event');
// OR
FlareLane.trackEvent('test_event', { "dataKey": "dataValue" });

.getIsSubscribed

JavaScript
/*
Params
- callback: (Boolean) => {}
*/
FlareLane.getIsSubscribed((isSubscribed) => {
// Do something...
console.log(isSubscribed);
});

.setIsSubscribed

Use if you want to manage subscriptions directly within your app.
JavaScript
/*
Params
- isSubscribed: Boolean
- callback: (Boolean) => {}
*/
const callback = (isSubscribed) => {
// Do something...
console.log(isSubscribed);
};
// SUBSCRIBE
FlareLane.setIsSubscribed(true, callback);
// UNSUBSCRIBE
FlareLane.setIsSubscribed(false, callback);

.setUserId

When logging in, specify the user ID.
JavaScript
/*
Params
- userId: string | null
*/
// SET
FlareLane.setUserId("[email protected]");
// REMOVE
FlareLane.setUserId(null);

.setTags

JavaScript
/*
Params
- tags: Record<string, string | number>
*/
// SET
FlareLane.setTags({ gender: "men", age: 24 });

.getDeviceId

JavaScript
/*
Params
- callback: (string | null) => {}
*/
FlareLane.getDeviceId((deviceId)) => {
// Do something...
console.log(deviceId);
});

.setConvertedHandler

Register a callback handler to be executed when the app enters after clicking on the notification.
JavaScript
/*
Params
- callback: (Notification) => {}
*/
FlareLane.setConvertedHandler((notification) => {
// Do something...
console.log(notification);
});