iOS 中的 MFMessageComposeController 在哪种情况下会触发 MessageComposeResultFailed?
At which case the MessageComposeResultFailed is fired for MFMessageComposeController in iOS?
MFMessageComposeViewController的didFinishWithResult委托方法显示消息已发送成功,即使设备处于飞行模式或设备没有SIM,但消息发送失败。代表没有经历失败 state.Why 它不进入失败状态吗?请给我一些建议。代码如下:
MFMessageComposeViewController *pic = [[MFMessageComposeViewController alloc] init];
pic.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.
pic.body = @"Hello from California!";
[self presentViewController:pic 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
{
// Notifies users about errors associated with the interface
switch (result)
{
case MessageComposeResultCancelled:
//Cancelled
break;
case MessageComposeResultSent:
//Sent
break;
case MessageComposeResultFailed:
//Failed
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];
}
对我来说,当我按下“取消”或“发送”消息时,正确的代表被解雇了。但是当我打开 AIRPLANE 模式或没有 SIM 卡的设备时,MessageComposeResultSent
仍然被触发。有人可以清楚地告诉 MessageComposeResultFailed
什么时候被解雇吗?有活步吗?请帮助我
根据 docs for MessageComposeResult
:
这种行为是有意义的
case sent
The user successfully queued or sent the message.
委托方法可以报告 MessageComposeResultSent
即使您的应用所做的只是将消息交给系统发送。不能保证它确实发送了消息。
文档不清楚它何时报告 MessageComposeResultFailed
,但我想它是为了捕获可能发生的任何可能的错误。
根据您的特定用例,您可以在允许某人使用 MFMessageComposeViewController
.
之前添加蜂窝连接检查
MFMessageComposeViewController的didFinishWithResult委托方法显示消息已发送成功,即使设备处于飞行模式或设备没有SIM,但消息发送失败。代表没有经历失败 state.Why 它不进入失败状态吗?请给我一些建议。代码如下:
MFMessageComposeViewController *pic = [[MFMessageComposeViewController alloc] init];
pic.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.
pic.body = @"Hello from California!";
[self presentViewController:pic 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
{
// Notifies users about errors associated with the interface
switch (result)
{
case MessageComposeResultCancelled:
//Cancelled
break;
case MessageComposeResultSent:
//Sent
break;
case MessageComposeResultFailed:
//Failed
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];
}
对我来说,当我按下“取消”或“发送”消息时,正确的代表被解雇了。但是当我打开 AIRPLANE 模式或没有 SIM 卡的设备时,MessageComposeResultSent
仍然被触发。有人可以清楚地告诉 MessageComposeResultFailed
什么时候被解雇吗?有活步吗?请帮助我
根据 docs for MessageComposeResult
:
case sent
The user successfully queued or sent the message.
委托方法可以报告 MessageComposeResultSent
即使您的应用所做的只是将消息交给系统发送。不能保证它确实发送了消息。
文档不清楚它何时报告 MessageComposeResultFailed
,但我想它是为了捕获可能发生的任何可能的错误。
根据您的特定用例,您可以在允许某人使用 MFMessageComposeViewController
.