与IOS深度链接混淆 [英] Confused with IOS Deep linking

查看:196
本文介绍了与IOS深度链接混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想问一下,有人在这里知道为IOS应用创建深层链接的一步一步的过程吗?我试过阅读一些文章,但它没有给我绝对的答案。谢谢:)

I'll just want to ask if someone here know the step by step process of creating a deep link for an IOS app? I've tried to read some articles but it did not give me absolute answers. Thank you :)

推荐答案

深层链接基本上只是为您的应用设置网址,以便其他应用可以使用信息启动它。如果您进行设置,可以启动应用的某些部分,以便您的应用对某些网址做出反应。所以你需要做一些事情。对于此示例,我将使用两个应用程序。如果您尝试与现有应用程序集成,您只需要找出他们的网址方案。因此,对于此示例,我将Messages用作一个应用程序,将Schedule用作另一个应用程序。

首先:在Messages应用程序中,我们需要设置Schedule应用程序调用的方案。

Deep linking is basically just setting up url to your app so that other apps can launch it with information. The can launch to certain parts of the app if you set it up so that your app reacts to certain urls. 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. 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.

因此,打开您的第一个应用程序我们需要添加方案,以便其他应用程序可以打开它。转到 info.plist 点击小+并输入网址类型点击三角形展开并点击+类型 URL Schemes 并在其中添加一个项目并将您的应用程序名称放入其中。还要添加 URL标识符以及 $(PRODUCT_BUNDLE_IDENTIFIER)作为值。 `

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. Also add URL identifier along with $(PRODUCT_BUNDLE_IDENTIFIER) as the value. `

然后我们只需添加我们可以打开的应用程序,再次点击顶级+并添加 LSApplicationQueriesSchemes 这会将应用程序列入白名单,以便我们可以评估它们是否安装在设备上。

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.


现在我们可以跳转到另一个应用程序并创建一种方法来调用它。对于这个例子,让我们按下按钮就可以实现。

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")
    }

canOpenURL(url)检查应用程序是否在设备上。如果您愿意,可以启动应用程序商店到您的应用程序,如果它返回false。然后 launchAppWithURL 实际启动它。这是您可能还希望发生多个事情的基本设置,因此您可能有多个url方案可以启动相同的应用程序但将其带到应用程序的不同部分。在函数中应用程序的app委托中

The canOpenURL(url) checks to see if the application is on the device. If you wanted to you could launch the app store to your app if that retuned false. then launchAppWithURL actually launches it. 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. 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.

这篇关于与IOS深度链接混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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