update:2017.04.08 added part of using iOS Deeplinkkit to use universal links
---------------------------------------------------------
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 a user clicks on a link, it jumps to their page and then passes the number to the iOS app to open the specified share data.
Idea: iOS provides a scheme that can be used to jump from a browser or other app to its own application to query scheme-related content.
Find Deeplinkkit This third-party component on GitHub after probably understanding the scheme mechanism.
Use for example the following:
1. Add a URL Type in plist, for example, URL schemes called Com.test.test
2. Add the following code to the Appdelegate, for example:
-(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, for example:
-(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, there must be a field before host. AA is the host mentioned in Deeplinkkit. This is the same character as the router. The rest doesn't have to be explained.
Use down, deeplinkkit or relatively simple, but the document is relatively poor, I read a long time code, among which research his demo help the most.
Hope that the students who need to do deep links to help, there is no matter what the problem, please leave a message here, we communicate together. Thank you!
-------------------------
update:2017.04.08
Starting with IOS 9.2, the universal links mechanism has been added to further enhance the function of inter-application jump, which is recommended in this regard read deferred deep linking in IOS, this article on deep There are very specific explanations for the two ways of linking. You mustn't miss it. I will not carry it over.
Using iOS Deeplinkkit to support Universal Links, first you have to place a JSON file in the root folder of your official website, and the pages mentioned above have specific narration.
After you have done these preliminary preparations, you need to add the following code to your project:
-(BOOL) Application: (UIApplication *) application continueuseractivity: (nsuseractivity *) useractivity Restorationhandler: (void (^) (Nsarray *)) Restorationhandler { return [Self.router handleuseractivity: Useractivity withcompletion:null];}
Also, since I have a lot more requirements like collection effects, I started using branch very early. This is also good, but the official documents are all in English, there is no better Chinese use of a simple introduction, may be to some of their English ability is not self-confident friends will cause pressure, there is time for me to organize a simple introduction of the use of Chinese.
IOS Deeplinkkit using a simple introduction