在swift中配置深层链接? [英] Configure deep links in swift?

查看:150
本文介绍了在swift中配置深层链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个用swift编写的应用程序,我想使用深层链接。用户将点击URL路线中具有不同信息的信息,例如帖子的id或其拥有的喜欢的数量或类似的信息。我知道你把它放在AppDelegate中:

So I have an app written in swift that I would like to use deep links for. A user would click on one that in the route of the URL had different pieces of information such as the id of the post or the number of likes it has or something like that. I understand that you put this in the AppDelegate:

func application(application: UIApplication,openURL url: NSURL,sourceApplication sourceApplication: String?,annotation annotation: AnyObject?) -> Bool {
    println(url.host as String!)
    return true
}

并且在 appname:// 之后打印所有内容。但是如何将 url.host 发送到我的视图控制器以解析为我需要的信息。如果URL的声明在该函数之外,那么我可以使用它:

And that prints everything after appname://. But how can I get url.host to my view controller to be parsed into the information I need. If the declaration of URL was outside of that function then I could use this:

let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let InfoFromDeepLink = appDelegate.url.host

但是因为它在那个庞大的目标里面-C功能,我很无奈。你怎么做到这一点?我完全不知所措。我甚至无法将函数设置为 return url.host ,因为它不允许这样做。这就是我在Javascript中所做的。如果您也知道Javascript可能会用Web开发人员理解的术语来表达,因为我对此很陌生。对于Swift开发人员来说,这必须如此简单吗?我觉得很蠢。

but since it's inside of that bulky Objective-C function, I'm helpless. How do you do this? I'm completely baffled. I can't even set the function to return url.host because it doesn't allow that. That's what I would do in Javascript. If you also know Javascript maybe put it in terms that a web developer would understand because I'm pretty new to this. This has to be so simple for a Swift developer right? I feel so stupid.

推荐答案

Apple不再支持Deep Links。它现在被称为通用链接,其工作方式略有不同。

Apple no longer supports Deep Links. It is now called Universal Links and works a bit differently.

来源


既然Apple不再支持深度链接的URI方案,开发人员必须实现Universal Links才能在iOS上正确地进行深层链接。如果您已经在使用URI方案,请查看我们关于过渡到Universal Links的博客。

Now that Apple no longer supports URI schemes for deep linking, developers must implement Universal Links in order to deep link properly on iOS. If you are already using URI schemes, check out our blog on transitioning to Universal Links.

来自: HERE

HERE 是关于Universal Links的另一篇文章及其内容。

And HERE is another article on Universal Links and what they are.

这篇关于在swift中配置深层链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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