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];
}
}
}
尝试检查,看看有什么你的结果实际上是......'default'只是一个全面的情况,如果switch参数与任何情况都不匹配,那么它将被执行。 –
您是否测试过您是否可以发送短信? Doc:在呈现消息组合视图之前,调用canSendText类方法以确保用户的设备已正确配置。如果canSendText方法返回NO,则不要尝试呈现消息组合视图。如果短信传送不可用,您可以通知用户或者简单地禁用应用程序中的SMS功能。 – jbat100
我已经有应用程序中的东西来捕捉它不能发送短信。我如何打印出真正的结果。 –