ディープリンクを支える

ドキュメント

ディープリンクのサポート

ディープリンクとは、ユーザーの携帯電話でアプリを開き、アプリのメインウィジェットだけでなく、特定のページやユーザーエクスペリエンスに直接ユーザーを送るリンクのことです。ディープリンクは通常、リターゲティングキャンペーンで使用され、すでに携帯電話にアプリを持っているが、しばらくアプリを使っていないユーザーを対象としています。SingularはSingular Linksを通してディープリンクをサポートしています。

シンギュラーリンクを有効にする

iOSとAndroidでSingular Linksを有効にするには、Singular Linksの前提条件をご覧ください。

Androidサポートの場合は、プロジェクトのMainActivity.javaファイルに以下のコードを追加してください:

Java Kotlin
import com.singular.flutter_sdk.SingularBridge;
import android.content.Intent;

@Override
protected void onNewIntent(@NonNull Intent intent) {
  super.onNewIntent(intent);
  SingularBridge.onNewIntent(intent);
}

iOSサポートの場合は、プロジェクトのAppDelegate.mに以下を追加します:

Objective-C Swift
// Top of AppDelegate.m


            
#import "SingularAppDelegate.h"

- (BOOL)application:(UIApplication *)application 
     didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
       [GeneratedPluginRegistrant registerWithRegistry:self];
       [SingularAppDelegate shared].launchOptions = launchOptions;
       return [super application:application 
         didFinishLaunchingWithOptions:launchOptions];
}

- (BOOL)application:(UIApplication *)application 
     continueUserActivity:(NSUserActivity *)userActivity 
     restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> 
       *restorableObjects))restorationHandler {
         [[SingularAppDelegate shared] continueUserActivity:userActivity 
           restorationHandler:restorationHandler];
     return [super application:application continueUserActivity:userActivity 
         restorationHandler:restorationHandler ];
}

- (BOOL)application:(UIApplication *)app 
     openURL:(NSURL *)url 
     options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
       [[SingularAppDelegate shared] handleOpenUrl:url options:options];
       return [super application:app openURL:url options: options];
}

Singularリンクの処理

Singularのハンドラーメカニズムを使用して、アプリが開かれるきっかけとなったトラッキングリンクの詳細を読み取ります。

例えば

SingularConfig config = new SingularConfig('<SDK KEY>', '<SDK SECRET>');

config.singularLinksHandler = (SingularLinkParams params) {
  String deeplink = params.deeplink;
  String passthrough = params.passthrough;
  bool isDeferred = params.isDeferred;
  // Add your code here to handle the deep link


};
          
Singular.init(config);