1.首先遵循代理:
MFMessageComposeViewControllerDelegate,MFMailComposeViewControllerDelegate
2.写入下面的方法
- (void)sendMessage:(NSString*)mobile
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
NSString *descriptionStr = [NSString stringWithFormat:@"去旅游就选人人票,我是yangchao,我为人人票代言,下载地址:阿拉啦啦啦啦啦啦啦啦拉了拉"];
controller.body = descriptionStr;
controller.messageComposeDelegate = self;
controller.recipients = [NSArray arrayWithObject:mobile];
[self presentViewController:controller animated:YES completion:^(void) {}];
}
}
3.调用sendSMS函数
//内容,收件人列表
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:^(void) {}];
}
}
4.处理发送完的响应结果
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissViewControllerAnimated:YES completion:^(void) {}];
}
5.所有的方法有了需要调用,不然不起作用
[self sendMessage:这里是电话号码];