- 浏览: 902754 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (466)
- iPhone, iOS , Objective-c (155)
- 数据库 (20)
- 设计模式 (5)
- 第三方包管理,cocoapod (2)
- 版本管理, SVN, Subversion, Git (1)
- Google, Android, Java (14)
- Wordpress (1)
- 职业素养 (3)
- 版本管理,git (3)
- 前端小技巧 (2)
- flash (1)
- javascript (5)
- Ruby (0)
- 编程语言 (1)
- 网络常识 (1)
- 找到生活好感觉 (5)
- 产品经理 (1)
- markdown (1)
- 云服务器 (1)
- iPhone (116)
- iOS (116)
- Objective-c (116)
- 学习技巧 (2)
- Google (5)
- Android (6)
- Java (21)
- python (1)
- sqlite (3)
- node.js (2)
- mongodb (2)
- 学习技巧,阅读 (2)
- 软件测试 (3)
- 架构设计 (2)
- 设计 (1)
- Spring framework (3)
- junit (1)
- Linux (2)
- 软件 (1)
- Struts2 (1)
- 版本管理 (3)
- SVN (3)
- Subversion (3)
- Git (3)
- mysql (5)
- quartz (1)
- 无关技术 (1)
- 前端 (1)
- Redis (1)
- 产品管理 (0)
- 计算机常识 (1)
- 计算机科学 (0)
- swift (1)
- 服务器 (2)
- 搜索 (1)
- Scala (1)
- J2EE (1)
- maven (1)
- 前端css (1)
- 英语 (1)
- 消息队列 (1)
- kafka (0)
- apache kafka (4)
- netbeans (1)
- IDE (2)
- 歌词 (1)
- 过滤器实现 (1)
- linux vim vi (1)
- jmeter (1)
- springcloud (1)
最新评论
-
hujingnemo:
不知道为什么打不开
CHM如何改编字体大小 -
weiboyuan:
求答案 weiboyuanios@163.com
iOS软件工程师面试题(高级) -
xueji5368:
这个现在已经广泛使用了嘛!
RoboGuice入门 -
Yao__Shun__Yu:
...
CHM如何改编字体大小 -
353144886:
非常之详细 美女求认识
sqlite数据类型 datetime处理
先介绍一种最简单的方法:
调用打电话功能
[[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];
调用发短信功能
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"sms://10000"]];
上面的发短信的功能是调用系统的界面,下面是实现一种点击按键就直接发送短信,相当于后台发送,能不能上软件商店,还不能确定。相对建议来说,尽量使用第一种。
首先导入MFMessageComposeViewControllerDelegate这个代理,实现里面的方法
-(void)messageComposeViewController:(MFMessageComposeViewController *)controllerdidFinishWithResult:(MessageComposeResult)result {
//Notifies users about errors associated with the interface
switch (result) {
case MessageComposeResultCancelled:
if (DEBUG) NSLog(@"Result: canceled");
break;
case MessageComposeResultSent:
if (DEBUG) NSLog(@"Result: Sent");
break;
case MessageComposeResultFailed:
if (DEBUG) NSLog(@"Result: Failed");
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
}
群发短信:
- (IBAction)sendSMS {
BOOL canSendSMS = [MFMessageComposeViewController canSendText];
NSLog(@"can send SMS [%d]",canSendSMS);
if (canSendSMS) {
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.navigationBar.tintColor = [UIColor blackColor];
picker.body = @"test";
picker.recipients = [NSArray arrayWithObject:@"10086"];
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
给一个人发短信:
从网页上获得内容
-(void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
UIWebView *web = nil;
NSMutableString* absUrl = [[NSMutableString alloc] initWithString:web.request.URL.absoluteString];
[absUrl replaceOccurrencesOfString:@"http://i.aizheke.com" withString:@"http://m.aizheke.com" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [absUrl length])];
picker.body=[NSString stringWithFormat:@"我在爱折客上看到:%@ 可能对你有用,推荐给你!link:%@",[webstringByEvaluatingJavaScriptFromString:@"document.title"],absUrl];
[absUrl release];
[self presentModalViewController:picker animated:YES];
[picker release];
}
事件绑定发送短信
-(IBAction)showSMSPicker:(id)sender {
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil) {
if ([messageClass canSendText]) {
[self displaySMSComposerSheet];
}
else {
//设备没有短信功能
}
}
else {
// iOS版本过低,iOS4.0以上才支持程序内发送短信
}
}
以上内容有一部分是来各个网站,本人自己加上自己的理解,整理,至于来源于互联网的那一部分作者是谁,来自于哪里,我现在也不知道了,写出来供大家学习。如果有你是那一部分的作者,请联系我!
Restrictions
If you could send an SMS within a program on the iPhone, you'll be able to write games that spam people in the background. I'm sure you really want to have spams from your friends, "Try out this new game! It roxxers my boxxers, and yours will be too! roxxersboxxers.com!!!! If you sign up now you'll get 3,200 RB points!!"
Apple has restrictions for automated (or even partially automated) SMS and dialing operations. (Imagine if the game instead dialed 911 at a particular time of day)
Your best bet is to setup an intermediate server on the internet that uses an online SMS sending service, and send the SMSs via that route if you need complete automation. (ie, your program on the iPhone sends a UDP packet to your server, which sends the real SMS)
iOS 4 Update
iOS 4, however, now provides a viewcontroller you can import into your application. You prepopulate the SMS fields, then the user can initiate the SMS send within the controller. Unlike using the "sms:..." url format, this allows your application to stay open, and allows you to populate both the to and the body fields. You can even specify multiple recipients.
This prevents applications from sending automated SMS without the user explicitly aware of it. You still cannot send fully automated SMS from the iPhone itself, it requires some user interaction. But this at least allows you to populate everything, and avoids closing the application.
The MFMessageComposeViewController class is well documented, and tutorials show how easy it is to implement.
iOS 5 Update
iOS 5 includes messaging for iPod touch and iPad devices, so while I've not yet tested this myself, it may be that all iOS devices will be able to send SMS via MFMessageComposeViewController. If this is the case, then Apple is running an SMS server that sends messages on behalf of devices that don't have a cellular modem.
iOS 6 Update
No changes to this class.
iOS 7 Update
You can now check to see if the message medium you are using will accept a subject or attachments, and what kind of attachments it will accept. You can edit the subject and add attachments to the message, where the medium allows it.
Limitations to this class
Keep in mind that this won't work on phones without iOS 4, and it won't work on the iPod touch or the iPad, except, perhaps, under iOS 5. You must either detect the device and iOS limitations prior to using this controller, or risk restricting your app to recently upgraded 3G, 3GS, and 4 iPhones.
However, an intermediate server that sends SMS will allow any and all of these iOS devices to send SMS as long as they have internet access, so it may still be a better solution for many applications. Alternately, use both, and only fall back to an online SMS service when the device doesn't support it.
调用打电话功能
[[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];
调用发短信功能
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"sms://10000"]];
上面的发短信的功能是调用系统的界面,下面是实现一种点击按键就直接发送短信,相当于后台发送,能不能上软件商店,还不能确定。相对建议来说,尽量使用第一种。
首先导入MFMessageComposeViewControllerDelegate这个代理,实现里面的方法
-(void)messageComposeViewController:(MFMessageComposeViewController *)controllerdidFinishWithResult:(MessageComposeResult)result {
//Notifies users about errors associated with the interface
switch (result) {
case MessageComposeResultCancelled:
if (DEBUG) NSLog(@"Result: canceled");
break;
case MessageComposeResultSent:
if (DEBUG) NSLog(@"Result: Sent");
break;
case MessageComposeResultFailed:
if (DEBUG) NSLog(@"Result: Failed");
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
}
群发短信:
- (IBAction)sendSMS {
BOOL canSendSMS = [MFMessageComposeViewController canSendText];
NSLog(@"can send SMS [%d]",canSendSMS);
if (canSendSMS) {
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.navigationBar.tintColor = [UIColor blackColor];
picker.body = @"test";
picker.recipients = [NSArray arrayWithObject:@"10086"];
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
给一个人发短信:
从网页上获得内容
-(void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
UIWebView *web = nil;
NSMutableString* absUrl = [[NSMutableString alloc] initWithString:web.request.URL.absoluteString];
[absUrl replaceOccurrencesOfString:@"http://i.aizheke.com" withString:@"http://m.aizheke.com" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [absUrl length])];
picker.body=[NSString stringWithFormat:@"我在爱折客上看到:%@ 可能对你有用,推荐给你!link:%@",[webstringByEvaluatingJavaScriptFromString:@"document.title"],absUrl];
[absUrl release];
[self presentModalViewController:picker animated:YES];
[picker release];
}
事件绑定发送短信
-(IBAction)showSMSPicker:(id)sender {
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil) {
if ([messageClass canSendText]) {
[self displaySMSComposerSheet];
}
else {
//设备没有短信功能
}
}
else {
// iOS版本过低,iOS4.0以上才支持程序内发送短信
}
}
以上内容有一部分是来各个网站,本人自己加上自己的理解,整理,至于来源于互联网的那一部分作者是谁,来自于哪里,我现在也不知道了,写出来供大家学习。如果有你是那一部分的作者,请联系我!
Restrictions
If you could send an SMS within a program on the iPhone, you'll be able to write games that spam people in the background. I'm sure you really want to have spams from your friends, "Try out this new game! It roxxers my boxxers, and yours will be too! roxxersboxxers.com!!!! If you sign up now you'll get 3,200 RB points!!"
Apple has restrictions for automated (or even partially automated) SMS and dialing operations. (Imagine if the game instead dialed 911 at a particular time of day)
Your best bet is to setup an intermediate server on the internet that uses an online SMS sending service, and send the SMSs via that route if you need complete automation. (ie, your program on the iPhone sends a UDP packet to your server, which sends the real SMS)
iOS 4 Update
iOS 4, however, now provides a viewcontroller you can import into your application. You prepopulate the SMS fields, then the user can initiate the SMS send within the controller. Unlike using the "sms:..." url format, this allows your application to stay open, and allows you to populate both the to and the body fields. You can even specify multiple recipients.
This prevents applications from sending automated SMS without the user explicitly aware of it. You still cannot send fully automated SMS from the iPhone itself, it requires some user interaction. But this at least allows you to populate everything, and avoids closing the application.
The MFMessageComposeViewController class is well documented, and tutorials show how easy it is to implement.
iOS 5 Update
iOS 5 includes messaging for iPod touch and iPad devices, so while I've not yet tested this myself, it may be that all iOS devices will be able to send SMS via MFMessageComposeViewController. If this is the case, then Apple is running an SMS server that sends messages on behalf of devices that don't have a cellular modem.
iOS 6 Update
No changes to this class.
iOS 7 Update
You can now check to see if the message medium you are using will accept a subject or attachments, and what kind of attachments it will accept. You can edit the subject and add attachments to the message, where the medium allows it.
Limitations to this class
Keep in mind that this won't work on phones without iOS 4, and it won't work on the iPod touch or the iPad, except, perhaps, under iOS 5. You must either detect the device and iOS limitations prior to using this controller, or risk restricting your app to recently upgraded 3G, 3GS, and 4 iPhones.
However, an intermediate server that sends SMS will allow any and all of these iOS devices to send SMS as long as they have internet access, so it may still be a better solution for many applications. Alternately, use both, and only fall back to an online SMS service when the device doesn't support it.
发表评论
-
UIImage变为NSData并进行压缩
2014-05-19 20:23 1924//sdk中提供了方法可以直接调用 UIImage *im ... -
update cocapods
2014-05-17 22:27 799早上更新cocoapod依赖库,发现更新到32.1版本,早先的 ... -
iOS发送短信息代码实例
2014-05-16 18:15 2685#import <MessageUI/Message ... -
DISPATCH TIMER
2014-05-14 16:12 726/* __block void (^callback) ... -
UITextField左边显示图片
2014-05-13 18:08 1168The overlay view displayed on t ... -
iOS面试题
2014-05-09 16:10 10761.写一下UIButton与UITableView的层级结构 ... -
socket二进制报文
2014-05-09 15:18 1299里面有帧头 字符串UTF-8 中间用0隔开 又一个字符串 ... -
将网站添加到桌面的方法
2014-05-08 14:25 1660<link href="http://www. ... -
iPhone通讯录联系人操作大全
2014-05-07 10:29 14551.需要引入AddressBook.framework框架 2 ... -
sqlite获取最新插入的rowid
2014-05-07 09:59 1516除了 last_insert_rowid select max ... -
号码归属地查询,拨打电话
2014-05-06 15:07 841在程序内调用拨打电话的方法,[[UIApplication s ... -
iOS时间合并
2014-04-28 17:55 1093合并同一时间的课程,同一时间可能有多个课程,比如13:30-1 ... -
vCard通讯录格式说明
2014-04-28 16:47 2554原帖:http://freesoftman.iteye.com ... -
UISearchBar背景色全套解决方案
2014-04-25 09:36 7439os系统升级到7.1后,原来在7.0下显示正常的UISearc ... -
升级XCode5.1.1遇到的奇葩问题NSString,NSObjectRuntime.h报错,Foundation找不到
2014-04-24 11:19 894升级XCode5.1.1遇到的奇葩问题NSString,NSO ... -
将NSString转为NSArray
2014-04-22 16:52 6266// Your JSON data: NSString *c ... -
另外一种NSData转为NSString的方法
2014-04-22 15:40 1211If the data is not null-termina ... -
HTTP,Socket,WebSocket异同
2014-04-18 16:54 1829参考文章: http://abbshr.g ... -
push隐藏UINavigtaionBar和UITabbar
2014-04-17 15:20 1087[self.navigationController setN ... -
数据库SQL
2014-04-11 13:31 9201、说明:创建数据库 CREATE DATABASE data ...
相关推荐
以上就是关于在iOS应用中封装打电话、发短信和发邮件功能的基本方法。通过这样的封装,你可以在项目中创建一个统一的工具类,提高代码复用性和维护性。不过,始终要确保遵循Apple的App Store审核指南,特别是关于...
在iOS开发中,调用打电话、发送短信、发送邮件以及打开浏览器是常见的功能需求,尤其在构建用户交互丰富的应用程序时。这些功能使得应用能够更好地与系统服务集成,提供便捷的用户体验。下面将详细讲解如何在iOS6及...
IOS源码实现了: 1)打电话:用户在初始化该类后,调用打电话的方法,传入相应参数,即可完成调用系统打电话的功能。 2)发短信:用户在初始化该类后,调用发短信的方法,传入相应参数,即可完成调用系统发短信功能...
操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络...
在iOS应用开发中,实现程序内打电话和发送短信的功能,主要涉及到系统提供的接口调用,这一过程需要遵循Apple的App Store审核指南,并确保用户隐私安全。以下是对这一知识点的详细阐述: 1. **打电话功能**: iOS...
至于发短信功能,iOS提供了`sms:`URL Scheme,与拨打电话类似,但iOS不会提供发送短信的确认对话框,而是直接跳转到短信应用。然而,由于隐私和安全原因,Apple建议不要直接触发短信发送,而是让用户在短信应用中...
读取短信功能在iOS中受到严格的隐私限制,除非用户明确授权,否则应用无法直接访问短信内容。然而,你可以使用`MFMessageComposeViewController`来让用户发送新短信或回复现有短信。创建并配置这个视图控制器: ```...
1、调用 自带mail ... 2、调用 电话phone [[UIApplication sharedApplication] openURL:... iOS应用内拨打电话结束后返回应用 一般在应用中拨打电话的方式是: [[UIApplication sharedApplication] openUR
与打电话类似,通过创建一个包含收件人号码的URL(如`sms:1234567890`),然后调用`openURL:`方法,可以触发系统的短信应用并填充收件人。如果需要添加预设的短信内容,可以在URL后面加上`&body=短信内容`。 3. **...
以上就是iOS中实现打电话、发短信、发邮件和发送QQ消息的基本步骤。在实际开发中,还需要考虑到权限请求、错误处理以及用户体验等方面的细节。例如,发送短信和邮件需要用户授权,而拨打电话可能涉及隐私问题。此外...
在标题“iOS设备通讯录获取,及其他小功能”中,我们可以理解到,这个项目不仅实现了获取并打印设备通讯录的功能,还包含了其他实用的小功能,如调用系统电话、发送短信、打开浏览器等。 首先,让我们详细了解一下...
在这个项目中,我们可以看到`ZHContactManager`如何帮助开发者实现这些功能,并且结合实际操作如打电话、发送短信和邮件,提升用户体验。 首先,`ZHContactManager`提供了一个简单易用的接口来选择用户设备中的联系...
快速实现 发短信,发邮件,打电话 功能,无需更多代码,一行足矣! Usage 注意: 需要导入系统框架:MessageUI.framework 项目中添加工具类: LZXCommunication.h & LZXCommunication 导入 LZXCommunication.h 调用...
首先,我们来看如何实现打电话的功能。在iOS中,可以使用`UIApplication`的`openURL:`方法来启动电话拨号器。这个方法会尝试打开指定的URL,如果该URL的格式为tel:号码,系统就会自动启动电话应用并拨打该号码。例如...
3. **打电话**:拨打电话通常需要访问系统的拨号器功能,可能通过Intent启动系统的拨号应用,或者在某些情况下,直接通过底层通信库实现。在Android中,可以使用Intent ACTION_DIAL或ACTION_CALL来实现。 至于压缩...
例如,Android和iOS的API差异,以及如何在Web应用或跨平台框架(如React Native、Flutter)中实现短信功能。 7. **错误处理与异常**:由于网络环境、运营商限制或用户权限问题,短信收发可能会失败。因此,良好的...
下面我们将详细探讨这些技术及其在打电话、发信息、发邮件、访问AppStore、使用社交平台如微信、QQ、微博以及支付宝等场景中的应用。 1. URL Scheme:这是一种早期的iOS应用间通信方式,每个应用可以定义自己的URL ...
- **打电话**: 介绍如何在应用内拨打电话。 - **使用Safari**: 演示如何在应用中打开网页。 - **发送短信和电子邮件**: - 发送短信: 如何实现短信发送功能。 - 发送电子邮件: 如何在应用内发送邮件。 - **在应用...
一款可以支持获取本地通讯录信息的功能,该效果实现了在一些应用中获取本地通讯录的信息,并且还可以对通讯录的信息进行修改、添加、删除等操作,同时也可以调用发短信、打电话功能等。另外用户还可以在本地通讯录所...
1. **调用系统打电话功能**:在iOS中,拨打电话通常通过`Telprompt`类或`UIApplication`的`openURL:`方法来实现。NMTel可能使用了`tel:`协议来触发系统电话应用,例如`[[UIApplication sharedApplication] openURL:...