# Mobile SDK Reference

## .initialize

Request the notification permission and register a subscribed device.

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  Params
  - launchOptions: [UIApplication.LaunchOptionsKey : Any]?
  - projectId: String
  - requestPermissionOnLaunch: Bool = true

*/

FlareLane.initWithLaunchOptions(launchOptions, projectId: "INPUT_YOUR_PROJECT_ID", true)
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  Params
  - launchOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> * _Nullable)
  - projectId:(NSString * _Nonnull)
  - requestPermissionOnLaunch:(Bool) = YES

*/

[FlareLane initWithLaunchOptions:launchOptions projectId:@"INPUT_YOUR_PROJECT_ID" requestPermissionOnLaunch: YES];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  Params
  - Context context
  - String projectId
  - boolean requestPermissionOnLaunch

*/

FlareLane.initWithContext(this, "INPUT_YOUR_PROJECT_ID", true)
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Params
  - Context context
  - String projectId
  - boolean requestPermissionOnLaunch

*/

FlareLane.initWithContext(this, "INPUT_YOUR_PROJECT_ID", true);
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Params
  - String projectId
  - bool? requestPermissionOnLaunch = true

*/

FlareLane.shared.initialize("INPUT_YOUR_PROJECT_ID", requestPermissionOnLaunch: true);
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  Params
  - projectId: string
  - requestPermissionOnLaunch: boolean = true
*/

FlareLane.initialize('INPUT_YOUR_PROJECT_ID', true);
```

{% endtab %}
{% endtabs %}

## .setLogLevel

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  Params
  - LogLevel level
    - .verbose
    - .error
*/

FlareLane.setLogLevel(level: .verbose)
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  Params
  - LogLevel level
    - LogLevelVerbose
    - LogLevelError
*/

[FlareLane setLogLevelWithLevel:LogLevelVerbose];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  Params
  - int logLevel
    - Log.VERBOSE
    - Log.ERROR
*/

FlareLane.setLogLevel(Log.VERBOSE)
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Params
  - int logLevel
    - Log.VERBOSE
    - Log.ERROR
*/

FlareLane.setLogLevel(Log.VERBOSE);
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Params
  - LogLevel logLevel
    - LogLevel.verbose
    - LogLevel.error
*/

FlareLane.shared.setLogLevel(LogLevel.verbose);
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  Params
  - logLevel: LogLevel
    - 'verbose'
    - 'error'
*/

FlareLane.setLogLevel('verbose');
```

{% endtab %}
{% endtabs %}

***

## Subscription

### .isSubscribed()

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  iOS SDK >= 1.4.0
  
  Params
  - completion: @escaping (Bool) -> Void
*/

