iOS 10.3 通用链接不工作

iOS 10.3 Universal Links Not Working

我已经遍历了关于 SO 的几乎所有通用链接问题,我可以找到但还没有找到任何运气。作为记录,这一切似乎都通过了 Branch's validator

我是 运行 iOS 10.3 并在 https 后提供我的 aasa 文件,所以理论上我不需要签名。

这是我的立场:

安装应用程序后,跟踪 Heroku 的登台服务器日志会给我以下信息:

7-07-27T17:24:59.818724+00:00 heroku[router]: at=info method=GET path="/.well-known/apple-app-site-association" host=trueey-staging.herokuapp.com request_id=54b817e2-1d89-4c7a-9ed8-f52bdb3ad46e fwd="24.23.197.78" dyno=web.1 connect=1ms service=6ms status=200 bytes=618 protocol=https
2017-07-27T17:24:59.812926+00:00 app[web.1]: Started GET "/.well-known/apple-app-site-association" for 24.23.197.78 at 2017-07-27 17:24:59 +0000
2017-07-27T17:24:59.814845+00:00 app[web.1]: Processing by Web::AppSiteController#show as */*
2017-07-27T17:24:59.815538+00:00 app[web.1]: Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)

1) 我的权利:

applinks:trueey-staging.herokuapp.com
applinks:https://trueey-staging.herokuapp.com

这些是同一回事吗?可能吧,但让我们加倍努力

2) 我的 apple-app-site-association 文件、路由和提供它的 Rails 控制器:

apple-app-site-association(以 apple-app-site 的身份存在于 /public):

{
    "applinks": {
        "apps": [ ],
        "details": [
            {
                "appID": "[Prefix].[AppId]",    
                "paths": [ "*", "/" ]
            }
        ]
    }   
}

路线:

  get "/apple-app-site-association", to: "web/app_site#show"
  get "/.well-known/apple-app-site-association", to: "web/app_site#show"

控制器:

module Web

class AppSiteController < ApplicationController
    def show
        data = File.read("#{Rails.root}/public/apple-app-site")
        render json: data
    end
end

end

3) 在我的 AppDelegate 中,我实现了 application:continueUserActivity:restorationHandler: 函数,它被设置为做与调用 didFinishLaunchingWithOptions 时完全相同的事情(加上打印出大量 ==== 踢)

还有...

没有。部署到暂存后,我在我的 phone 上加载应用程序,通过我们的共享功能生成一个 link,将其保存到笔记中,然后单击它仅在 Safari 中打开它。长按不会执行任何操作,并且没有其他迹象表明 Safari 正在打开而不是应用程序。设备日志似乎没有显示任何问题,但也许我没有搜索正确的东西?

晕。

我认为以下内容可以帮助到您。

1) applinks:trueey-staging.herokuapp.com 在关联域中

2) 尝试将 https://trueey-staging.herokuapp.com/apple-app-site-association 中的 json 更改为

{"applinks":{"apps":[],"details":[{"appID":"SSHENFP95X.com.markmywordsllc.trueey-staging","paths":["*"]}]}}

3) Apple 需要时间来注册新的通用链接。

完成这些步骤后,尝试从另一个应用程序打开 https://trueey-staging.herokuapp.com,它应该会打开您的应用程序

您的问题似乎出在您的应用实施上,而不是您的服务器上。

您需要在您的应用委托上实现 application:continueUserActivity:restorationHandler: 功能。

您可以阅读更多相关信息 here 我猜您已经访问过,但请密切注意 "Preparing Your App to Handle Universal Links" 部分,特别是:

After you specify your associated domains, adopt the UIApplicationDelegate methods for Handoff (specifically application:continueUserActivity:restorationHandler:) so that your app can receive a link and handle it appropriately.

When iOS launches your app after a user taps a universal link, you receive an NSUserActivity object with an activityType value of NSUserActivityTypeBrowsingWeb. The activity object’s webpageURL property contains the URL that the user is accessing. The webpage URL property always contains an HTTP or HTTPS URL, and you can use NSURLComponents APIs to manipulate the components of the URL.

最终使它起作用的是添加一个 application-identifier 授权,其值类似于 AASA 文件中的 appID;我使用通配符 $() 作为后缀,因此理论上它可以跨部署环境工作。不知道那应该来自哪里,也不知道 Apple 的文档中有什么假设,但是......应用程序现在从链接打开!