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&mt=8
code example:
Nsurl*appstoreurl =[nsurl urlwithstring:@ "http://phobos.apple.com/WebObjects/MZStore.woa/wa/ Viewsoftware?id=291586600&amp;mt=8 "];
[[UIApplication sharedapplication] openurl:appstoreurl];