我一直致力于在我的应用中实现短信。不幸的是,每当我测试它时,我总是得到默认结果,即使它确实发送了消息而我在另一端收到它。我做错了什么,我比较了其他的例子,我的看起来是一样的。 这适用于iMessage ???现在我总是按照发送的方式获取它,即使我进入短信,也会说失败。
// feedback message field with the result of the operation.
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result {
switch (result)
{
case MFMailComposeResultCancelled:
[self displayStickieUniversalViewControllerTitleString:@"Cancelled" bodyString:@"You cancelled sending the SMS.The event will be saved in the calendar." buttonString:@"Ok, Save Event" bodyTextSize:12.0f buttonTextLines:3];
break;
case MFMailComposeResultSent:
[self displayStickieUniversalViewControllerTitleString:@"SMS sent" bodyString:@"Your SMS was sent. The event will be saved in the calendar." buttonString:@"Ok, Save Event" bodyTextSize:12.0f buttonTextLines:3];
break;
case MFMailComposeResultFailed:
[self displayStickieUniversalViewControllerTitleString:@"Failed" bodyString:@"Failed to send SMS. The event will be saved in the calendar." buttonString:@"Ok, Save Event" bodyTextSize:12.0f buttonTextLines:3];
break;
default:
[self displayStickieUniversalViewControllerTitleString:@"Failed" bodyString:@"Failed to send SMS. The event will be saved in the calendar." buttonString:@"Ok, Save Event" bodyTextSize:12.0f buttonTextLines:3];
break;
}
[self dismissModalViewControllerAnimated:YES];
}
/////
if (actionClicked == @"smsEvent") {
if ([attendeesArray count]!=0) {
NSLog(@"Yes clicked, will send sms confirmation");
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if (messageClass != nil) {
if ([messageClass canSendText]) {
[self displaySMSComposerSheet];
}
else {
[self displayStickieUniversalViewControllerTitleString:@"Device not configured to send SMS." bodyString:@"The event will be saved in the calendar." buttonString:@"Save Event" bodyTextSize:14.0f buttonTextLines:2];
}
}
else {
[self displayStickieUniversalViewControllerTitleString:@"Device not configured to send SMS." bodyString:@"The event will be saved in the calendar." buttonString:@"Save Event" bodyTextSize:14.0f buttonTextLines:2];
}
}
}
答案 0 :(得分:0)
看起来你正在使用错误的枚举可能与它有关,我的看起来像这样:
switch (result)
{
case MessageComposeResultCancelled:
break;
case MessageComposeResultSent:
break;
case MessageComposeResultFailed:
break;
default:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SMS" message:@"Sending Failed - Unknown Error :-("
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}
break;
}