アプリがインストールされているユーザーがAdjustリンクをクリックすると、ダイレクトディープリンク機能により、アプリ内の特定のコンテンツへ直接遷移させることができます。
設定
iOSでは、アプリの実装に応じてダイレクトディープリンクを受け取るための方法が複数提供されています。
これらのメソッド内で、次のいずれかのメソッドを使用して、ディープリンクをAdjust SDKにパスします。
ディープリンクの処理と解析(推奨)
processDeeplink(_:completionHandler:)
メソッドを使用すると、以下の処理が実行されます。
- ディープリンククリックによるアトリビューションを記録する
- 短いブランドリンクを長いブランドリンクに解析する
- その他のリンクをそのまま渡す
その後、アプリは解決済みのリンクを解析し、適切な画面へ遷移させることができます。このメソッドは、Adjustの長いブランドリンクを含む全てのディープリンク(ユニバーサルリンク、アプリスキームディープリンクなど)に使用できます。
+ (void)processDeeplink:(nonnull NSURL *)deeplink
completionHandler:(void (^_Nonnull)(NSString * _Nonnull resolvedLink))completionHandler;
ディープリンクの処理(レガシー版)
Adjust SDKにはappWillOpen(_:)
メソッドがあり、ショートブランドリンクを使用していない場合でも、ディープリンククリックからのアトリビューションを記録することができます。
+ (void)appWillOpenUrl:(nonnull NSURL *)url;
ただし、processDeeplink(_:completionHandler:)
メソッドはこのレガシー版メソッドの機能を置き換えるものであるため、新しいこちらのメソッドを使用することを推奨します。
実装に関する重要な注意事項
ディープリンクの効果的な活用方法は、以下の通りです。
-
リンク処理の要件
-
アプリは、Adjustのブランドリンク (brandname.go.link
) とユニバーサルリンク (example.com
) を同一に処理する必要があります。アプリでドメインの許可リストを使用している場合は、Adjustブランドドメインが含まれていることを確認してください。たとえば、次の両方が同じ画面に移動するはずです。
- Adjustブランドリンク:
https://brandname.go.link/summer-clothes?promo=beach
- ユニバーサルリンク:
https://example.com/summer-clothes?promo=beach
-
アプリは、Adjustのブランドリンクとアプリスキームのディープリンクを同じように処理する必要があります。iOSでユニバーサルリンクがサポートされていない場合、Adjustはそれらを同等のアプリスキーム形式に変換します。たとえば、以下の2つのリンクは、どちらも同じ画面に遷移する必要があります。
- Adjustブランドリンク:
https://brandname.go.link/summer-clothes?promo=beach
- アプリスキームのディープリンク:
example://summer-clothes?promo=beach
-
アプリステータスに関する考慮事項
- アプリが「未起動」、「バックグラウンド」、または必要に応じて「フォアグラウンド」)のいずれの状態から起動された場合でも、リンクを正しく処理できるよう確認してください。
- ユーザーが認証されていない場合など、すぐに処理できない場合はディープリンクを保存し、アプリで移動する準備ができてから処理することを検討してください。
-
アプリ内ナビゲーション
- アプリが
UIApplication.open(_:options:completionHandler:)
またはSwiftUIの openURL
を呼び出してユニバーサルリンクを開こうとすると、iOSはそれらのリンクをアプリ内ではなくSafariで開いてしまいます。これらのメソッドをアプリ内ナビゲーションに使用する場合は、アプリスキームのディープリンクのみを渡す必要があります。または、アプリ内にユニバーサルリンクを配置し、独自のディープリンク処理ロジックでリンクを解析し、適切な画面へ遷移させることも可能です。
実装
アプリの構造と一致する実装方法を使用してください。
AppDelegateライフサイクルを使用するUIKitアプリ
AppDelegateを更新して、iOSダイレクトディープリンクメソッドを実装します。
// Receive universal link when app is installed
// and link opens app from "not running"
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingLink = userActivity.webpageURL
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
Adjust.processDeeplink(incomingLink) { resolvedLink in
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive app scheme deep link when app is installed
// and link opens app from "not running",
// background, or foreground state.
_ application: UIApplication,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
Adjust.processDeeplink(incomingLink) { resolvedLink in
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive universal link when app is installed
// and link opens app from "not running"
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
(void (^)(NSArray<id<uiuseractivityrestoring>> *_Nullable))
// Check if it's a web browsing activity
if (![userActivity.activityType
isEqualToString:NSUserActivityTypeBrowsingWeb])
// Check if there's a valid URL
NSURL *incomingLink = userActivity.webpageURL;
if (!incomingLink) return YES;
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
[Adjust processDeeplink:incomingLink
completionHandler:^(NSString *resolvedLink){
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive app scheme deep link when app is installed
// and link opens app from "not running",
// background, or foreground state.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)incomingLink
(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
[Adjust processDeeplink:incomingLink
completionHandler:^(NSString *resolvedLink){
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
SceneDelegateライフサイクルを使用するUIKitアプリ
SceneDelegateを更新して、iOSダイレクトディープリンクメソッドを実装します。
// Receive universal link or app scheme deep link when app is installed
// and link opens app from "not running" state.
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
// Receive incoming universal link
if let userActivity = connectionOptions.userActivities.first,
userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingLink = userActivity.webpageURL
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
Adjust.processDeeplink(incomingLink) { resolvedLink in
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive incoming app scheme deep link
guard let incomingLink = connectionOptions.urlContexts.first?.url else { return }
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
Adjust.processDeeplink(incomingLink) { resolvedLink in
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive universal link when app is installed
// and link opens app from background state.
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingLink = userActivity.webpageURL
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
Adjust.processDeeplink(incomingLink) { resolvedLink in
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive app scheme deep link when app is installed
// and link opens app from background
openURLContexts URLContexts: Set<uiopenurlcontext>
guard let incomingLink = URLContexts.first?.url else { return }
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
Adjust.processDeeplink(incomingLink) { resolvedLink in
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive universal link or app scheme deep link when app is installed
// and link opens app from "not running" state.
- (void)scene:(UIScene *)scene
willConnectToSession:(UISceneSession *)session
options:(UISceneConnectionOptions *)connectionOptions {
// Receive universal link
if (connectionOptions.userActivities.count > 0) {
NSUserActivity *userActivity =
connectionOptions.userActivities.allObjects.firstObject;
if ([userActivity.activityType
isEqualToString:NSUserActivityTypeBrowsingWeb] &&
userActivity.webpageURL) {
NSURL *incomingLink = userActivity.webpageURL;
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
[Adjust processDeeplink:incomingLink
completionHandler:^(NSString *resolvedLink){
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive app scheme deep link
if (connectionOptions.URLContexts.count == 0) return;
UIOpenURLContext *urlContext =
connectionOptions.URLContexts.allObjects.firstObject;
NSURL *incomingLink = urlContext.URL;
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
[Adjust processDeeplink:incomingLink
completionHandler:^(NSString *resolvedLink){
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive universal link when app is installed
// and link opens app from background state.
- (void)scene:(UIScene *)scene
continueUserActivity:(NSUserActivity *)userActivity {
// Check if it's a web browsing activity
if (![userActivity.activityType
isEqualToString:NSUserActivityTypeBrowsingWeb])
// Check if there's a valid URL
NSURL *incomingLink = userActivity.webpageURL;
if (!incomingLink) return;
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
[Adjust processDeeplink:incomingLink
completionHandler:^(NSString *resolvedLink){
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
// Receive app scheme deep link when app is installed
// and link opens app from background
- (void)scene:(UIScene *)scene
openURLContexts:(NSSet<uiopenurlcontext *> *)URLContexts {
// Check if we have any URL contexts
UIOpenURLContext *urlContext = URLContexts.allObjects.firstObject;
// Check if the URL is valid
NSURL *incomingLink = urlContext.URL;
if (!incomingLink) return;
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
[Adjust processDeeplink:incomingLink
completionHandler:^(NSString *resolvedLink){
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
AppDelegateライフサイクルを使用するSwiftUIアプリ
まだ作成していない場合は、プロジェクトのメインディレクトリに AppDelegate.swift
ファイルを作成し、以下の App.swift
ファイルの例のように、アプリケーションのメインファイルで参照してください。これは、アプリのライフサイクルイベントとAdjust SDKの実装を処理するために必要です。また、アプリがインストールされている状態でユニバーサルリンクやアプリスキームディープリンクを受け取れるように、onOpenURL
SwiftUIモディファイアも実装してください。
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
// Receive universal link or app scheme deep link when app is installed
// and link opens app from "not running",
// background, or foreground state.
.onOpenURL { incomingLink in
// Send deep link to Adjust's servers for attribution.
// If short branded link, receive long link.
// Otherwise, receive original link.
Adjust.processDeeplink(incomingLink) { resolvedLink in
// TO DO: Handle resolvedLink by parsing its components
// (example: path, query parameters) and
// navigating to the appropriate screen.
ScreenDelegateライフサイクルを使用するSwiftUIアプリ
AppDelegateライフサイクルを使用するSwiftUIアプリの手順に従ってください。onOpenURL
SwiftUIモデリングは、アプリがインストールされ、リンクがバックグラウンドまたはフォアグラウンドの状態からアプリを開くと、ユニバーサルリンクとアプリスキームのディープリンクを受信します。
さらに、SceneDelegateライフサイクルの手順に従って、UIKitアプリからscene(_:willConnectTo:options:)
メソッドを実装してください。このメソッドは、アプリがインストールされ、アプリが「未起動」の状態でリンクが開かれると、ユニバーサルリンクとアプリスキームのディープリンクを受け取ります。