Pregunta

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?

¿Fue útil?

Solución

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];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top