- 浏览: 884487 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (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 1867//sdk中提供了方法可以直接调用 UIImage *im ... -
update cocapods
2014-05-17 22:27 762早上更新cocoapod依赖库,发现更新到32.1版本,早先的 ... -
iOS发送短信息代码实例
2014-05-16 18:15 2626#import <MessageUI/Message ... -
DISPATCH TIMER
2014-05-14 16:12 665/* __block void (^callback) ... -
UITextField左边显示图片
2014-05-13 18:08 1099The overlay view displayed on t ... -
iOS面试题
2014-05-09 16:10 10351.写一下UIButton与UITableView的层级结构 ... -
socket二进制报文
2014-05-09 15:18 1240里面有帧头 字符串UTF-8 中间用0隔开 又一个字符串 ... -
将网站添加到桌面的方法
2014-05-08 14:25 1618<link href="http://www. ... -
iPhone通讯录联系人操作大全
2014-05-07 10:29 13951.需要引入AddressBook.framework框架 2 ... -
sqlite获取最新插入的rowid
2014-05-07 09:59 1468除了 last_insert_rowid select max ... -
号码归属地查询,拨打电话
2014-05-06 15:07 793在程序内调用拨打电话的方法,[[UIApplication s ... -
iOS时间合并
2014-04-28 17:55 1012合并同一时间的课程,同一时间可能有多个课程,比如13:30-1 ... -
vCard通讯录格式说明
2014-04-28 16:47 2418原帖:http://freesoftman.iteye.com ... -
UISearchBar背景色全套解决方案
2014-04-25 09:36 7387os系统升级到7.1后,原来在7.0下显示正常的UISearc ... -
升级XCode5.1.1遇到的奇葩问题NSString,NSObjectRuntime.h报错,Foundation找不到
2014-04-24 11:19 849升级XCode5.1.1遇到的奇葩问题NSString,NSO ... -
将NSString转为NSArray
2014-04-22 16:52 6226// Your JSON data: NSString *c ... -
另外一种NSData转为NSString的方法
2014-04-22 15:40 1163If the data is not null-termina ... -
HTTP,Socket,WebSocket异同
2014-04-18 16:54 1784参考文章: http://abbshr.g ... -
push隐藏UINavigtaionBar和UITabbar
2014-04-17 15:20 1039[self.navigationController setN ... -
数据库SQL
2014-04-11 13:31 8571、说明:创建数据库 CREATE DATABASE data ...
相关推荐
在ios的程序内部实现打电话发短信 调用系统接口
传智播客iOS6免费公开课程-调用打电话发短信发邮件打开浏览器
IOS源码实现了: 1)打电话:用户在初始化该类后,调用打电话的方法,传入相应参数,即可完成调用系统打电话的功能。 2)发短信:用户在初始化该类后,调用发短信的方法,传入相应参数,即可完成调用系统发短信功能...
操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络...
ios开发获取手机唯一标识符和调用系统打电话拨号功能
1、调用 自带mail ... 2、调用 电话phone [[UIApplication sharedApplication] openURL:... iOS应用内拨打电话结束后返回应用 一般在应用中拨打电话的方式是: [[UIApplication sharedApplication] openUR
真机运行,会打印出设备的通讯录,没做表格来显示,所以模拟器运行没效果,还有其他的附加功能如调用系统电话,发短信,浏览器等等。还做了一个for循环实现button排列的简单测试和代理实现页面传值等功能
快速实现 发短信,发邮件,打电话 功能,无需更多代码,一行足矣! Usage 注意: 需要导入系统框架:MessageUI.framework 项目中添加工具类: LZXCommunication.h & LZXCommunication 导入 LZXCommunication.h 调用...
此demo是通过调用系统方法来实现打电话和发短信功能
NMTel写的第一个app,是为了纽迈通讯录有个iOS版。可以调用系统打电话发短信功能,可以添加删除移动联系人等。
ZHContactManager - 通讯录操作:选择联系人、添加新联系人、添加到现有联系人;打电话、发短信、发邮件
一款可以支持获取本地通讯录信息的功能,该效果实现了在一些应用中获取本地通讯录的信息,并且还可以对通讯录的信息进行修改、添加、删除等操作,同时也可以调用发短信、打电话功能等。另外用户还可以在本地通讯录所...
6个目标文件,EJB来模拟银行ATM机的流程及操作:获取系统属性,初始化JNDI,取得Home对象的引用,创建EJB对象,并将当前的计数器初始化,调用每一个EJB对象的count()方法,保证Bean正常被激活和钝化,EJB对象是用...
6个目标文件,EJB来模拟银行ATM机的流程及操作:获取系统属性,初始化JNDI,取得Home对象的引用,创建EJB对象,并将当前的计数器初始化,调用每一个EJB对象的count()方法,保证Bean正常被激活和钝化,EJB对象是用...
来源:github/RHAddressBookLicence:MIT作者:Richard Heard 在应用中获取本地通讯录(AddressBook...也可以调用发短信、打电话功能。用户在本地通讯录所做的一切改动,会给RHAddressBook发送NSNotifications通知。