简体   繁体   English

如何使用数组中的数字发送SMS?

[英]How to send the SMS using number in an array?

I have stored the contact numbers in an array and then passed this array to message controller like the below code and printed the value of controller.recipients and its showing null. 我已经将联系电话存储在一个数组中,然后将此数组传递给消息控制器,如下面的代码,并打印controller.recipients的值及其显示为空。

  MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
  NSArray *arr = [NSArray arrayWithArray:selContacts];
  controller.recipients = arr;
 NSLog(@"received:- %@",controller.recipients);
 controller.messageComposeDelegate = self;
 controller.body =@"https://itunes.apple.com/in/app/Click Here to Download!";
    if([MFMessageComposeViewController canSendText])
    {
        [self presentModalViewController:controller animated:YES];
    }
if(![MFMessageComposeViewController canSendText])
{
    UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [warningAlert show];
    return;

}
NSArray *recipents = @[@"+919999999999"];
NSString *message = @"Enter message here!";
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
[messageController setRecipients:recipents];
[messageController setBody:message];
// Present message view controller on screen
[self presentViewController:messageController animated:YES completion:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM