iphone自己应用之间调用步骤:
1、在plist文件中,注册对外接口
- 在xcode group&files里面,展开 Supporting Files选择<app>-info.plist。
- 鼠标右击Information Property List,点击add row,然后从列表中选择URL types。
- 右击 add row添加一个对象(item)。
- 右击item add row ,从列表中选择 URL Schemes 再右击添加一个对象(item1),将item1得值设置为:myapp。
- 这个myapp就是对外接口,其它应用可以通过它,调用该应用
plist如下图所示:
2、调用方法
在你需要调用上面注册过对外接口的应用中,添加下面代码即可:
NSURL *url = [NSURL URLWithString:@"myapp:"];
[[UIApplication sharedApplication] openURL:url];
通过上述两个步骤,你可以在你的应用中,让用户打开你的其它应用
调用IOS自带的app的方法
一、调用app store界面方法
在实际开发中,往往要推荐自己其他应用和推荐自己的收费软件,那么我们就需要在程序中直接连接到app store的相应页面。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"程序的相应连接"]];
二、调用其它应用的方法
1)调用自带mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://"]];
2)调用电话phone
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];
3)调用 SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];
4)调用自带浏览器 safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://"]];
5)调用 Remote
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"remote://"]];
上面是最基本的语句,没什么处理过程。
如:调用phone可以传递号码,调用SMS只能设定号码,不能初始化SMS内容。
1、调用 自带mail
02 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@ "mailto://admin@hzlzh.com" ]]; |
05 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@ "tel://8008808888" ]]; |
08 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@ "tel://123456789" ]]; |
10 | 使用这种方式拨打电话时,当用户结束通话后,iphone界面会停留在电话界面。 |
11 | 用如下方式,可以使得用户结束通话后自动返回到应用: |
12 | UIWebView*callWebview =[[UIWebView alloc] init]; |
13 | NSURL *telURL =[NSURL URLWithString:@ "tel:10086" ]; |
14 | [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; |
16 | [self.view addSubview:callWebview]; |
19 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@ "telprompt://10086" ]]; |
22 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@ "sms://800888" ]]; |
25 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@ "http://www.hzlzh.com" ]]; |
27 | 调用phone可以传递号码,调用SMS 只能设定号码,不能初始化SMS内容。 |
30 | 加入:MessageUI.framework |
32 | #import <MessageUI/MFMessageComposeViewController.h> |
34 | 实现代理:MFMessageComposeViewControllerDelegate |
40 | - ( void )sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients |
43 | MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease]; |
45 | if ([MFMessageComposeViewController canSendText]) |
49 | controller.body = bodyOfMessage; |
51 | controller.recipients = recipients; |
53 | controller.messageComposeDelegate = self; |
55 | [self presentModalViewController:controller animated:YES]; |
62 | - ( void )messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result |
64 | [self dismissModalViewControllerAnimated:YES]; |
66 | if (result == MessageComposeResultCancelled) |
67 | NSLog(@ "Message cancelled" ) |
68 | else if (result == MessageComposeResultSent) |
69 | NSLog(@ "Message sent" ) |
71 | NSLog(@ "Message failed" ) |