iOS应用发送SMS短消息代码

2021-11-01 09:18:35 浏览数 (2)

代码语言:javascript复制
//Import the MessageUI Framework into your project and 
//#import the header file into the “.h” file of your controller 
//where you want to open the In-App SMS sheet.
-(IBAction) sendInAppSMS:(id) sender
{
    MFMessageComposeViewController *controller =
        [[[MFMessageComposeViewController alloc] init] autorelease];
    if([MFMessageComposeViewController canSendText])
    {
        controller.body = @"Hello from Mugunth";
        controller.recipients = [NSArray arrayWithObjects:
                @"12345678", @"87654321", nil];
        controller.messageComposeDelegate = self;
        [self presentModalViewController:controller animated:YES];
    }
}

0 人点赞