在iPhone上以编程方式发送短信

在iPhone上以编程方式发送短信

问题描述:

在我的应用程序中,我想在特定事件中将预定义的smstext发送到一个数字, 如何发送这样的短信?

in my application I want to send predefine smstext to one single number on certain event , how to send sms like that?

在没有用户干预的情况下,您无法发送SMS.但是,通过用户的批准",有两种方法可以从iPhone应用程序发送短信.

You cannot send an SMS without user intervention. However, with the user's "approval" there are two ways to send an SMS from an iPhone application.

  1. Apple的 MessageComposer 示例项目中的代码向您展示了如何使用MFMessageComposeViewController类发送SMS.
  2. 或者,您可以使用:

  1. Apple's MessageComposer sample project has code that shows you how to send an SMS using the MFMessageComposeViewController class.
  2. Alternatively, you can use:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:1-408-555-1212"]];