In iOS development, it is often necessary to call other apps, such as making a phone call, sending an email, and so on. Uiapplication:openurl: The method is for this purpose # #转

Source: Internet
Author: User

Source Address: http://blog.csdn.net/lengshengren/article/details/16339409

In iOS development, it is often necessary to call other apps, such as making a phone call, sending an email, and so on. Uiapplication:openurl: Method is the simplest way to do this, and the method typically invokes different apps by providing a schema for the URL parameter.

The following applications can be called by the OpenURL method:

    • Call Google Maps (Google Maps)
    • Calling the mail client (Apple Mail)
    • Dialing (Phone number)
    • Call SMS (SMS)
    • Invoke browser (Safari Browser)
    • Call the store (AppStore)

Call Google Maps (Google Maps)

URL pattern:http://maps.google.com/maps?q=<strong>${query_string}</strong>

code example:

NSString* searchQuery [email protected] "1 Infinite Loop, Cupertino, CA 95014";
SearchQuery =[addresstext stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];
NSString* urlstring =[nsstring stringwithformat:@ "http://maps.google.com/maps?q=%@", searchQuery];
[[uiapplication sharedapplication] openurl:[nsurl Urlwithstring:urltext]];

Calling the mail client (Apple Mail)

URL pattern:mailto://<strong>${email_address}</strong>

code example:

[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@ "Mailto://[email protected]"];

Dialing (Phone number)

URL pattern:tel://<strong>${phone_number}</strong>

code example:

[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@ "tel://10086"];

Call SMS (SMS)

URL pattern:sms:<strong>${phonenumber_or_shortcode}</strong>

code example:

[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@ "sms:10086"];

Invoke browser (Safari Browser)

code example:

Nsurl*url =[nsurl urlwithstring:@ "http://eyecm.com"];
[[UIApplication sharedapplication] openurl:url];

Call the store (AppStore)

URL mode: http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&amp;mt=8

code example:

Nsurl*appstoreurl =[nsurl urlwithstring:@ "http://phobos.apple.com/WebObjects/MZStore.woa/wa/ Viewsoftware?id=291586600&amp;amp;mt=8 "];
[[UIApplication sharedapplication] openurl:appstoreurl];

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.