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. 編程方式發送短信的Android(不接收狀態)
- 4. 發送和接收短信
- 5. 對於iOS,您可以以編程方式強制通過MMS發送短信
- 6. 如何以編程方式將短信作爲附件發送給短信?
- 7. 以編程方式發送短信 - 設置過期
- 8. 以編程方式在Windows Phone 8中發送短信
- 9. iphone 4.0以編程方式發送短信
- 10. 如何以編程方式發送短信?
- 11. 以編程方式發送短信代碼問題
- 12. 如何在黑莓中以編程方式發送短信
- 13. 無法在android中以編程方式發送短信
- 14. 應用程序發送多個短信接收電話/短信
- 15. 發送短信給收件人iOS
- 16. Android:以同步方式發送短信
- 17. 發送和接收短信和開發短信面板
- 18. 發送短信的廣播接收器
- 19. 發送短信給接收者
- 20. 使用Twilio發送和接收短信
- 21. 發送和接收Google短信SMS VB.NET
- 22. AT命令發送/接收短信
- 23. 發送長短信並接收錯誤
- 24. 通過PSTN發送和接收短信
- 25. 通過Arduino發送/接收短信
- 26. Kannel:無法發送或接收短信
- 27. Android:如何通過短信發送和接收數據
- 28. 短信網關發送和接收尼日利亞短信
- 29. wp7短信發送接收和短信攔截器
- 30. 如何發送短信並在iPhone sdk中接收短信?