3

I am trying to have users send a phone verification text via SMS. The first time they try sending the message to a number, it looks like the message goes through and we get a callback with MessageComposeResultSent. However, no message actually is queued or sent. Taking a look in iMessage, there is a record of the phone number at the top of the list but no message, just a blank screen. If the SMS is tried again to the same number, it goes through. The implementation seems pretty simple, so not sure if this is a bug or if I am doing something wrong.

Here is our code:

MFController = [[MFMessageComposeViewController alloc] init];

if([MFMessageComposeViewController canSendText])
{

    self.MFController.body = [NSString stringWithFormat:@"Please send this message to verify your phone number.\n\n(%@)",token];
    self.MFController.recipients = [NSArray arrayWithObject:@"+PHONENUMBER"];
    self.MFController.messageComposeDelegate = self;    
    [self presentViewController:MFController animated:YES completion:nil];
}

I've tried declaring MFController directly in the method, as an ivar, strong property. I've also tried initializing MFController in ViewDidLoad to no avail.

Update: I'm not alone here. A lot more recent posts on the Apple Dev Forum. If anyone has a creative work-around, please post!

Also, restarting the phone seems to resolve the issue for most users, however we have no way of handling the failure to send because we are receiving a MessageComposeResultSent result.

MattDiep
  • 111
  • 6

1 Answers1

0

Are you conforming the delegate?

if you created the instance as property the access it via self,

self.MFController = [[MFMessageComposeViewController alloc] init];

    if([MFMessageComposeViewController canSendText])
    {

        self.MFController.body = [NSString stringWithFormat:@"Please send this message to verify your phone number.\n\n(%@)",token];
        self.MFController.recipients = [NSArray arrayWithObject:@"+PHONENUMBER"];
        self.MFController.messageComposeDelegate = self;    
        [self presentViewController:self.
MFController animated:YES completion:nil];
    }

Let me know if it works.

Sanoj Kashyap
  • 5,020
  • 4
  • 49
  • 75