Mobile SDK Reference
플레어레인 프로젝트에 기기를 새롭게 등록합니다. requestPermissionOnLaunch을 true로 설정 시 앱 실행과 동시에 알림 권한을 요청합니다.
/* Params - Context context - String projectId - boolean requestPermissionOnLaunch*/
FlareLane.initWithContext(this, "INPUT_YOUR_PROJECT_ID", true)/* Params - Context context - String projectId - boolean requestPermissionOnLaunch*/
FlareLane.initWithContext(this, "INPUT_YOUR_PROJECT_ID", true);/* Params - launchOptions: [UIApplication.LaunchOptionsKey : Any]? - projectId: String - requestPermissionOnLaunch: Bool = true*/
FlareLane.initWithLaunchOptions(launchOptions, projectId: "INPUT_YOUR_PROJECT_ID", true)/* Params - launchOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> * _Nullable) - projectId:(NSString * _Nonnull) - requestPermissionOnLaunch:(Bool) = YES*/
[FlareLane initWithLaunchOptions:launchOptions projectId:@"INPUT_YOUR_PROJECT_ID" requestPermissionOnLaunch: YES];/* Params - String projectId - bool? requestPermissionOnLaunch = true*/
FlareLane.shared.initialize("INPUT_YOUR_PROJECT_ID", requestPermissionOnLaunch: true);/* Params - projectId: string - requestPermissionOnLaunch: boolean = true
*/
FlareLane.initialize('INPUT_YOUR_PROJECT_ID', true);.setLogLevel
Section titled “.setLogLevel”SDK의 로그레벨을 설정합니다.
/* Params - int logLevel - Log.VERBOSE - Log.ERROR*/
FlareLane.setLogLevel(Log.VERBOSE)/* Params - int logLevel - Log.VERBOSE - Log.ERROR*/
FlareLane.setLogLevel(Log.VERBOSE);/* Params - LogLevel level - .verbose - .error*/
FlareLane.setLogLevel(level: .verbose)/* Params - LogLevel level - LogLevelVerbose - LogLevelError*/
[FlareLane setLogLevelWithLevel:LogLevelVerbose];/* Params - LogLevel logLevel - LogLevel.verbose - LogLevel.error*/
FlareLane.shared.setLogLevel(LogLevel.verbose);/* Params - logLevel: LogLevel - 'verbose' - 'error'*/
FlareLane.setLogLevel('verbose');기기별 알림 구독 처리
Section titled “기기별 알림 구독 처리”.isSubscribed
Section titled “.isSubscribed”알림 구독 여부를 조회합니다. 권한이 없는 경우에도 false를 리턴합니다.
/* Android SDK >= 1.4.0
Params - Context context Return - boolean isSubscribed*/
FlareLane.isSubscribed(this)/* Android SDK >= 1.4.0
Params - Context context Return - boolean isSubscribed*/
FlareLane.isSubscribed(this);/* iOS SDK >= 1.4.0
Params - completion: @escaping (Bool) -> Void*/
FlareLane.isSubscribed { isSubscribed in // Do Something...}/* iOS SDK >= 1.4.0
Params - (void (^)(_Bool)) completion*/
[FlareLane isSubscribedWithCompletion: ^(BOOL isSubscribed) { // Do Something...}];/* Flutter SDK >= 1.4.0
Return - Future<bool> isSubscribed Return - boolean isSubscribed*/
await FlareLane.shared.isSubscribed();/* React Native SDK >= 1.4.0
Params - callback: (isSubscribed: boolean) => void*/
FlareLane.isSubscribed((isSubscribed) => { // Do Something...});.subscribe
Section titled “.subscribe”알림을 구독합니다. 권한이 없는 경우 먼저 권한 허용을 위한 팝업을 띄우거나 시스템 설정으로 이동시킵니다.
/* Android SDK >= 1.4.0
Params - Context context - boolean fallbackToSettings - 알림 권한 띄울 수 없을 때 알림 설정으로 이동 - @Nullable IsSubscribedHandler*/
FlareLane.subscribe(this, true, FlareLane.IsSubscribedHandler { // Do Something...})/* 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... }});/* iOS SDK >= 1.4.0
Params - fallbackToSettings: Bool - 알림 권한 띄울 수 없을 때 알림 설정으로 이동 - completion: ((Bool) -> Void)?*/
FlareLane.subscribe(fallbackToSettings: true) { isSubscribed in // Do Something...}/* iOS SDK >= 1.4.0
Params - (BOOL) fallbackToSettings - 알림 권한 띄울 수 없을 때 알림 설정으로 이동 - (void (^)(_Bool)) completion*/
[FlareLane subscribeWithFallbackToSettings:YES completion:^(BOOL isSubscribed) { // Do Something...}];/* Flutter SDK >= 1.4.0
Params - bool? fallbackToSettings - 알림 권한 띄울 수 없을 때 알림 설정으로 이동 - void Function(bool)? callback*/
await FlareLane.shared.subscribe(true, (isSubscribed) { // Do Something...});/* React Native SDK >= 1.4.0
Params - fallbackToSettings: boolean - 알림 권한 띄울 수 없을 때 알림 설정으로 이동 - callback?: (isSubscribed: boolean) => void*/
FlareLane.subscribe(true, (isSubscribed) => { // Do Something...});.unsubscribe
Section titled “.unsubscribe”알림을 미구독합니다.
/* Android SDK >= 1.4.0
Params - Context context - @Nullable IsSubscribedHandler*/
FlareLane.unsubscribe(this, FlareLane.IsSubscribedHandler { // Do Something...})/* Android SDK >= 1.4.0
Params - Context context - @Nullable IsSubscribedHandler*/
FlareLane.unsubscribe(this, new FlareLane.IsSubscribedHandler() { @Override public void onSuccess(boolean isSubscribed) { // Do Something... }});/* iOS SDK >= 1.4.0
Params - completion: ((Bool) -> Void)? = nil*/
FlareLane.unsubscribe() { isSubscribed in // Do Something...}/* iOS SDK >= 1.4.0
Params - (void (^)(_Bool)) completion*/
[FlareLane unsubscribeWithCompletion:^(BOOL isSubscribed) { // Do Something...}];/* Flutter SDK >= 1.4.0
Params - void Function(bool)? callback*/
await FlareLane.shared.unsubscribe((isSubscribed) { // Do Something...});/* React Native SDK >= 1.4.0
Params - callback?: (isSubscribed: boolean) => void*/
FlareLane.unsubscribe((isSubscribed) => { // Do Something...});고객 데이터 연동
Section titled “고객 데이터 연동”.setUserId
Section titled “.setUserId”일반적으로, 회원가입/로그인 성공 시 유저ID를 연동하여 회원과 비회원을 구분합니다.
/* Params - Context context - @Nullable String userId*/
// SETFlareLane.setUserId(this, "USER_ID")// REMOVEFlareLane.setUserId(this, null)/* Params - Context context - @Nullable String userId*/
// SETFlareLane.setUserId(this, "USER_ID");// REMOVEFlareLane.setUserId(this, null);/* Params - userId: String?*/
// SETFlareLane.setUserId(userId: "USER_ID")// REMOVEFlareLane.setUserId(this, nil)/* Params - userId:(NSString * _Nullable)*/
// SET[FlareLane setUserIdWithUserId: @"USER_ID"];// REMOVE[FlareLane setUserIdWithUserId: nil];/* Params - String? userId*/
// SETFlareLane.shared.setUserId("USER_ID");// REMOVEFlareLane.shared.setUserId(null);/* Params - userId: string | null*/
// SETFlareLane.setUserId("USER_ID");// REMOVEFlareLane.setUserId(null);.trackEvent
Section titled “.trackEvent”이벤트를 트리거합니다. 기기의 유저ID가 존재하는 경우 유저 대상으로, 그 외에는 단일 기기 대상으로 반영됩니다.
/* 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)/* 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)/* Params - type: String - data: [String: Any]?*/
FlareLane.trackEvent("test_event")// ORFlareLane.trackEvent("test_event", data: ["test":"value"])/* Params - type: NSString - data: NSDictionary *Nullable*/
[FlareLane trackEvent:@"test_event" data:nil];// OR[FlareLane trackEvent:@"test_event" data:@{ @"key": @"value" }];/* Params - type: String - data: Map<String, Object>?*/
FlareLane.shared.trackEvent("test_event");// ORFlareLane.shared.trackEvent("test_event", {"key": "value"});/* Params - type: string - data?: Record<string, string | number>*/
FlareLane.trackEvent('test_event');// ORFlareLane.trackEvent("test_event", {"key": "value"});.setTags
Section titled “.setTags”태그를 반영합니다. 기기의 유저ID가 존재하는 경우 유저 대상으로, 그 외에는 단일 기기 대상으로 반영됩니다.
/* 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 - JSONObject tags*/
JSONObject tags = new JSONObject();tags.put("gender", "men");tags.put("age", 24);tags.put("removeTag", JSONObject.NULL); // remove
FlareLane.setTags(this, tags);/* Params - tags: [String : Any]*/
FlareLane.setTags(tags: ["gender": "men", "age": 24])/* Params - tags:(NSDictionary<NSString *,id> * _Nonnull)*/
[FlareLane setTagsWithTags:@{@"gender": @"men", @"age": @24}];/* Params - Map<String, Object> tags*/
FlareLane.shared.setTags({ "gender": "men", "age": 24});/* Params - tags: Record<string, any>*/
FlareLane.setTags({ gender: 'men', age: 27 });.getDeviceId
Section titled “.getDeviceId”/* Params - Context context*/
FlareLane.getDeviceId(this);/* Params - Context context*/
FlareLane.getDeviceId(this);FlareLane.getDeviceId()[FlareLane getDeviceId];await FlareLane.shared.getDeviceId())await FlareLane.getDeviceId()알림 핸들러
Section titled “알림 핸들러”.setNotificationClickedHandler
Section titled “.setNotificationClickedHandler”알림 클릭 후 앱 진입 시 실행할 콜백 핸들러를 등록합니다.
/* 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...})/* 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 onClicked(Notification notification) { // Do Something... }});/* Params - callback: (FlareLaneNotification) -> Void - FlareLaneNotification - id: String - body: String - title: String? - url: String? - imageUrl: String?*/
FlareLane.setNotificationClickedHandler() { notification in // Do Something...}/* Params - callback: (FlareLaneNotification) -> Void - FlareLaneNotification - id: String - body: String - title: String? - url: String? - imageUrl: String?*/
[FlareLane setNotificationClickedHandlerWithCallback:^(FlareLaneNotification* _Nonnull notification) { // Do something..}];/* Params - NotificationClickedHandler handler = void Function(FlareLaneNotification notification); - FlareLaneNotification - String id - String? title - String body - String? url - String? imageUrl*/
FlareLane.shared.setNotificationClickedHandler((notification) { // Do Something...});/* Params - callback: (notification: Notification) => void - Notification - id: string; - title?: string; - body: string; - url?: string;*/
FlareLane.setNotificationClickedHandler((notification) => { // Do Something...});.setNotificationForegroundReceivedHandler
Section titled “.setNotificationForegroundReceivedHandler”포그라운드 상태에서 알림 수신 시 실행할 콜백 핸들러를 등록합니다. 알림 노출 여부도 지정할 수 있습니다.
/* 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())
// 알림 노출을 하시려면 아래 함수를 실행하세요. event.display()}/* 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());
// 알림 노출을 하시려면 아래 함수를 실행하세요. event.display(); }}));/* SDK Version >= 1.5.0
Params - callback: (FlareLaneNotificationReceivedEvent) -> Void - FlareLaneNotificationReceivedEvent - notification: FlareLaneNotification - display()*/
FlareLane.setNotificationForegroundReceivedHandler { event in print(event.notification)
// 알림 노출을 하시려면 아래 함수를 실행하세요. event.display()}/* SDK Version >= 1.5.0
Params - callback: (FlareLaneNotificationReceivedEvent) -> Void - FlareLaneNotificationReceivedEvent - notification: FlareLaneNotification - display()*/
[FlareLane setNotificationForegroundReceivedHandlerWithCallback:^(FlareLaneNotificationReceivedEvent * _Nonnull event) { NSLog([event.notification description]);
// 알림 노출을 하시려면 아래 함수를 실행하세요. [event display];}];/* SDK Version >= 1.5.0
Params - NotificationForegroundReceivedHandler handler = void Function(FlareLaneNotificationReceivedEvent event); - FlareLaneNotificationReceivedEvent - FlareLaneNotification notification - display()*/
FlareLane.shared.setNotificationForegroundReceivedHandler((event) { print(event.notification);
// 알림 노출을 하시려면 아래 함수를 실행하세요. event.display();});/* SDK Version >= 1.5.0
Params - callback: (event: NotificationReceivedEvent) => void - NotificationReceivedEvent - notification: Notification - display()*/
FlareLane.setNotificationForegroundReceivedHandler((event) => { console.log(event.notification);
// 알림 노출을 하시려면 아래 함수를 실행하세요. event.display();});.displayInApp
Section titled “.displayInApp”현재 기기가 보여줄 수 있는 특정 그룹의 가장 우선순위 높은 인앱메시지를 노출합니다.
/* SDK Version >= 1.7.0
Params - String group*/
FlareLane.displayInApp("home")/* SDK Version >= 1.7.0
Params - String group*/
FlareLane.displayInApp("home");/* SDK Version >= 1.7.0
Params - group: String*/
FlareLane.displayInApp("home")/* SDK Version >= 1.7.0
Params - group: String*/
[FlareLane displayInApp: @"home"];/* SDK Version >= 1.7.0
Params - String group*/
FlareLane.shared.displayInApp("home");/* SDK Version >= 1.7.0
Params - group: string*/
FlareLane.displayInApp("view_product", { "product_id": 12345, "category": "food" });.setInAppMessageActionHandler
Section titled “.setInAppMessageActionHandler”인앱메시지 커스텀 액션을 수행하는 경우 이를 처리할 핸들러를 직접 정의합니다.
/* 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... }})/* 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... }});/* SDK Version >= 1.7.0
Params - callback: (FlareLaneInAppMessage, actionId: String) -> Void*/
FlareLane.setInAppMessageActionHandler { iam, actionId in // Do Something...}/* SDK Version >= 1.7.0
Params - callback: (FlareLaneInAppMessage, actionId: String) -> Void*/
FlareLane setInAppMessageActionHandlerWithCallback:^(FlareLaneInAppMessage * _Nonnull iam, NSString * _Nonnull actionId) { // Do Something...}/* SDK Version >= 1.7.0
Params - void Function(InAppMessage iam, String actionId)*/
FlareLane.shared.setInAppMessageActionHandler((iam, actionId) { // Do Something...});/* SDK Version >= 1.7.0
Params - (iam: InAppMessage, actionId: string) => void;*/
FlareLane.setInAppMessageActionHandler((iam, actionId) => { // Do Something...});