콘텐츠로 이동

Mobile SDK Reference

플레어레인 프로젝트에 기기를 새롭게 등록합니다. requestPermissionOnLaunch을 true로 설정 시 앱 실행과 동시에 알림 권한을 요청합니다.

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

SDK의 로그레벨을 설정합니다.

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

알림 구독 여부를 조회합니다. 권한이 없는 경우에도 false를 리턴합니다.

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

알림을 구독합니다. 권한이 없는 경우 먼저 권한 허용을 위한 팝업을 띄우거나 시스템 설정으로 이동시킵니다.

/*
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
- @Nullable IsSubscribedHandler
*/
FlareLane.unsubscribe(this, FlareLane.IsSubscribedHandler {
// Do Something...
})

일반적으로, 회원가입/로그인 성공 시 유저ID를 연동하여 회원과 비회원을 구분합니다.

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

이벤트를 트리거합니다. 기기의 유저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)

태그를 반영합니다. 기기의 유저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
*/
FlareLane.getDeviceId(this);

알림 클릭 후 앱 진입 시 실행할 콜백 핸들러를 등록합니다.

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

포그라운드 상태에서 알림 수신 시 실행할 콜백 핸들러를 등록합니다. 알림 노출 여부도 지정할 수 있습니다.

/*
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.7.0
Params
- String group
*/
FlareLane.displayInApp("home")

인앱메시지 커스텀 액션을 수행하는 경우 이를 처리할 핸들러를 직접 정의합니다.

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