Feature implementation: A jumps to B and opens the specified page in B. http://blog.csdn.net/dollyyang/article/details/50325307
Click on the page to determine whether to install the app and open, otherwise jump to the App Store method
Steps:
1. First create two projects (Project A, Project B), add the URL Types in the Info.plist file in Project B, as shown in: Where URL idenifier is the bundle ID of Project B, add a command prefix to the URL schemes, I use " PROJECTB ", this name can be taken, run the project B.
2. Add a jump code to project a
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"projectB://"]];
Here the URL of the command prefix must be consistent with the previous definition, I added this line of code to a button click Method, now click on the button can jump to project B.
3. Now say that the app jumps between the communication, in fact, the same as the value of the transfer. Click on the second button in project A to add code
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"projectB://openBSecondPage"]];
4. Project B adds a Nsurl attribute in Appdelegate that implements a proxy method that receives the URL passed from project A.
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{ self.url = url; return YES;}
Then add the code to the first interface in B
- (void) Viewdidload {[Super Viewdidload];Nsurl * url = ((Appdelegate *) [uiapplication Sharedapplication] .delegate) .URL; if (URL) {//shows the Url,url = Projectb://openbsecondpage obtained from a Host = Openbsecondpage self.label .text = [nsstring stringwithformat:@ "url =%@,host =%@", [url Absolutestring],[url host]; //some operations based on the host of the transmitted URLs if ([[URL host]isequaltostring:@< Span class= "hljs-string" > "Openbsecondpage"]) {//jump to the second interface [ "second" Sender:nil];}}}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
In short, some custom actions are made after opening project B from a URL passed from a.
Jump between apps, go to Level two interface