通用链接在iOS 10.2中不起作用 [英] Universal links doesn't work in iOS 10.2

查看:71
本文介绍了通用链接在iOS 10.2中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HTTPS根目录(kumpul.co.id/apple-app-site-association)中提供了apple-app-site-association,结果从

I have serve apple-app-site-association in my HTTPS root (kumpul.co.id/apple-app-site-association) and the result is passed from https://branch.io/resources/aasa-validator/#resultsbox

我已在我的权利中对其进行了配置: applinks:kumpul.co.id

I have configured it in my entitlements: applinks:kumpul.co.id

并且我已经将此功能放到我的Appdelegate.swift中:

and i have put this function in my Appdelegate.swift:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
    NSLog("Check Universal Link")
    // 1
    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
        let url = userActivity.webpageURL,
        let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
            return false
    }
        print("url: \(url)")
    print("component: \(components)")

    // 2
    if let match = MatchHandler.sharedInstance.items.filter({ $0.path == components.path}).first {
        self.presentMatch(match)
        return true
    }
    //3
    let webpageUrl = URL(string: "http://www.kumpul.co.id")!
    application.openURL(webpageUrl)

    return false
}

对于路径,我设置了路径":["/match/*"],因为链接例如是 kumpul.co.id/match/play_2.html

For the paths, i set "paths": [ "/match/*"] because the links would be kumpul.co.id/match/play_2.html for example

但是当我单击WhatsApp或Line消息上的链接时,根本没有调用此函数,单击链接时我看不到日志.我在这里做什么错了?

but when i click my link on WhatsApp or Line message, this function doesn't called at all, i can't see the logs when i click the link. What am i doing wrong here ?

推荐答案

行与通用链接不兼容,因此测试用例无效.单击通用链接"时,即使所有配置均已完美配置,您的应用也无法打开(您需要使用号召性用语按钮提供内容的网络预览,例如.

Line is not compatible with Universal Links, so that test case is invalid. Your app won't open when a Universal Link is clicked in Line, even if everything is configured perfectly (you need to offer a web preview of the content with a call-to-action button, like this — the same problem exists on Facebook, by the way).

WhatsApp应该可以运行..如果在单击链接时您的应用甚至没有启动,则说明存在配置问题.您可以尝试在此页面.如果您的应用程序正在启动,则您的配置正确,您应该验证 continue userActivity

WhatsApp should be working. If your app is not even launching when the link is clicked, you have a configuration issue. You can try walking through some of the troubleshooting steps on this page. If your app is launching, then your configuration is correct and you should verify the logic inside continue userActivity

这篇关于通用链接在iOS 10.2中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