Web SDK Reference

.initialize

Request the notification permission and register a subscribed device.

/*
Params
- options: InitializeOptions
  - projectId
  - serviceWorkerPath
*/

FlareLane.initialize({ projectId: "<PROJECT_ID>" });

.setLogLevel

/*
Params
- logLevel: 'none' | 'error' | 'verbose'(default)
*/

FlareLane.setLogLevel('verbose');

Subscription

.getIsSubscribed

/*
Params
- callback: (Boolean) => {}
*/

FlareLane.getIsSubscribed((isSubscribed) => {
    // Do something...
    console.log(isSubscribed);
});

.setIsSubscribed

Use if you want to manage subscriptions directly within your app.

/*
Params
- isSubscribed: Boolean
- callback: (Boolean) => {}
*/

const callback = (isSubscribed) => {
    // Do something...
    console.log(isSubscribed);
};

// SUBSCRIBE
FlareLane.setIsSubscribed(true, callback);
// UNSUBSCRIBE
FlareLane.setIsSubscribed(false, callback);

Data Management

.setUserId

When logging in, specify the user ID.

/*
Params
- userId: string | null
*/

// SET
FlareLane.setUserId("USER_ID");
// REMOVE
FlareLane.setUserId(null);

.trackEvent

/*
Params
- type: string
- data?: Record<string, string | number>
*/

FlareLane.trackEvent('test_event');
// OR
FlareLane.trackEvent('test_event', { "dataKey": "dataValue" });

.setTags

/*
Params
- tags: Record<string, string | number>
*/

// SET
FlareLane.setTags({ gender: "men", age: 24 });

.getDeviceId

/*
Params
- callback: (string | null) => {}
*/

FlareLane.getDeviceId((deviceId)) => {
  // Do something...
  console.log(deviceId);
});

Notifications Handler

.setConvertedHandler

Register a callback handler to be executed when the app enters after clicking on the notification.

/*
Params
- callback: (Notification) => {}
*/

FlareLane.setConvertedHandler((notification) => {
    // Do something...
    console.log(notification);
 });

In-App Message

.displayInApp

Displays the highest priority in-app message that can be shown in the group.

FlareLane.displayInApp("home");

.setInAppMessageActionHandler

Implement a handler for custom actions in the in-app message.

FlareLane.setInAppMessageActionHandler((iam, actionId) => {
  // Do Something...
});

Last updated