Iphone 如何使用IOS模拟器以编程方式发送短信
我是triyng,想做一个可以使用IOS模拟器以编程方式发送短信的应用程序。 请告诉我步骤的顺序好吗。 什么是代码,我们如何使用它一步一步的细节Iphone 如何使用IOS模拟器以编程方式发送短信,iphone,ios,Iphone,Ios,我是triyng,想做一个可以使用IOS模拟器以编程方式发送短信的应用程序。 请告诉我步骤的顺序好吗。 什么是代码,我们如何使用它一步一步的细节 谢谢。Ios similator无法发送消息,但您可以使用此代码在divice中运行项目来发送消息 在项目中添加MessageUI框架 然后在.h文件中添加以下内容 #import <MessageUI/MessageUI.h> @interface MessageViewController : UIViewController<
谢谢。Ios similator无法发送消息,但您可以使用此代码在divice中运行项目来发送消息 在项目中添加MessageUI框架 然后在.h文件中添加以下内容
#import <MessageUI/MessageUI.h>
@interface MessageViewController : UIViewController<MFMessageComposeViewControllerDelegate>
- (IBAction)SendTextBtnTapped:(id)sender;
@end
- (IBAction)SendTextBtnTapped:(id)sender {
[self sendSMS:@"" recipientList:[NSArray arrayWithObjects: nil]];
}
//for sms
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = bodyOfMessage;
controller.recipients = recipients;
controller.messageComposeDelegate = self;
controller.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[self presentModalViewController:controller animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:YES];
if (result == MessageComposeResultCancelled)
NSLog(@"Message cancelled");
else if (result == MessageComposeResultSent)
NSLog(@"Message sent");
else
NSLog(@"Message failed");
}
你想通过任何网关发送短信,对吗?或者你想通过编程发送它?iOS模拟器不能发送短信..你能通过iOS模拟器发送短信吗?使用divice发送消息。但是他想通过iOS模拟器而不是设备发送短信。我在开始回答时说,他不能从模拟器发送消息,但使用此代码,他可以通过在divice中添加他的项目来发送消息。@Sudha没有办法发送消息从模拟器发送短信bcoz短信服务使用模拟器不包含的SIM信息中心。