调用系统短信发送
发送短信主要用到MessageUI和MFMessageComposeViewControllerDelegate
#import <MessageUI/MessageUI.h>
@interface ViewController () <MFMessageComposeViewControllerDelegate>
@end
@implementation ViewController
#pragma mark - SendMessage
- (void)sendUrgeMessage:(NSArray *)numberArray {
//群发短信
BOOL canSendSMS = [MFMessageComposeViewController canSendText];
if (canSendSMS) {
//创建系统短信ViewController
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.navigationBar.tintColor = [UIColor whiteColor];
//设置收信人
picker.recipients = numberArray;
//设置发送内容
NSString *textBody = @"亲~记得好评哦";
picker.body = textBody;
//弹出短信窗口
[self presentViewController:picker animated:YES completion:nil];
}else {
[UIAlertView showWithMessage:@"陛下的手机短信异常ヽ(•̀ω•́ )ゝ哟" delegate:nil];
}
}
#pragma mark - MFMessageComposeViewControllerDelegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
switch (result) {
case MessageComposeResultCancelled:
break;
case MessageComposeResultSent:
break;
case MessageComposeResultFailed:
break;
default:
break;
}
//收起发送框
[self dismissViewControllerAnimated:YES completion:nil];
}
@end