Skip to content

Mobile SDK Reference

Registers a new device with your FlareLane project. When requestPermissionOnLaunch is set to true, the notification permission is requested as soon as the app launches.

/*
Params
- Context context
- String projectId
- boolean requestPermissionOnLaunch
*/
FlareLane.initWithContext(this, "INPUT_YOUR_PROJECT_ID", true)

Sets the SDK log level.

/*
Params
- int logLevel
- Log.VERBOSE
- Log.ERROR
*/
FlareLane.setLogLevel(Log.VERBOSE)

Managing notification subscriptions per device

Section titled “Managing notification subscriptions per device”

Checks whether the device is subscribed to notifications. Returns false if permission has not been granted.

/*
Android SDK >= 1.4.0
Params
- Context context
Return
- boolean isSubscribed
*/
FlareLane.isSubscribed(this)

Subscribes the device to notifications. If permission has not been granted, it first shows the permission prompt or directs the user to the system settings.

/*
Android SDK >= 1.4.0
Params
- Context context
- boolean fallbackToSettings - directs the user to the notification settings when the permission prompt cannot be shown
- @Nullable IsSubscribedHandler
*/
FlareLane.subscribe(this, true, FlareLane.IsSubscribedHandler {
// Do Something...
})

Unsubscribes the device from notifications.

/*
Android SDK >= 1.4.0
Params
- Context context
- @Nullable IsSubscribedHandler
*/
FlareLane.unsubscribe(this, FlareLane.IsSubscribedHandler {
// Do Something...
})

Typically, you set the User ID upon a successful sign-up or login to distinguish between registered users and guests.

/*
Params
- Context context
- @Nullable String userId
*/
// SET
FlareLane.setUserId(this, "USER_ID")
// REMOVE
FlareLane.setUserId(this, null)

Triggers an event. If the device has a User ID, the event is applied to the user; otherwise, it is applied to the single device.

/*
Params
- Context context
- String type
- @Nullable JSONObject data
*/
FlareLane.trackEvent(this, "test_event", null)
// OR
var tags = JSONObject()
tags.put("key", "value")
FlareLane.trackEvent(this, "test_event", tags)

Applies tags. If the device has a User ID, the tags are applied to the user; otherwise, they are applied to the single device.

/*
Params
- Context context
- JSONObject tags
*/
var tags = JSONObject()
tags.put("gender", "men")
tags.put("age", 24)
tags.put("removeTag", JSONObject.NULL) // remove
FlareLane.setTags(this, tags)
/*
Params
- Context context
*/
FlareLane.getDeviceId(this);

Registers a callback handler that runs when the user opens the app after clicking a notification.

/*
Params
- public interface setNotificationClickedHandler
- onClicked(Notification notification)
- Notification
- @NonNull String id
- @Nullable String title
- @NonNull String body
- @Nullable String url
- @Nullable String imageUrl
*/
FlareLane.setNotificationClickedHandler(NotificationClickedHandler { notification ->
// Do Something...
})

Registers a callback handler that runs when a notification is received while the app is in the foreground. You can also control whether the notification is displayed.

/*
SDK Version >= 1.5.0
Params
- public interface NotificationForegroundReceivedHandler
- onWillDisplay(NotificationReceivedEvent event);
- NotificationReceivedEvent
- Notification getNotification()
- void display()
*/
FlareLane.setNotificationForegroundReceivedHandler { event ->
Log.d("FlareLane", event.notification.toString())
// Call the function below to display the notification.
event.display()
}

Displays the highest-priority in-app message in a specific group that the current device is eligible to show.

/*
SDK Version >= 1.7.0
Params
- String group
*/
FlareLane.displayInApp("home")

Defines a custom handler to process custom actions triggered by in-app messages.

/*
SDK Version >= 1.7.0
Params
- public interface InAppMessageActionHandler
- onExecute(InAppMessage iam, String actionId)
*/
FlareLane.setInAppMessageActionHandler(object : InAppMessageActionHandler {
override fun onExecute(iam: InAppMessage, actionId: String) {
// Do Something...
}
})