FlareLane.isSubscribed { isSubscribed in
  // Do Something...
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  iOS SDK >= 1.4.0
  
  Params
  - (void (^)(_Bool)) completion
*/

[FlareLane isSubscribedWithCompletion: ^(BOOL isSubscribed) {
  // Do Something...
}];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  Android SDK >= 1.4.0

  Params
  - Context context
  Return
  - boolean isSubscribed
*/

FlareLane.isSubscribed(this)
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Android SDK >= 1.4.0
  
  Params
  - Context context
  Return
  - boolean isSubscribed
*/

FlareLane.isSubscribed(this);
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Flutter SDK >= 1.4.0
  
  Return
  - Future<bool> isSubscribed
  Return
  - boolean isSubscribed
*/

await FlareLane.shared.isSubscribed();
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  React Native SDK >= 1.4.0
  
  Params
  - callback: (isSubscribed: boolean) => void
*/

FlareLane.isSubscribed((isSubscribed) => {
  // Do Something...
});
```

{% endtab %}
{% endtabs %}

### .subscribe()

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  iOS SDK >= 1.4.0
  
  Params
  - fallbackToSettings: Bool - 알림 권한 띄울 수 없을 때 알림 설정으로 이동
  - completion: ((Bool) -> Void)?
*/

FlareLane.subscribe(fallbackToSettings: true) { isSubscribed in
  // Do Something...
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  iOS SDK >= 1.4.0
  
  Params
  - (BOOL) fallbackToSettings - 알림 권한 띄울 수 없을 때 알림 설정으로 이동
  - (void (^)(_Bool)) completion
*/

[FlareLane subscribeWithFallbackToSettings:YES completion:^(BOOL isSubscribed) {
  // Do Something...
}];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  Android SDK >= 1.4.0
  
  Params
  - Context context
  - boolean fallbackToSettings - 알림 권한 띄울 수 없을 때 알림 설정으로 이동
  - @Nullable IsSubscribedHandler
*/

FlareLane.subscribe(this, true, FlareLane.IsSubscribedHandler {
  // Do Something...
})
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Android SDK >= 1.4.0
  
  Params
  - Context context
  - boolean fallbackToSettings - 알림 권한 띄울 수 없을 때 알림 설정으로 이동
  - @Nullable IsSubscribedHandler
*/

FlareLane.subscribe(this, true, new FlareLane.IsSubscribedHandler() {
    @Override
    public void onSuccess(boolean isSubscribed) {
      // Do Something...
    }
});
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Flutter SDK >= 1.4.0
  
  Params
  - bool? fallbackToSettings - 알림 권한 띄울 수 없을 때 알림 설정으로 이동
  - void Function(bool)? callback
*/

await FlareLane.shared.subscribe(true, (isSubscribed) {
  // Do Something...
});
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  React Native SDK >= 1.4.0
  
  Params
    - fallbackToSettings: boolean - 알림 권한 띄울 수 없을 때 알림 설정으로 이동
    - callback?: (isSubscribed: boolean) => void
*/

FlareLane.subscribe(true, (isSubscribed) => {
  // Do Something...
});
```

{% endtab %}
{% endtabs %}

### .unsubscribe()

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  iOS SDK >= 1.4.0
  
  Params
  - completion: ((Bool) -> Void)? = nil
*/

FlareLane.unsubscribe() { isSubscribed in
  // Do Something...
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  iOS SDK >= 1.4.0
  
  Params
  - (void (^)(_Bool)) completion
*/

[FlareLane unsubscribeWithCompletion:^(BOOL isSubscribed) {
  // Do Something...
}];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  Android SDK >= 1.4.0
  
  Params
  - Context context
  - @Nullable IsSubscribedHandler
*/

FlareLane.unsubscribe(this, FlareLane.IsSubscribedHandler { 
  // Do Something...
})
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Android SDK >= 1.4.0
  
  Params
  - Context context
  - @Nullable IsSubscribedHandler
*/

FlareLane.unsubscribe(this, new FlareLane.IsSubscribedHandler() {
    @Override
    public void onSuccess(boolean isSubscribed) {
      // Do Something...
    }
});
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Flutter SDK >= 1.4.0
  
  Params
  - void Function(bool)? callback
*/

await FlareLane.shared.unsubscribe((isSubscribed) {
  // Do Something...
});
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  React Native SDK >= 1.4.0
  
  Params
  - callback?: (isSubscribed: boolean) => void
*/

FlareLane.unsubscribe((isSubscribed) => {
  // Do Something...
});
```

{% endtab %}
{% endtabs %}

***

## Data Management

### .setUserID

When logging in, specify the user ID.

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  Params
  - userId: String?
*/

// SET
FlareLane.setUserId(userId: "example@flarelane.com")
// REMOVE
FlareLane.setUserId(this, nil)
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  Params
  - userId:(NSString * _Nullable)
*/

// SET
[FlareLane setUserIdWithUserId: @"example@flarelane.com"];
// REMOVE
[FlareLane setUserIdWithUserId: nil];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  Params
  - Context context
  - @Nullable String userId
*/

// SET
FlareLane.setUserId(this, "example@flarelane.com")
// REMOVE
FlareLane.setUserId(this, null)
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Params
  - Context context
  - @Nullable String userId
*/

// SET
FlareLane.setUserId(this, "example@flarelane.com");
// REMOVE
FlareLane.setUserId(this, null);
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Params
  - String? userId
*/

// SET
FlareLane.shared.setUserId("example@flarelane.com");
// REMOVE
FlareLane.shared.setUserId(null);
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  Params
  - userId: string | null
*/

// SET
FlareLane.setUserId("example@flarelane.com");
// REMOVE
FlareLane.setUserId(null);
```

{% endtab %}
{% endtabs %}

### .trackEvent

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  Params
  - type: String
  - data: [String: Any]?
*/

FlareLane.trackEvent("test_event")
// OR
FlareLane.trackEvent("test_event", data: ["test":"value"])
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  Params
  - type: NSString
  - data: NSDictionary *Nullable
*/

[FlareLane trackEvent:@"test_event" data:nil];
// OR
[FlareLane trackEvent:@"test_event" data:@{ @"key": @"value" }];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  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)
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Params
  - Context context
  - String type
  - @Nullable JSONObject data
*/

FlareLane.trackEvent(this, "test_event", null)

// OR

JSONObject tags = new JSONObject();
tags.put("key", "value")

FlareLane.trackEvent(this, "test_event", tags)
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Params
  - type: String
  - data: Map<String, Object>?
*/

FlareLane.shared.trackEvent("test_event");
// OR
FlareLane.shared.trackEvent("test_event", {"key": "value"});
```

{% endtab %}

{% tab title="JS(RN)" %}

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

FlareLane.trackEvent('test_event');
// OR
FlareLane.trackEvent("test_event", {"key": "value"});
```

{% endtab %}
{% endtabs %}

### .setTags

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  Params
  - tags: [String : Any]
*/

FlareLane.setTags(tags: ["gender": "men", "age": 24])
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  Params
  - tags:(NSDictionary<NSString *,id> * _Nonnull)
*/

[FlareLane setTagsWithTags:@{@"gender": @"men", @"age": @24}];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  Params
  - Context context
  - JSONObject tags
*/

var tags = JSONObject()
tags.put("gender", "men")
tags.put("age", 24)

FlareLane.setTags(this, tags)
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Params
  - Context context
  - JSONObject tags
*/

try {
    JSONObject tags = new JSONObject();
    tags.put("gender", "men");
    tags.put("age", 24);
    
    FlareLane.setTags(this, tags);
} catch (JSONException e) {
    e.printStackTrace();
}
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Params
  - Map<String, Object> tags
*/

FlareLane.shared.setTags({
  "gender": "men",
  "age": 24
});
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  Params
  - tags: Record<string, any>
*/

FlareLane.setTags({ gender: 'men', age: 27 });
```

{% endtab %}
{% endtabs %}

### .getDeviceId

{% tabs %}
{% tab title="Swift" %}

```swift
FlareLane.getDeviceId()
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
[FlareLane getDeviceId];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  Params
  - Context context
*/

FlareLane.getDeviceId(this);
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Params
  - Context context
*/

FlareLane.getDeviceId(this);
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
await FlareLane.shared.getDeviceId())
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
await FlareLane.getDeviceId()
```

{% endtab %}
{% endtabs %}

***

## Notifications Handler

### .setNotificationClickedHandler

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

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  Params
  - callback: (FlareLaneNotification) -> Void
    - FlareLaneNotification
      - id: String
      - body: String
      - title: String?
      - url: String?
      - imageUrl: String?
*/

FlareLane.setNotificationClickedHandler() { notification in
  // Do Something...
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  Params
  - callback: (FlareLaneNotification) -> Void
    - FlareLaneNotification
      - id: String
      - body: String
      - title: String?
      - url: String?
      - imageUrl: String?
*/

[FlareLane setNotificationClickedHandlerWithCallback:^(FlareLaneNotification* _Nonnull notification) {
  // Do something..
}];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  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...
})
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  Params
  - public interface NotificationClickedHandler
    - onClicked(Notification notification)
      - Notification
        - @NonNull String id
        - @Nullable String title
        - @NonNull String body
        - @Nullable String url
        - @Nullable String imageUrl
*/

 FlareLane.setNotificationClickedHandler(new NotificationClickedHandler() {
    @Override
    public void onConverted(Notification notification) {
      // Do Something...
    }
});
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  Params
  - NotificationClickedHandler handler = void Function(FlareLaneNotification notification);
    - FlareLaneNotification
      - String id
      - String? title
      - String body
      - String? url
      - String? imageUrl
*/

FlareLane.shared.setNotificationClickedHandler((notification) {
  // Do Something...
});
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  Params
  - callback: (notification: Notification) => void
    - Notification
      - id: string;
      - title?: string;
      - body: string;
      - url?: string;
*/

FlareLane.setNotificationClickedHandler((notification) => {
  // Do Something...
});
```

