Ios – How to send In-App SMS in iphone

iosiphonesms

M working on as messenger App .
i want to sent automatically sms on my client as a verification code and user can use that code as a verification code ..
Can any one help me how to sent sms automatically on my client

Ex.

If user click on register at that time he/she will get conformation sms automatically from iphone client .
That what i need to implement ..

Thanks

Best Answer

You can't send an SMS automatically from iOS, you can present the user with the SMS view and pre fill the SMS body.

You will find more on how the use the MFMessageComposeViewController here: http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMessageComposeViewController_class/Reference/Reference.html

- (void) sendSMSCode:(NSString *)smsCode {
    MFMessageComposeViewController *viewController = [[MFMessageComposeViewController alloc] init];
    viewController.messageComposeDelegate = self;

    [viewController setBody:smsCode];
    // Replace with the number to send the SMS so
    [viewController setRecipients:[NSArray arrayWithObject:@"+123456789"]];
    [self presentModalViewController:viewController animated:YES];
    [viewController release], viewController = nil;
}

#pragma mark - MFMessageComposeViewController methods

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {

    [controller dismissModalViewControllerAnimated:YES];

    if (result == MessageComposeResultFailed) {
             // handle the error.
    }
}