如何从我当前的应用程序调用消息应用程序 我知道要使用这段代码......
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];
或
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
@"sms:1-408-555-1212"]];
但我想要的只是打电话给消息应用程序,我不希望电话没有或没有电话号。
只想打开当前的消息应用视图
请帮帮我......
答案 0 :(得分:2)
MFMessageComposeViewController *messagComposer = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
messagComposer.messageComposeDelegate = self;
messagComposer.recipients = recipientsArray; // here give array of recipints
messagComposer.body = @"Some text";
[self presentModalViewController:picker animated:YES];
}
尝试这样发送消息
答案 1 :(得分:0)
试试这个::
在项目中导入 MessageUI 框架。
<。>在.h文件中,#import <MessageUI/MessageUI.h>
发送短信的呼叫方法: [self SendSMS:@"YOUR_MESSAGE" recipientList:ARRAY_OF_RECIPIENTS];
此处,您没有任何收件人,然后将数组作为 nil
传递。
方法::
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
[controller release];
}
消息框架方法::
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Status:" message:@"" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
switch (result) {
case MessageComposeResultCancelled:
alert.message = @"Cancelled";
break;
case MessageComposeResultFailed:
alert.message = @"Failed";
break;
case MessageComposeResultSent:
alert.message = @"Send";
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
[alert show];
[alert release];
}
希望,它会帮助你。
感谢。