1

我一直致力于在我的应用程序中实现 SMS 消息传递。不幸的是,每当我测试它时,我总是得到默认结果,即使它确实发送了消息并且我在另一端收到了它。我做错了什么,我比较了其他例子,我的看起来一样。这适用于 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]; 
        }
    }
}   
4

1 回答 1

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;
}
于 2011-10-22T17:21:20.300 回答