`
CshBBrain
  • 浏览: 651329 次
  • 性别: Icon_minigender_1
  • 来自: 成都
博客专栏
B7d9bf34-126e-301f-819e-81f2615b5a2a
开源WebSocket服务...
浏览量:145224
Group-logo
HTML5移动开发
浏览量:138097
社区版块
存档分类
最新评论

iOS程序中调用系统自带应用(短信,邮件,浏览器,地图,appstore,拨打电话)

 
阅读更多

转自:http://blog.csdn.net/yhawaii/article/details/7587355

 

在程序中调用系统自带的应用,比如我进入程序的时候,希望直接调用safar来打开一个网页,下面是一个简单的使用:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    
    //调用safar打开网页    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.cnblogs.com/foxmin"]];
////调用app store (省略号后面加的是产品的id等一些参数)
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.apple.com/app/……"]];
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/app/ "]];
////调用电话
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://XXXXX"]];
////调用SMS
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://XXXXX"]];
////调用Remote
//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"remote://XXX"]];    
    return YES;
}
复制代码


查看更多iPhone应用程序的调用和第三方应用程序的调用,可以在iPhone的URL方案查看。下面列举部分:

Apple iPhone Applications

Safari

Any URL starting with http:// which does not point to maps.google.com or www.youtube.com is sent to Safari:

NSString *stringURL = @"http://wiki.akosma.com/";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Apparently feed:// opens http://reader.mac.com in Safari.

Maps

URLs starting with http://maps.google.com open up the "Maps" application automatically:

NSString *title = @"title";
float latitude = 35.4634;
float longitude = 9.43425;
int zoom = 13;
NSString *stringURL = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%1.6f,%1.6f&z=%d", title, latitude, longitude, zoom];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

It seems that maps:// also opens up the Maps application.

Phone

The phone links start with "tel:" but must not contain spaces or brackets (it can contain dashes and "+" signs, though):

NSMutableString *phone = [[@"+ 12 34 567 89 01" mutableCopy] autorelease];
[phone replaceOccurrencesOfString:@" " 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
[phone replaceOccurrencesOfString:@"(" 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
[phone replaceOccurrencesOfString:@")" 
                       withString:@"" 
                          options:NSLiteralSearch 
                            range:NSMakeRange(0, [phone length])];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", phone]];
[[UIApplication sharedApplication] openURL:url];

SMS

To open the SMS application, just use the sms: protocol in your URL:

NSString *stringURL = @"sms:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

You can specify a phone number, but apparently not a default text for your message:

NSString *stringURL = @"sms:+12345678901";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

The same restrictions apply as for phone URLs, regarding spaces, brackets and dashes.

Mail

These URLs launch Mail and open the compose message controller:

NSString *stringURL = @"mailto:test@example.com";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

You can also provide more information, for a customized subject and body texts:

NSString *subject = @"Message subject";
NSString *body = @"Message body";
NSString *address = @"test1@akosma.com";
NSString *cc = @"test2@akosma.com";
NSString *path = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@", address, cc, subject, body];
NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];

You might also omit some information:

NSString *subject = @"Message subject";
NSString *path = [NSString stringWithFormat:@"mailto:?subject=%@", subject];
NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];

For more complex body texts, you might want to use the CFURLCreateStringByAddingPercentEscapes() function, as explained above in this page.

YouTube

URLs starting with http://www.youtube.com open up the "YouTube" application automatically:

NSString *stringURL = @"http://www.youtube.com/watch?v=WZH30T99MaM";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

It also works with this URL (which normally brings the Flash video player used by YouTube):

NSString *stringURL = @"http://www.youtube.com/v/WZH30T99MaM";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

iTunes

To open up iTunes, use this URL:

NSString *stringURL = @"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=156093464&id=156093462&s=143441";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

App Store

Very similar to the iTunes URLs:

NSString *stringURL = @"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=294409923&mt=8";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

iBooks

(source: http://akos.ma/aqdr)

NSString *stringURL = @"itms-books:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
NSString *stringURL = @"itms-bookss:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Third Party Applications

Most URL schemes in this list come from App Lookup.

AirSharing

Launch the application:

NSString *stringURL = @"airsharing://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Alocola

Launch the application:

NSString *stringURL = @"alocola://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Appigo Notebook

Launch the application:

NSString *stringURL = @"appigonotebook://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Appigo Todo

Launch the application:

NSString *stringURL = @"appigotodo://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Create a new task:

NSString *template = @"appigotodo://com.example.xyzapp/import?name=%@&note=%@&due-date=%@&priority=%@&repeat=%@";
NSString *name = @"Buy%20some%20milk";
NSString *note = @"Stop%20on%20the%20way%20home%20from%20work.";
NSString *dueDate = @"2009-07-16";
NSString *priority = @"1";
NSString *repeat = @"101";
NSString *stringURL = [NSString stringWithFormat:template, name, note, dueDate, priority, repeat];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

Duo

Launch the application and pre-populate the update field with your desired Tweet/Facebook update. Optional: Provide Duo with the custom URL and return path to your app to provide the user with a button to return to your app.

NSString *appID = @"Your Apps Name";
NSString *updateInfo = @"The Tweet/Status Update";
NSString *returnScheme = @"Your Apps Return URL Scheme";
NSString *returnPath = @"Your/Apps/Return/Path";
NSString *baseURL = @"duoxx://updateFaceTwit?";
	
NSString *encodedUpdateInfo = [updateInfo stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSString *urlString = [NSString stringWithFormat:@"%@BLappID=%@;BLupdateInfo=%@;BLreturnScheme=%@;BLreturnPath=%@", 
						   baseURL, appID, encodedUpdateInfo, returnScheme, returnPath];

NSURL *url = [NSURL URLWithString:urlString];
[[UIApplication sharedApplication] openURL:url];

 

The Cartographer

Launch app and add a placemark at given coordinate:

NSString *title = @"Placemark title (optional)";
NSString *summary = @"Placemark description (optional)";
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(123.0, 12.0);

title = [(id)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)title, NULL, (CFStringRef)@";/?:@&=+$,", kCFStringEncodingUTF8) autorelease];
summary = [(id)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)summary, NULL, (CFStringRef)@";/?:@&=+$,", kCFStringEncodingUTF8) autorelease];

NSString *cartographerURL = [NSString stringWithFormat:@"cartographer://placemark?coordinate=%lf,%lf&title=%@&summary=%@", 
         coordinate.latitude, coordinate.longitude, title, summary];

NSURL *url = [NSURL URLWithString:cartographerURL];
[[UIApplication sharedApplication] openURL:url];

Launch app and load either a KML source or a Google My Map:

NSString *sourceURL = @"http://....";
// e.g. http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=208320711678395936256.00046bbcfdcd1f3ebf64b&z=5

// Optional:
MKCoordinateRegion region = ...;
sourceURL = [sourceURL stringByAppendingFormat:@"&ll=%lf,%lf&spn=%lf,%lf", 
               region.center.latitude, region.center.longitude, region.span.latitudeDelta, region.span.longitudeDelta];

NSURL *url = [NSURL URLWithString:[sourceURL stringByReplacingOccurrencesOfString:@"http://" withString:@"cartographer://"]];
[[UIApplication sharedApplication] openURL:url];

 

ChatCo

NSString *stringURL = @"irc://irc.example.domain/roomName";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
NSString *stringURL = @"irc://irc.example.domain/Nickname@roomName";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
NSString *stringURL = @"irc://irc.example.domain/Nickname!Realname@roomName";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
分享到:
评论

相关推荐

    ios-iOS9之iPhone打电话发短信写邮件打开浏览器.zip

    本教程重点聚焦于如何在iPhone上使用核心功能,如打电话、发送短信、撰写邮件以及打开浏览器。下面我们将深入探讨这些功能及其在iOS9中的使用方式。 首先,打电话是iPhone的基础功能之一。在iOS9中,用户可以通过...

    传智播客iOS6免费公开课程-调用打电话发短信发邮件打开浏览器

    在iOS开发中,调用打电话、发送短信、发送邮件以及打开浏览器是常见的功能需求,尤其在构建用户交互丰富的应用程序时。这些功能使得应用能够更好地与系统服务集成,提供便捷的用户体验。下面将详细讲解如何在iOS6及...

    不调用ios自带发送短信通讯录

    虽然标题提到不调用系统自带的发送短信,但在iOS中,官方推荐的方法是使用`MFMessageComposeViewController`类,它允许用户在App内部编写并发送短信。首先,确保在Info.plist文件中添加`...

    ios应用内跳转到AppStore或者iTunes

    在iOS开发中,有时我们需要引导用户在应用内部直接跳转到AppStore或iTunes来查看应用详情、进行评分和评论,或者购买相关的媒体内容。这个功能对于提高应用的可见度和用户参与度至关重要。以下是对这个主题的详细...

    ios一个app应用内部调用另一个新的app应用

    在标题和描述中提到的"ios一个app应用内部调用另一个新的app应用",实际上就是指通过URL Scheme实现iOS应用间的跳转。 首先,我们需要理解什么是URL Scheme。URL Scheme是一种类似于http或https的自定义协议,但它...

    ios应用发布到appstore全部流程

    在iOS应用开发的世界里,将你的应用程序发布到App Store是至关重要的一步,让全球的iPhone和iPad用户能够发现并下载你的作品。以下是你需要了解的关于“ios应用发布到App Store的全部流程”的详细步骤: 1. **创建...

    unity与iOS交互进行App Store内购(IAP)

    本教程将详细介绍如何使用Unity与iOS系统进行交互,实现App Store内购功能。 一、Unity与iOS交互基础 在Unity中实现IAP,我们需要使用Unity的插件系统来引入Apple的StoreKit框架。StoreKit是iOS SDK的一部分,专门...

    iOS 6 SDK在应用内展示App Store

    在iOS开发中,展示App Store是一项常见的功能,特别是在iOS 6时代,苹果引入了新的SDK,使得开发者可以更方便地在自己的应用内嵌入App Store的内容。本文将深入探讨如何利用iOS 6 SDK来实现在应用内展示App Store的...

    苹果iOS程序在AppStore程序发布过程总结

    苹果iOS程序在AppStore程序发布过程是一项复杂且系统的工作流程,对于希望将应用程序发布至全球最大移动应用市场的开发者而言至关重要。本文旨在全面梳理从申请账号到最终在AppStore上线的整个过程,帮助读者更好地...

    IOS 拨打电话(三种方式)

    在iOS平台上,为应用程序添加拨打电话的功能是常见的需求。这里我们将深入探讨三种不同的方法来实现这一功能,确保用户能够从你的应用中直接发起电话呼叫。首先,我们需要了解iOS的权限管理,然后逐一介绍每种拨打...

    IOS应用源码之跳转到app store的小案例 .rar

    首先,跳转到App Store通常涉及到URL Scheme,这是iOS系统提供的一种机制,允许应用程序之间进行交互。App Store有自己的特定URL Scheme,即`itms-apps`,通过这个scheme,我们可以构建一个指向特定App ID的URL,...

    .IOS通过手机浏览器打开指定APP

    - 注册完成后,当通过自定义URL方案访问时(如在浏览器输入“special://”),iOS系统会尝试打开相应注册的应用程序。 2. 在iOS APP之间进行通讯: - iOS APP之间的通讯可以通过URL scheme来实现,即一个APP通过...

    ios 调起地图(百度、高德、系统自带)App导航 demo

    ios 调起地图(百度、高德、系统自带)App导航 demo,是一个展示地图位置标注,公交、自驾、步行3种路线规划的类。并且能同时选择性地调起百度、高德、系统自带高德地图 App 客户端进行全功能的导航功能。使用方法简单...

    ios应用源码之跳转到app store的小案例 20181210

    在iOS应用开发中,有时我们需要实现从我们的应用内部直接跳转到App Store,以便用户可以查看、评价或更新我们的应用程序。这个"ios应用源码之跳转到app store的小案例"是一个很好的学习资源,用于理解如何实现这个...

    iOS 电话 短信调用

    在iOS开发中,电话和短信调用是两个重要的功能领域,尤其对于那些需要与用户通信的应用来说。本文将深入探讨如何在iOS应用中实现电话拨打和短信发送。 首先,我们来讨论电话调用。在iOS中,我们可以使用`TCTL拨打...

    IOS应用源码——跳转到app store的小案例.zip

    而在App Store中,我们使用的URL Scheme是"itms-apps://"。 在源码中,关键部分通常会包含一个按钮的点击事件处理函数。当用户点击这个按钮时,程序会构建一个特定格式的URL,形如`itms-apps://itunes.apple....

    iOS开发调用系统地图计算路线

    最后,如果你的应用需要显示路线选择界面,可以使用`MKMapItem.openInMaps()`方法,让用户在系统地图应用中查看路线: ```swift let startItem = MKMapItem(placemark: startPlacemark) let endItem = MKMapItem...

    ios应用源码之提示用户区app store评分的弹出框 2018128

    在iOS应用开发中,引导用户对App Store进行评分和评论是一项重要的策略,它有助于提高应用的可见性和用户参与度。本资源提供了一份2018年12月8日的iOS应用源码,用于实现自动提示用户去App Store给应用打分的功能。...

    iphone AppStore库

    总的来说,iPhone的AppStore库涉及的知识点包括:AppStore的定义、功能、应用分类、用户界面、安全性和审核机制、开发者提交应用的流程、AppStore在iOS生态系统中的地位以及".app"文件的结构和意义。对于iPhone用户...

Global site tag (gtag.js) - Google Analytics