{% endtab %}
{% endtabs %}

### .setNotificationForegroundReceivedHandler

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

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  SDK Version >= 1.5.0
  
  Params
  - callback: (FlareLaneNotificationReceivedEvent) -> Void
    - FlareLaneNotificationReceivedEvent
      - notification: FlareLaneNotification
      - display()
*/

FlareLane.setNotificationForegroundReceivedHandler { event in
  print(event.notification)

  // You can display or not
  event.display()
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  SDK Version >= 1.5.0
  
  Params
  - callback: (FlareLaneNotificationReceivedEvent) -> Void
    - FlareLaneNotificationReceivedEvent
      - notification: FlareLaneNotification
      - display()
*/

[FlareLane setNotificationForegroundReceivedHandlerWithCallback:^(FlareLaneNotificationReceivedEvent * _Nonnull event) {
  NSLog([event.notification description]);

  // You can display or not
  [event display];
}];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  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())
  
  // You can display or not
  event.display()
}
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  SDK Version >= 1.5.0
  
  Params
  - public interface NotificationForegroundReceivedHandler
    - onWillDisplay(NotificationReceivedEvent event);
      - NotificationReceivedEvent
        - Notification getNotification()
        - void display()
*/

FlareLane.setNotificationForegroundReceivedHandler((new NotificationForegroundReceivedHandler() {
  @Override
  public void onWillDisplay(NotificationReceivedEvent event) {
    Log.d("FlareLane", event.getNotification().toString());
    
    // You can display or not
    event.display();
  }
}));
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  SDK Version >= 1.5.0
  
  Params
  - NotificationForegroundReceivedHandler handler = void Function(FlareLaneNotificationReceivedEvent event);
    - FlareLaneNotificationReceivedEvent
      - FlareLaneNotification notification
      - display()
