Needless to say, the need to do this first:
1. Some social elements in the app share a link to social media such as Facebook, Twitter, and Google +
2. When users click on a link to jump to their own page, and then pass the parameters to the iOS app to open the specified sharing data
Idea: iOS provides scheme This can be used to jump to your app from a browser or other app to query scheme-related content.
Find Deeplinkkit This third-party component on GitHub after probably understanding the scheme mechanism.
Use the following:
1. Add a URL Type in plist, such as URL schemes called Com.test.test
2. Add the following code to the Appdelegate:
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions{ Router = [[Dpldeeplinkrouter alloc] init]; Browser call URL: "com.test.test://l/aa/123/456", so BB takes to 123, CC takes to 456 router[@ "/aa/:bb/:cc"] = ^ (Dpldeeplink *link) { NSLog (@ "----------Deeplink:%@,%@----------", link.routeparameters[@ "BB"], link.routeparameters[@ "CC"]); }; }
3. Add the following code to the Appdelegate:
-(BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) Sourceapplication annotation: (id) annotation { BOOL success = [Router Handleurl:url withcompletion:nil]; return success;}
4. Return the app to the background and enter com.test.test://l/aa/123/456 in the browser, where the router block will take effect.
Explain, here L is deeplinkkit this component needs, but the content can be entered casually, in short, must have a field before host. AA is the host mentioned in Deeplinkkit, which is the same as the character registered with router. The rest doesn't have to be explained.
Use down, deeplinkkit or relatively simple, but the document is not well written, I read a long code, which research his demo help the most.
Hope that the students who need to do deep links to help, have any questions, please leave a message here, we communicate together. Thank you!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Original address: http://blog.csdn.net/piratest/article/details/46820321
Introduction to IOS Deeplinkkit use