简体   繁体   中英

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? 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. 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.

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. ` 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 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. 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.

Have you checked out Turnpike? It's an open source tool for enabling deep linking in iOS apps. 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/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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