带有“https”方案的 iOS 通用链接无法打开应用

问题描述

如果我使用自定义 URL 方案,我可以让它们正常打开,例如myapp://app.co/path/to/content 但当我使用 https://app.co/path/to/content 时,它只是在浏览器中打开。这是我在 Info.plist 中定义我的方案的地方:

    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>co.myapp.mobile</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>myapp</string>
            <string>co.myapp.mobile</string>
            <string>https</string>
            <string>http</string>
        </array>
    </dict>

如果我没记错的话,这是您唯一需要定义自定义方案的地方。如果没有,那将是我的问题。

附言通常我只使用 myapp:// 就可以了,但我使用的是 firebase 动态链接,它需要深层链接才能使用 http 或 https。那是一个 separate issue

解决方法

这是使用 applinks 修复的。确保您希望应用处理的所有链接(不以自定义方案开头)都在 applinks 下定义。