1
A
回答
0
import
#import <MessageUI/MessageUI.h>
<MFMessageComposeViewControllerDelegate,MFMailComposeViewControllerDelegate>
-(void)send_SMS{
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil) {
// Check whether the current device is configured for sending SMS messages
if ([messageClass canSendText]) {
[self displaySMSComposerSheet];
}
else {
// feedbackMsg.hidden = NO;
// feedbackMsg.text = @"Device not configured to send SMS.";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Device not configured to send SMS." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call",nil];
//[alert setTag:5];
[alert show];
}
}
else {
// feedbackMsg.hidden = NO;
// feedbackMsg.text = @"Device not configured to send SMS.";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Device not configured to send SMS." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call",nil];
//[alert setTag:5];
[alert show];
}
}
// Displays an SMS composition interface inside the application.
-(void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
[email protected]"Testing";
picker.recipients = [NSArray arrayWithObject:@"12345678"];
[self presentModalViewController:picker animated:YES];
}
// Dismisses the message composition interface when users tap Cancel or Send. Proceeds to update the
// feedback message field with the result of the operation.
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result {
feedbackMsg.hidden = NO;
// Notifies users about errors associated with the interface
switch (result)
{
case MessageComposeResultCancelled:{
//feedbackMsg.text = @"Result: SMS sending canceled";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"SMS sending canceled" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
break;
case MessageComposeResultSent:{
//feedbackMsg.text = @"Result: SMS sent";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"SMS sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
break;
case MessageComposeResultFailed:{
//feedbackMsg.text = @"Result: SMS sending failed";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"SMS sending failed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
break;
default:
{
//feedbackMsg.text = @"Result: SMS not sent";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"SMS not sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
break;
}
[self dismissModalViewControllerAnimated:YES];
}
相關問題
- 1. 以編程方式接收短信
- 2. Xcode:以編程方式發送短信
- 3. 如何以編程方式將短信作爲附件發送給短信?
- 4. 應用程序發送多個短信接收電話/短信
- 5. 如何以編程方式發送短信?
- 6. 以編程方式發送短信代碼問題
- 7. 無法在android中以編程方式發送短信
- 8. 如何以編程方式發送免費短信?
- 9. iphone 4.0以編程方式發送短信
- 10. Android:以同步方式發送短信
- 11. 發送和接收短信和開發短信面板
- 12. 發送和接收Google短信SMS VB.NET
- 13. Kannel:無法發送或接收短信
- 14. 發送短信給接收者
- 15. 通過Arduino發送/接收短信
- 16. 發送短信的廣播接收器
- 17. Android:如何通過短信發送和接收數據
- 18. 如何發送短信並在iPhone sdk中接收短信?
- 19. 短信網關發送和接收尼日利亞短信
- 20. 在android中發送獨特的短信和接收looong短信
- 21. 用數據發送短信
- 22. 如何在iPhone中以編程方式獲取發送和接收的短信細節?
- 23. 在iOS發送短信
- 24. 有沒有免費的服務以編程方式發送短信?
- 25. 以編程方式通過Android App向特定號碼發送短信
- 26. 使用您的個人移動帳戶以編程方式發送短信息?
- 27. 以編程方式發送短信時獲取用戶輸入文本
- 28. 發送和接收短信therough Web應用程序
- 29. 您可以直接在cURL中發送短信/短信嗎?
- 30. 以編程方式發送帶有PDU格式的sms與PDU格式的連接短信