xcode ios:通用链接不适用于 iOS 10

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42469232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:48:29  来源:igfitidea点击:

ios: Universal links not working on iOS 10

iosxcodedeep-linkingios-universal-links

提问by meteors

I'm trying to integrate universal links in my iOS app. So whenever someone taps on <myapp>.herokuapp.com/contentgets redirected directly to app. I followed thisguide for setup. I did the following setup but cannot get it working. I also checked other threads on stackoverflow but none of them solved the issue.

我正在尝试在我的 iOS 应用程序中集成通用链接。因此,每当有人点击时,<myapp>.herokuapp.com/content都会直接重定向到应用程序。我按照指南进行设置。我进行了以下设置,但无法正常工作。我还在stackoverflow上检查了其他线程,但没有一个解决了这个问题。

  • Added Associated Domains in Capabilities Tab on my app's target. Added two domains: activitycontinuation:<myapp>.herokuapp.comand applinks:<myapp>.herokuapp.com.
  • In Build Phases > Copy Bundle Resources added the file .entitlements.
  • Got teamId from https://developer.apple.com/account/#/membership
  • On my website added a route for apple-app-site-associationat https://<myapp>.herokuapp.com/apple-app-site-associationwhich returns the following json:

    {
        "applinks": {
            "apps": [],
            "details": [
                {
                    "appID": "<teamId>.<bundleId>.dev",
                    "paths": [ "*" ]
                },
                {
                    "appID": "<teamId>.<bundleId>",
                    "paths": [ "*" ]
                }
            ]
        },
        "activitycontinuation": {
            "apps": [
                "<teamId>.<bundleId>.dev",
                "<teamId>.<bundleId>"
            ]
        }
    }
    
  • Installed app from Xcode to iPhone 6s Plus (physical device) with bundle id <bundleId>.devand copied link https://<myapp>.herokuapp.com/contentto Notes but it opens in Safari.

  • 在我的应用程序目标的功能选项卡中添加了关联域。添加了两个域:activitycontinuation:<myapp>.herokuapp.comapplinks:<myapp>.herokuapp.com.
  • 在 Build Phases > Copy Bundle Resources 中添加了文件 .entitlements。
  • https://developer.apple.com/account/#/membership获得 teamId
  • 在我的网站上添加一个路由,apple-app-site-associationhttps://<myapp>.herokuapp.com/apple-app-site-association其返回以下JSON:

    {
        "applinks": {
            "apps": [],
            "details": [
                {
                    "appID": "<teamId>.<bundleId>.dev",
                    "paths": [ "*" ]
                },
                {
                    "appID": "<teamId>.<bundleId>",
                    "paths": [ "*" ]
                }
            ]
        },
        "activitycontinuation": {
            "apps": [
                "<teamId>.<bundleId>.dev",
                "<teamId>.<bundleId>"
            ]
        }
    }
    
  • 将应用程序从 Xcode 安装到 iPhone 6s Plus(物理设备),<bundleId>.dev并带有捆绑 ID并复制https://<myapp>.herokuapp.com/content到 Notes 的链接,但它在 Safari 中打开。

回答by meteors

Fixed the issue. The problem was that I was testing with Debug configuration. When I tried with Release build everything is now working fine.

修复了问题。问题是我正在使用调试配置进行测试。当我尝试使用 Release 构建时,一切正常。

回答by dwestgate

There are quite a lot of issues that could be preventing your Universal Links from working here.

有很多问题可能会阻止您的通用链接在这里工作。

Here are some things to double-check:

以下是一些需要仔细检查的事项:

  • Is the AASA file properly named, and properly signed?
  • Are you testing with a physical device? (some say Universal Links now work consistently in the simulator with iOS 10, but I'd still use a physical device)
  • Are your device and provisioning certificates all error-free?
  • Could the AASA file have failed to update when the app was first installed/launched due to an issue with network connectivity (I find that the AASA will fail to download if Charles Proxy is capturing traffic, for example)
  • When testing, are you first pasting the link into Notes and then long-pressing on it? Are you seeing the "Open in App" menu option? If so, Universal Linking is working properly and has just been disabled on the device.
  • AASA 文件是否正确命名并正确签名?
  • 您是否使用物理设备进行测试?(有人说通用链接现在可以在 iOS 10 的模拟器中一致工作,但我仍然会使用物理设备)
  • 您的设备和配置证书是否都没有错误?
  • 由于网络连接问题,首次安装/启动应用程序时,AASA 文件是否无法更新(例如,我发现如果 Charles 代理正在捕获流量,AASA 将无法下载)
  • 测试时,您是先将链接粘贴到 Notes 中,然后长按吗?您看到“在应用程序中打开”菜单选项了吗?如果是这样,Universal Linking 工作正常并且刚刚在设备上被禁用。

I would also recommend running through Alex Austen's super blog post on this topic, as doing so may help you spot the problem (here: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9/).

我还建议您阅读 Alex Austen 关于此主题的超级博客文章,因为这样做可能会帮助您发现问题(此处:https: //blog.branch.io/how-to-setup-universal-links-to-deep -link-on-apple-ios-9/)。

Branch has a number of tools/resources for identifying Universal Linking issues. They are specifically intended for use with Branch links, but you may still find them helpful:

Branch 有许多工具/资源可用于识别通用链接问题。它们专门用于分支链接,但您可能仍然会发现它们很有用:

回答by DiegoQ

Paste your domain into this linkand check that it doesn't have issues

将您的域粘贴到此链接中并检查它是否没有问题