简体   繁体   English

与IOS深度链接混淆

[英]Confused with IOS Deep linking

I'll just want to ask if someone here know the step by step process of creating a deep link for an IOS app?我只是想问这里是否有人知道为 IOS 应用程序创建深层链接的分步过程? I've tried to read some articles but it did not give me absolute answers.我试图阅读一些文章,但它没有给我绝对的答案。 Thank you :)谢谢 :)

Deep linking is basically just setting up url to your app so that other apps can launch it with information.深层链接基本上只是为您的应用程序设置 url,以便其他应用程序可以使用信息启动它。 The can launch to certain parts of the app if you set it up so that your app reacts to certain urls.如果您设置它以便您的应用程序对某些 url 做出反应,则可以启动应用程序的某些部分。 So there are a few things that you have to do.因此,您必须做一些事情。 For this example I will use two apps.对于这个例子,我将使用两个应用程序。 If you are trying to integrate with an existing app you just have to find out what their url schemes are.如果您尝试与现有应用程序集成,则只需找出它们的 url 方案。 So for this example I will use 'Messages' as one app and 'Schedule' as another.因此,对于此示例,我将使用“消息”作为一个应用程序,将“日程安排”作为另一个应用程序。
First: in the 'Messages' app we will need to setup the schemes our Schedule app to call.首先:在“消息”应用程序中,我们需要设置计划应用程序调用的方案。

So open up your first app we need to add schemes so other apps can open it.因此,打开您的第一个应用程序,我们需要添加方案,以便其他应用程序可以打开它。 Go to your info.plist click the little + and type URL types hit the triangle to expand and hit the + type URL Schemes and within that one add an item and put your apps name in it.转到您的info.plist单击小 + 并键入URL types点击三角形以展开并点击 + 类型URL Schemes然后在其中添加一个项目并将您的应用程序名称放入其中。 Also add URL identifier along with $(PRODUCT_BUNDLE_IDENTIFIER) as the value.还要添加URL identifier$(PRODUCT_BUNDLE_IDENTIFIER)作为值。 ` ` info.plist 配置

Then we just have to add the apps that we can open so hit the top level + again and add LSApplicationQueriesSchemes This whitlists the apps so we can evaluate weather or not they are installed on the device.然后我们只需要添加我们可以打开的应用程序,因此再次点击顶层 + 并添加LSApplicationQueriesSchemes这将应用程序LSApplicationQueriesSchemes白名单,以便我们可以评估天气或它们是否安装在设备上。

LSApplicationQueriesSchemes Now we can jump over to the other app and create a way to call this.现在我们可以跳转到另一个应用程序并创建一种调用它的方法。 For this example lets make it happen when we press a button.对于这个例子,让我们在按下按钮时让它发生。

IBAction launchMessagesApp() {

  let url = NSURL(string: "Messages://") where UIApplication.sharedApplication().canOpenURL(url) {
    self.launchAppWithURL(url, name: "Messages")
    }

The canOpenURL(url) checks to see if the application is on the device. canOpenURL(url)检查应用程序是否在设备上。 If you wanted to you could launch the app store to your app if that retuned false.如果您愿意,如果返回错误,您可以将应用商店启动到您的应用。 then launchAppWithURL actually launches it.然后launchAppWithURL实际上启动它。 That is the basic setup you may also want to have multiple things happen so you may have multiple url schemes that launch the same app but take it to different parts of the app.这是基本设置,您可能还希望发生多种情况,因此您可能有多个 url 方案来启动同一个应用程序,但将其带到应用程序的不同部分。 In the app delegate of the app in the function在应用程序的应用程序委托中的功能

  func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
    print(url)
    //Any customizations for the app here  
}

You can do anything you can imagine.你可以做任何你能想象到的事情。

Have you checked out Turnpike?你检查过收费公路吗? It's an open source tool for enabling deep linking in iOS apps.它是一个开源工具,用于在 iOS 应用程序中启用深度链接。 http://urxtech.github.io/#GettingStarted http://urxtech.github.io/#GettingStarted

If you want to create a deeplink you might need to do some server code to detect the user device/browser and do some actions based on this.如果你想创建一个深度链接,你可能需要做一些服务器代码来检测用户设备/浏览器并基于此执行一些操作。

I've created a tool that simplify this process, you can check it here: http://www.uppurl.com/我创建了一个简化这个过程的工具,你可以在这里查看: http : //www.uppurl.com/

It's mainly a short link tool that checks for user device and give him the right url based on his devices.它主要是一个短链接工具,用于检查用户设备并根据他的设备为他提供正确的网址。 With this tool you don't need to write any server code and it also takes care of different devices, operating systems and browsers.使用此工具,您无需编写任何服务器代码,它还可以处理不同的设备、操作系统和浏览器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM