The most complete classic summary: iOS jump to Third-party applications, app jump transfer value

Source: Internet
Author: User

It is best to add support for HTTP protocol info plist Plus

<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Attention:

Simulator can also jump, the first time the simulator Jump app will pop up a prompt box.

The real machine doesn't bounce. Prompt box

Here the URL identifier, URL schemes required

URL schemes recommended lowercase, because after receiving the data, do not distinguish between uppercase and lowercase, are converted to lowercase. such as URL schemes fill in Ceshi in fact and fill in Ceshi same





Pedometer Application:

Open the Info.plist Info tab to add an array lsapplicationqueriesschemes array one: item 0:ceshi01

In the URL types at the bottom of the Info tab identifier do not need to fill in the URL schemes:pedometer

-(void) Performanceaction: (UIButton *) Sender {

Nsurl *otherappurl = [nsurlurlwithstring:@ "ceshi01://"];

Determine if the current system has a third party app client installed

if ([[Uiapplicationsharedapplication]canopenurl:otherappurl]) {

[[Uiapplicationsharedapplication]openurl:otherappurl];

}else{

Open a Web page

Nsurl *myurl = [nsurlurlwithstring:@ "https://www.baidu.com/"];

[[Uiapplicationsharedapplication]openurl:myurl];

}

}



CESHI01 Application:

Lsapplicationqueriesschemes Array

Item 0:pedometer

URL types identifier do not need to fill in the URL schemes:ceshi01 if not fill in the other jump does not come in

-(Ibaction) Jumptootherappaction: (UIButton *) Sender {

Nsurl *otherappurl = [Nsurl urlwithstring:@ "pedometer://"]; The specified format is that the message passed by the URL schemes://is case sensitive

Here the pedometer represents the Third-party application of the Info.plist URL Types has a URL schemes for pedometer does not require third-party application of the project name for pedometer,

There is also no need for third-party applications of the Bundle Identifier at the end of pedometer (that is, com. Xxxxx.pedometer form), which means that the jump between applications is not related to the project name, but also to Bundle identifier

Here will be the URL schemes in the pedometer called "Jump Key"

Determine if the current system has a third party app client installed

if ([[[UIApplication sharedapplication] Canopenurl:otherappurl]) {

[[UIApplication sharedapplication] openurl:otherappurl];

}else{

Open a Web page

Nsurl *myurl = [Nsurl urlwithstring:@ "https://www.baidu.com/"];

[[UIApplication sharedapplication] openurl:myurl];

}

}

After the above set two app can jump each other


after my repeated testing: (bidirectional jump is both applications meet the following one-way jump)

the process of one-way jump guessing **********************************************************:


such as application ceshi02 jump to application pedometer

The first step: Jump code:

-(Ibaction) Jumpaction: (UIButton *) Sender {

Nsurl *otherappurl = [nsurlurlwithstring:@ "jumpkey://"];

Determine if the current system has a third party app client installed

if ([[Uiapplicationsharedapplication]canopenurl:otherappurl]) {

[[Uiapplicationsharedapplication]openurl:otherappurl];

}else{

Open a Web page

Nsurl *myurl = [nsurlurlwithstring:@ "https://www.baidu.com/"];

[[Uiapplicationsharedapplication]openurl:myurl];

}

}

The second step: the application of their own: query [Nsurl urlwithstring:@ "jumpkey://"]; Jumpkey in the Lsapplicationqueriesschemes if the query is to the error

-canopenurl:failed for URL: ' pedometer://'-error: ' This app isn't allowed to query for scheme pedometer '

Step three: Third party application pedometer URL schemes have Jumpkey if there is a jump

Otherwise it will error -canopenurl:failed for URL: "pedometer://"-Error: "(null)"

These three steps are indispensable

Note: If ceshi02 meet the above jump, when you want to jump back from the application pedometer ceshi02 must also meet the above jump three steps, but the identity of the swap

If you do not meet the jump three steps then can not jump back to apply ceshi02 but does not affect the system automatically generated in the upper left corner of the return "ceshi02" button back to its own ceshi02 application










The following research applications transfer values: First jump to meet the above three steps here no longer repeat

Application of pedometer to the application of Ceshi transfer value


1. In application pedometer:

-(void) Serviceaction: (UIButton *) Sender {

Nsurl *otherappurl = [nsurlurlwithstring:@ "Ceshi://hello"]; Hello for message

Determine if the current system has a third party app client installed

if ([[Uiapplicationsharedapplication]canopenurl:otherappurl]) {

[[Uiapplicationsharedapplication]openurl:otherappurl];

}else{

Open a Web page

Nsurl *myurl = [nsurlurlwithstring:@ "https://www.baidu.com/"];

[[Uiapplicationsharedapplication]openurl:myurl];

}

}


2. Application of Ceshi

In Appdelegate

Message is printed as Hello

-(BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) sourceapplication annotation: (id) annotation

{

nsstring* message = [[urlhost]stringbyremovingpercentencoding];

NSLog (@ "%@", message);

Returnyes;

}

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.