*/

FlareLane.shared.setNotificationForegroundReceivedHandler((event) {
  print(event.notification);

  // You can display or not
  event.display();
});

```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  SDK Version >= 1.5.0
  
  Params
  - callback: (event: NotificationReceivedEvent) => void
    - NotificationReceivedEvent
      - notification: Notification
      - display()
*/

FlareLane.setNotificationForegroundReceivedHandler((event) => {
  console.log(event.notification);
  
  // You can display or not
  event.display();
});
```

{% endtab %}
{% endtabs %}

***

## In-App Message

### .displayInApp

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

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  SDK Version >= 1.7.0
  
  Params
  - group: String
*/

FlareLane.displayInApp("home")
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  SDK Version >= 1.7.0
  
  Params
  - group: String
*/

[FlareLane displayInApp: @"home"];
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  SDK Version >= 1.7.0
  
  Params
  - String group
*/

FlareLane.displayInApp("home")
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  SDK Version >= 1.7.0
  
  Params
  - String group
*/

FlareLane.displayInApp("home");
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  SDK Version >= 1.7.0
  
  Params
  - String group
*/

FlareLane.shared.displayInApp("home");
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  SDK Version >= 1.7.0
  
  Params
  - group: string
*/

FlareLane.displayInApp("home");
```

{% endtab %}
{% endtabs %}

### .setInAppMessageActionHandler

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

{% tabs %}
{% tab title="Swift" %}

```swift
/*
  SDK Version >= 1.7.0
  
  Params
  - callback: (FlareLaneInAppMessage, actionId: String) -> Void
*/

FlareLane.setInAppMessageActionHandler { iam, actionId in
  // Do Something...
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
/*
  SDK Version >= 1.7.0
  
  Params
  - callback: (FlareLaneInAppMessage, actionId: String) -> Void
*/

FlareLane setInAppMessageActionHandlerWithCallback:^(FlareLaneInAppMessage * _Nonnull iam, NSString * _Nonnull actionId) {
  // Do Something...
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
/*
  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...
  }
})
```

{% endtab %}

{% tab title="Java" %}

```java
/*
  SDK Version >= 1.7.0
  
  Params
  - public interface InAppMessageActionHandler
    - onExecute(InAppMessage iam, String actionId)
*/

FlareLane.setInAppMessageActionHandler(new InAppMessageActionHandler() {
  @Override
  public void onExecute(@NonNull InAppMessage iam, @NonNull String actionId) {
    // Do Something...
  }
});
```

{% endtab %}

{% tab title="Dart(Flutter)" %}

```dart
/*
  SDK Version >= 1.7.0
  
  Params
  - void Function(InAppMessage iam, String actionId)
*/

FlareLane.shared.setInAppMessageActionHandler((iam, actionId) {
  // Do Something...
});
```

{% endtab %}

{% tab title="JS(RN)" %}

```javascript
/*
  SDK Version >= 1.7.0
  
  Params
  - (iam: InAppMessage, actionId: string) => void;
*/

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guide.flarelane.com/guide-for-developers/mobile-sdk-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
