-2

I'm using the following code to send in-app sms.

NSString *message = @"this ia the message";
MFMessageComposeViewController *TextSheet = ([MFMessageComposeViewController alloc]);
TextSheet.messageComposeDelegate = self;
[TextSheet setBody:message];
TextSheet.recipients = [NSArray arrayWithObjects:@"0549999999", @"0548888888", nil];
[self presentViewController:TextSheet animated:YES completion:Nil];

I try it on a real device iPhone 5C with IOS 7 and its shows a black screen only. What am I doing wrong?

Chana
  • 123
  • 1
  • 8
  • 6
    ([MFMessageComposeViewController alloc]); never do alloc without init ! probably this will solve the problem – Julian Jan 21 '14 at 12:53

1 Answers1

1

You have a couple of issues in your code - most importantly, you're not initializing your MFMessageComposeViewController correctly. You need to call alloc and init.

MFMessageComposeViewController *textSheet = [[MFMessageComposeViewController alloc] init];

You could also tidy up your recipients list by using a literal array:

textSheet.recipients = @[ @"0549999999", @"0548888888" ];

Finally, your nil that you're passing for the completion block should not be capitalized:

[self presentViewController:textSheet animated:YES completion:nil];
James Frost
  • 6,960
  • 1
  • 33
  • 42