iMessage群发短信代码(不带验证)

记得要继承MFMessageComposeViewControllerDelegate协议
 if (phoneNum!=nil&&![phoneNum isEqualToString:@""])
        {
            if (phoneNum.length>13) {
                phoneNum= [phone substringToIndex:11];//截取下标11之前的字符串
            }
            send_index=0;
            MFMessageComposeViewController *picker =[[MFMessageComposeViewController alloc] init];
                
            if ([MFMessageComposeViewController canSendText])
            {
                picker.messageComposeDelegate = self;
                NSMutableArray *substrings = [NSMutableArray array];
                [substrings addObject:storeinfoModel.storetel];
                [substrings addObject:@"13806512943"];//可添加多个电话号码,群发
                [picker setRecipients:substrings];
                NSString *menuStr=@"";
                NSMutableArray *foodsarray=[storesArray objectAtIndex:0];
                for(int z=0; z<foodsarray.count; z++)
                {
                    NewCartModel * objectValue = [foodsarray objectAtIndex:z];
                    menuStr = [menuStr stringByAppendingFormat:@"%@X%i  ",objectValue.name, objectValue.num];
                }
                menuStr=[menuStr stringByAppendingFormat:@"送到:%@",self.dizhiTextField.text];
                [picker setBody:menuStr];
                [self presentModalViewController:picker animated:YES];
                }
        }
实现MFMessageComposeViewControllerDelegate中的方法
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
                 didFinishWithResult:(MessageComposeResult)result {
    
    [controller    dismissModalViewControllerAnimated:YES];
    if (result==MessageComposeResultSent)
    {
	//表示短信发送成功,另外几种状态可查看文档
    }
}


你可能感兴趣的:(iMessage群发短信代码(不带验证))