Call the OpenURL method of the UIApplication class between apps

Source: Internet
Author: User

First, the OpenURL method of UIApplication class

1. Call the App Store interface method

In the actual development, often to recommend their own other applications and recommend their own fee software, then we need to connect directly to the App store's corresponding page in the program.

The practical approach is simple, using the OpenURL method of the UIApplication class:

[[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:@ "The corresponding connection of the program]];

 

2. Methods for invoking other applications

Call to bring your own mail

[[Uiapplicationsharedapplication] openurl:[nsurlurlwithstring:@ "Mailto://[email protected]"];

Call Telephone Phone

[[UIApplication sharedapplication] openurl:[nsurlurlwithstring:@ "tel://8008808888"];

Call SMS

[[Uiapplicationsharedapplication] Openurl:[nsurl urlwithstring:@ "sms://800888"];

Call your own browser safari

[[Uiapplicationsharedapplication] openurl:[nsurlurlwithstring:@ "http://www.hzlzh.com"];

Call Remote

[[Uiapplicationsharedapplication] Openurl:[nsurl urlwithstring:@ "REMOTE://FFF"];

Call phone can pass number, call SMS can only set number, cannot initialize SMS content.

Second, Inter-application communication

1, in the plist file, register the external interface

Locate the Appname-info.plist file, click Open it, find the URL in the list types (if not, add a URL types) inside the content settings to see:

 

Key keys and value are URL identifier = com.zilanxing.andpush;url schemes = Andpush

The external interface has been registered.

2, call the above interface communication

Registration URL Address:andpush://cn.andpush.com/access/register?code=zodspc8zxv

Open app Registration app via iOS browser

Andpush user Registration, when the user mailbox received the invitation link, directly click on the link below to open the Andpush application registration page

<a href= "ANDPUSH://CN.ANDPUSH.COM/ACCESS/REGISTER?CODE=ZODSPC8ZXV" >andpush://cn.andpush.com/access/ Register?code=zodspc8zxv</a>

//Through other app apps Open the registration page for the Andpush application

[[uiapplication sharedapplication] Openurl:[nsurl urlwithstring:@ "andpush://cn.andpush.com/access/ REGISTER?CODE=ZODSPC8ZXV "];

3, Andpush the Request for registration page

Add the following code to the Andpush application's APPDELEGATE.M file:

-(BOOL) Application: (UIApplication *) application Handleopenurl: (nsurl *) URL

{

if (!url) {

return NO;

}

NSLog (@ "Handleopenurl:%@", [url absolutestring]);

//When host equals cn.andpush.com, the description is a registration request

if ([[[URL host] isequaltostring:@ "cn.andpush.com"]) {

Requested URL address: ANDPUSH://CN.ANDPUSH.COM/ACCESS/REGISTER?CODE=ZODSPC8ZXV

Get the registration Invitation code code

NSString *code = [[url query] substringfromindex:[[url query] rangeofstring:@ "code="].location+5];

NSLog (@ "code:%@", code);

Use local Viewcontroller to register

Userregisterviewcontroller *viewcontroller = [[[[Userregisterviewcontrolleralloc] init] autorelease];

Viewcontroller.title = @ "register";

Viewcontroller.code = code;

Show view from bottom

Uinavigationcontroller *navigationcontroller = [[Uinavigationcontroller alloc] Initwithrootviewcontroller: Viewcontroller];

Navigationcontroller.title = @ "register";

[Self.tabbarcontroller Presentmodalviewcontroller:navigationcontroller animated:true];

[Navigationcontroller release];

[Self.navigationcontroller Pushviewcontroller:controller Animated:yes];

[Controller release];

return YES;

} else {

return NO;

}

}

This is done, and then perfected.

Other references:

Http://www.cocoachina.com/newbie/tutorial/2012/0529/4302.html

Http://www.byywee.com/page/M0/S753/753470.html

Http://www.cocoachina.com/bbs/simple/?t58388.html

Transfer from http://blog.163.com/wzi_xiang/blog/static/659829612012910103458775/

Call the OpenURL method of the UIApplication class between apps

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.