Jump between apps, go to Level two interface

Source: Internet
Author: User

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


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://"]];
    • 1

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"]];
    • 1

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;}
    • 1
    • 2
    • 3
    • 4
    • 5

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.