我是iPhone新手。我想通過一些額外的SMS細節字符串。我正在使用下面的代碼發送短信到特定的號碼,但如果我想用SMS字符串發送一些數據,那我該怎麼辦?有誰能告訴我這種格式嗎?用數據發送短信
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://9016098909891"]];
我是iPhone新手。我想通過一些額外的SMS細節字符串。我正在使用下面的代碼發送短信到特定的號碼,但如果我想用SMS字符串發送一些數據,那我該怎麼辦?有誰能告訴我這種格式嗎?用數據發送短信
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://9016098909891"]];
您可以在app短信功能使用,你可以設置你的短信文本體..
第1步:將MessageUI Framework導入到您的項目中並導入頭文件#import <MessageUI/MessageUI.h>
第2步:發送短信如下
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
controller.body = @"Hello from Mugunth";
controller.recipients = [NSArray arrayWithObjects:@"12345678", @"87654321", nil];
controller.messageComposeDelegate = self;
controller.delegate = self;
[self presentModalViewController:controller animated:YES];
}
第3步:辦理代表爲
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
case MessageComposeResultCancelled:
NSLog(@"Cancelled");
break;
case MessageComposeResultFailed:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"Unknown Error"
delegate:self cancelButtonTitle:@」OK」 otherButtonTitles: nil];
[alert show];
[alert release];
break;
case MessageComposeResultSent:
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
}
看到這裏http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/
的SMS
URL方案不提供填充所述SMS體的任何裝置。因此,你只能預填充短消息服務選項是使用MFMessageComposeViewController
您可以設置使用消息框架的文本郵件正文,你將需要添加到了框架。將#import <MessageUI/MessageUI.h>
添加到導入列表。
確保視圖控制器執行MFMessageComposeViewControllerDelegate
,這是需要關閉MFMessageComposeViewController
。然後,在將顯示消息作曲家地方這種代碼的方法
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
[controller dismissModalViewControllerAnimated:YES];
}
:
的爲MFMessageComposeViewControllerDelegate
實施
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
messageController.body = @"Your message here.";
messageController.recipients = [NSArray arrayWithObject:@"9016098909891"];
[self presentModalViewController:messageController animated:YES];
[messageController release], messageController = nil;
文章請點擊此鏈接: –
2012-04-23 07:51:43