Mobile SDK Reference
FlareLaneプロジェクトに新しいデバイスを登録します。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 // 任意の処理を実行します...}/* iOS SDK >= 1.4.0
Params - (void (^)(_Bool)) completion*/
[FlareLane isSubscribedWithCompletion: ^(BOOL isSubscribed) { // 任意の処理を実行します...}];/* 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) => { // 任意の処理を実行します...});.subscribe
Section titled “.subscribe”デバイスを通知に購読させます。許可が付与されていない場合は、まず許可リクエストのダイアログを表示するか、ユーザーをシステム設定へ誘導します。
/* Android SDK >= 1.4.0
Params - Context context - boolean fallbackToSettings - 許可リクエストのダイアログを表示できない場合に、ユーザーを通知設定へ誘導します - @Nullable IsSubscribedHandler*/
FlareLane.subscribe(this, true, FlareLane.IsSubscribedHandler { // 任意の処理を実行します...})/* 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) { // 任意の処理を実行します... }});/* iOS SDK >= 1.4.0
Params - fallbackToSettings: Bool - 許可リクエストのダイアログを表示できない場合に、ユーザーを通知設定へ誘導します - completion: ((Bool) -> Void)?*/
FlareLane.subscribe(fallbackToSettings: true) { isSubscribed in // 任意の処理を実行します...}/* iOS SDK >= 1.4.0
Params - (BOOL) fallbackToSettings - 許可リクエストのダイアログを表示できない場合に、ユーザーを通知設定へ誘導します - (void (^)(_Bool)) completion*/
[FlareLane subscribeWithFallbackToSettings:YES completion:^(BOOL isSubscribed) { // 任意の処理を実行します...}];/* Flutter SDK >= 1.4.0
Params - bool? fallbackToSettings - 許可リクエストのダイアログを表示できない場合に、ユーザーを通知設定へ誘導します - void Function(bool)? callback*/
await FlareLane.shared.subscribe(true, (isSubscribed) { // 任意の処理を実行します...});/* React Native SDK >= 1.4.0
Params - fallbackToSettings: boolean - 許可リクエストのダイアログを表示できない場合に、ユーザーを通知設定へ誘導します - callback?: (isSubscribed: boolean) => void*/
FlareLane.subscribe(true, (isSubscribed) => { // 任意の処理を実行します...});.unsubscribe
Section titled “.unsubscribe”デバイスの通知購読を解除します。
/* Android SDK >= 1.4.0
Params - Context context - @Nullable IsSubscribedHandler*/
FlareLane.unsubscribe(this, FlareLane.IsSubscribedHandler { // 任意の処理を実行します...})/* Android SDK >= 1.4.0
Params - Context context - @Nullable IsSubscribedHandler*/
FlareLane.unsubscribe(this, new FlareLane.IsSubscribedHandler() { @Override public void onSuccess(boolean isSubscribed) { // 任意の処理を実行します... }});/* iOS SDK >= 1.4.0
Params - completion: ((Bool) -> Void)? = nil*/
FlareLane.unsubscribe() { isSubscribed in // 任意の処理を実行します...}/* iOS SDK >= 1.4.0
Params - (void (^)(_Bool)) completion*/
[FlareLane unsubscribeWithCompletion:^(BOOL isSubscribed) { // 任意の処理を実行します...}];/* Flutter SDK >= 1.4.0
Params - void Function(bool)? callback*/
await FlareLane.shared.unsubscribe((isSubscribed) { // 任意の処理を実行します...});/* React Native SDK >= 1.4.0
Params - callback?: (isSubscribed: boolean) => void*/
FlareLane.unsubscribe((isSubscribed) => { // 任意の処理を実行します...});顧客データ連携
Section titled “顧客データ連携”.setUserId
Section titled “.setUserId”通常は、サインアップやログインの成功時にユーザーIDを設定し、登録済みのユーザーとゲストを区別します。
/* Params - Context context - @Nullable String userId*/
// 設定FlareLane.setUserId(this, "USER_ID")// 削除FlareLane.setUserId(this, null)/* Params - Context context - @Nullable String userId*/
// 設定FlareLane.setUserId(this, "USER_ID");// 削除FlareLane.setUserId(this, null);/* Params - userId: String?*/
// 設定FlareLane.setUserId(userId: "USER_ID")// 削除FlareLane.setUserId(this, nil)/* Params - userId:(NSString * _Nullable)*/
// 設定[FlareLane setUserIdWithUserId: @"USER_ID"];// 削除[FlareLane setUserIdWithUserId: nil];/* Params - String? userId*/
// 設定FlareLane.shared.setUserId("USER_ID");// 削除FlareLane.shared.setUserId(null);/* Params - userId: string | null*/
// 設定FlareLane.setUserId("USER_ID");// 削除FlareLane.setUserId(null);.trackEvent
Section titled “.trackEvent”イベントを発生させます。デバイスにユーザーIDが設定されている場合はそのユーザーにイベントが適用され、設定されていない場合は単一のデバイスに適用されます。
/* Params - Context context - String type - @Nullable JSONObject data*/
FlareLane.trackEvent(this, "test_event", null)
// または
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)
// または
JSONObject tags = new JSONObject();tags.put("key", "value")
FlareLane.trackEvent(this, "test_event", tags)/* Params - type: String - data: [String: Any]?*/
FlareLane.trackEvent("test_event")// またはFlareLane.trackEvent("test_event", data: ["test":"value"])/* Params - type: NSString - data: NSDictionary *Nullable*/
[FlareLane trackEvent:@"test_event" data:nil];// または[FlareLane trackEvent:@"test_event" data:@{ @"key": @"value" }];/* Params - type: String - data: Map<String, Object>?*/
FlareLane.shared.trackEvent("test_event");// またはFlareLane.shared.trackEvent("test_event", {"key": "value"});/* Params - type: string - data?: Record<string, string | number>*/
FlareLane.trackEvent('test_event');// またはFlareLane.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) // 削除
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); // 削除
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 -> // 任意の処理を実行します...})/* 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) { // 任意の処理を実行します... }});/* Params - callback: (FlareLaneNotification) -> Void - FlareLaneNotification - id: String - body: String - title: String? - url: String? - imageUrl: String?*/
FlareLane.setNotificationClickedHandler() { notification in // 任意の処理を実行します...}/* Params - callback: (FlareLaneNotification) -> Void - FlareLaneNotification - id: String - body: String - title: String? - url: String? - imageUrl: String?*/
[FlareLane setNotificationClickedHandlerWithCallback:^(FlareLaneNotification* _Nonnull notification) { // 任意の処理を実行します...}];/* Params - NotificationClickedHandler handler = void Function(FlareLaneNotification notification); - FlareLaneNotification - String id - String? title - String body - String? url - String? imageUrl*/
FlareLane.shared.setNotificationClickedHandler((notification) { // 任意の処理を実行します...});/* Params - callback: (notification: Notification) => void - Notification - id: string; - title?: string; - body: string; - url?: string;*/
FlareLane.setNotificationClickedHandler((notification) => { // 任意の処理を実行します...});.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();});アプリ内メッセージ
Section titled “アプリ内メッセージ”.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) { // 任意の処理を実行します... }})/* 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) { // 任意の処理を実行します... }});/* SDK Version >= 1.7.0
Params - callback: (FlareLaneInAppMessage, actionId: String) -> Void*/
FlareLane.setInAppMessageActionHandler { iam, actionId in // 任意の処理を実行します...}/* SDK Version >= 1.7.0
Params - callback: (FlareLaneInAppMessage, actionId: String) -> Void*/
FlareLane setInAppMessageActionHandlerWithCallback:^(FlareLaneInAppMessage * _Nonnull iam, NSString * _Nonnull actionId) { // 任意の処理を実行します...}/* SDK Version >= 1.7.0
Params - void Function(InAppMessage iam, String actionId)*/
FlareLane.shared.setInAppMessageActionHandler((iam, actionId) { // 任意の処理を実行します...});/* SDK Version >= 1.7.0
Params - (iam: InAppMessage, actionId: string) => void;*/
FlareLane.setInAppMessageActionHandler((iam, actionId) => { // 任意の処理を実行します...});