![](/img/trans.png)
[英]MessageComposeResultFailed When this case fire below code
[英]At which case the MessageComposeResultFailed is fired for MFMessageComposeController in iOS?
MFMessageComposeViewController的didFinishWithResult委托方法显示消息发送成功,即使设备处于飞行模式或设备没有SIM卡,但消息发送失败。委托没有go通过失败state。为什么没有它 go 到故障 state?请给我一些建议。 代码如下:
- (void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
// You can specify one or more preconfigured recipients. The user has
// the option to remove or add recipients from the message composer view
// controller.
/* picker.recipients = @[@"Phone number here"]; */
// You can specify the initial message text that will appear in the message
// composer view controller.
picker.body = @"Hello from California!";
[self presentViewController:picker animated:YES completion:NULL];
}
DELEGATE 方法如下:
// -------------------------------------------------------------------------------
// messageComposeViewController:didFinishWithResult:
// 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
{
self.feedbackMsg.hidden = NO;
// Notifies users about errors associated with the interface
switch (result)
{
case MessageComposeResultCancelled:
self.feedbackMsg.text = @"Result: SMS sending canceled";
break;
case MessageComposeResultSent:
self.feedbackMsg.text = @"Result: SMS sent";
break;
case MessageComposeResultFailed:
self.feedbackMsg.text = @"Result: SMS sending failed";
break;
default:
self.feedbackMsg.text = @"Result: SMS not sent";
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];
}
对我来说,当我按下“取消”或“发送”消息时,正确的代表会被解雇。 但是,当我打开 AIRPLANE 模式或没有 SIM 卡的设备时,仍然会触发MessageComposeResultSent
。 有人可以清楚地知道MessageComposeResultFailed
何时被触发吗? 有直播步骤吗? 请帮助我
根据MessageComposeResult
的文档,这种行为是有意义的:
case sent
The user successfully queued or sent the message.
委托方法可以报告MessageComposeResultSent
,即使您的应用所做的只是将消息发送给系统。 不能保证它确实发送了消息。
文档不清楚何时报告MessageComposeResultFailed
,但我想它是为了捕获可能发生的任何可能的错误。
根据您的特定用例,您可以在允许某人使用MFMessageComposeViewController
之前添加对蜂窝连接的检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.