LoginSignup
1
7

More than 1 year has passed since last update.

ユニバーサルリンク チェックポイント

Last updated at Posted at 2021-02-12

サーバ側

  • apple-app-site-associationファイル
    • ファイルの書き方が正しいか
      • ファイルに.jsonなど拡張子は何もつけない。
      • appIDsキーに関して、<チームID>.<バンドルID>という形式になっているか。
      • apps: []というキー・バリューについて、iOS13以降であれば消していい。iOS12以前もサポートするのであれば、残す必要がある。
      • appIDキーについて、iOS13以降はappIDsキーに変えることもできる。iOS12以前をサポートするならそのままにする。
      • pathsキーについて、iOS13以降はcomponentsキーに変えることもできる。iOS12以前をサポートするならそのままにする。

Supporting Universal Links in Your App

通常はS3などにファイルを置くことになると思われる。
https://dev.classmethod.jp/articles/universal-links/

apple-app-site-association(iOS13以上の例)
{
  "applinks": {
      "details": [
           {
             "appIDs": [ "ABCDE12345.com.example.app", "ABCDE12345.com.example.app2" ],
             "components": [
               {
                  "#": "no_universal_links",
                  "exclude": true,
                  "comment": "Matches any URL whose fragment equals no_universal_links and instructs the system not to open it as a universal link"
               },
               {
                  "/": "/buy/*",
                  "comment": "Matches any URL whose path starts with /buy/"
               },
               {
                  "/": "/help/website/*",
                  "exclude": true,
                  "comment": "Matches any URL whose path starts with /help/website/ and instructs the system not to open it as a universal link"
               },
               {
                  "/": "/help/*",
                  "?": { "articleNumber": "????" },
                  "comment": "Matches any URL whose path starts with /help/ and which has a query item with name 'articleNumber' and a value of exactly 4 characters"
               }
             ]
           }
       ]
   }
}

Support Universal Links

apple-app-site-association(iOS12以下もサポートする例)
{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "9JA89QQLNQ.com.apple.wwdc",
                "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
            },
            {
                "appID": "ABCD1234.com.apple.wwdc",
                "paths": [ "*" ]
            }
        ]
    }
}
  • content-typeapplication/json

  • ファイルの置き場が正しいか。

    • apple-app-site-associationをサーバの.well-knownディレクトリ の下に配置するようにしなければならない。ルートに直接おくことも以前は認められていたが、今はNG。
  • 優先度の高いアプリのバンドルIDを先に記載しているか。

The order of the dictionaries in the array determines the order the system follows when looking for a match, so you can specify an app to handle a particular part of your website. Because the system evaluates each path in the paths array in the order it is specified—and stops evaluating when a positive or negative match is found—you should specify high priority paths before low priority paths.

  • ユニバーサルリンクのURLと同じドメインのURLをSafariで開いていないか?

When a user is browsing your website in Safari and they tap a universal link to a URL in the same domain as the current webpage, iOS respects the user’s most likely intent and opens the link in Safari. If the user taps a universal link to a URL in a different domain, iOS opens the link in your app.

(訳)今Safariでウェブページを見ており、ユニバーサルリンクのURLをタップしたが、そのドメインが今見ているウェブページのドメインと同じ場合は、ユーザーの最も意図していそうな振る舞いをするため、そのユニバーサルリンクをSafariで開く。別のドメインのURLをタップした場合は、アプリを起動する。

その他:
Setting up iOS Universal Links

アプリ側

  • apple developerのサイトにて、アプリのBundle Identifierの項でCapabilitiesAssociated Domainsにチェックが入っているかどうか。
  • Xcode > Targets > Signing & Capabilities にapplinks:<ドメイン名>という形式でドメイン名を記載しているかどうか。
  • AppDelegatefunc application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Boolにてハンドリング処理を入れているかどうか。
    • userActivity.activityTypeNSUserActivityTypeBrowsingWeb かどうかのチェックを入れているか。
    • アプリ側に渡されるURLはuserActivity.webpageURL内に入っているが、それをハンドリングしているか。

デバッグ

Console.appからファイルがダウンロード開始されたかのログを見ることができる。また、iPhoneでsystem diagnosis ファイルを作成し、実際にダウンロードされたかの結果をPCで見ることもできる。https://www.youtube.com/watch?v=xxyEq_ySoO4

参考

Supporting Universal Links in Your App
Support Universal Links
What's new in Universal Links(2020)
What's New in Universal Links(2019)
FlutterアプリをFirebase HostingでDeepLink対応する

1
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
7