IOS问题汇总:2015-1-9 iOS 调用系统发短信以及打电话功能

iOS 调用系统发短信以及打电话功能

ios电话smsinterface互联网class
先介绍一种最简单的方法:

调用打电话功能

[[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以上才支持程序内发送短信

}

}

时间: 2024-08-01 22:47:57

IOS问题汇总:2015-1-9 iOS 调用系统发短信以及打电话功能的相关文章

IOS 调用系统发短信以及打电话的功能

IOS 调用系统发短信以及打电话的功能 http://blog.csdn.net/lwq421336220/article/details/7818979 先介绍一种最简单的方法: 调用打电话功能 [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]]; 调用发短信功能 [[UIApplication sharedApplication]openURL:[NSURL URLWithS

iOS调用系统发短信功能详解

iOS调用系统的发短信功能可以分为两种:1,程序外调用系统发短信.2,程序内调用系统发短信.第二种的好处是用户发短信之后还可以回到app.这对app来说非常重要. 程序外调用系统发短信 这个方法其实很简单,直接调用openURL即可: [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"sms://13888888888"]]; 程序内调用系统发短信 1)导入MessageUI.framework,并引入头文

调用系统发短信的功能

来自为知笔记(Wiz)

iOS 之(调用系统发送短信功能)

今天处理一个订单详情的界面,在订单详情页面上有联系方式(电话号码),在电话号码的右边有两图片,一个是电话样式的,一个是短信样式的,做为一名程序员(号称攻城师)一眼看下去就应该是一个 button,而不是 imageView ,既然是 button 那就应该是打电话和发短信的,这样一来的话,当我们点击短信的这个 button 时,就应该调用系统发短信的界面,下面先来看看效果图与需求:       这篇随笔主要是记录总结发短信的代码,打电话迟点更新 下面来看调用系统发短信的实现代码 老规矩,新建一个

iOS基本的发短信和打电话调用

电话.短信是手机的基础功能,iOS中提供了接口,让我们调用.这篇文章简单的介绍一下iOS的打电话.发短信在程序中怎么调用. 1.打电话 [cpp] view plain copy print? [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10010"]];//打电话 使用openURL这个API打电话结束后,返回的是系统的拨打电话界面,如何才能返回自己的应用呢?有两种方法与大家分享. 第

iOS中如何切换到发短信、打电话、发邮件

我们在做APP的时候,难免会遇到需要调用短信,电话等程序的时候.如美团. 当然,这些都只是一些简单的方法就可以实现,但是时间久了也会淡忘,所以想写这边博客.一是为了再捡起来复习一下,另一个相当于留个备份,以后忘了,自己也可以捡起来看看. 首先,说说如何调用浏览器打开网页. 当然这个就很简单了,只需要短短两句话就可以实现 NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"]; // [[UIApplication share

python 调用接口发短信

调用接口发送短信 此处接口是移动云nas """ Create_of_date:2020-03-08 Author:nod description: 调用移动云mas接口 exchange_date author exchange """ from flask import request, Flask, jsonify import hashlib import base64 import json import requests url='h

Delphi调用极光发短信nethttpclient

xe8以上版本使用 vHttp := TNetHTTPClient.Create(nil); vList := TStringList.Create; vS := TStringStream.Create; try Memo1.Lines.Add('----------------Post阻塞----------------'); vS.Clear;with vHttp do begin ConnectionTimeout := 2000; // 2秒 ResponseTimeout := 10

调用打电话发短信

iOS 调用系统发短信以及打电话功能 分类: iOS 短信 电话 2012-08-01 16:29 13092人阅读 评论(0) 收藏 举报 ios电话smsinterface互联网class 先介绍一种最简单的方法: 调用打电话功能 [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]]; 调用发短信功能 [[UIApplication sharedApplication]open