8

我有一个应用程序,用户可以在其中选择图像并将其发送给朋友,方法是将图像附加到 MFMessageComposeViewController 的实例。在 MFMCVC 视图中按下发送后,有时事情会按预期工作——带有图像的消息已成功发送给收件人,或者在本机 iMessage 客户端中的消息旁边显示“消息失败”标签(但在在这两种情况下,图像在本机客户端中都是可见的)。但是,在按下发送后大约一半的时间会出现一个错误(在运行 iOS 7 的 iPhone 4 上)。信息——依恋和一切——消失了,再也见不到了。收件人永远不会收到消息,并且它不会出现在 iMessage 中发件人的消息通道中。

我相当确定这是 Apple 的 MFMessageComposeViewController 本身的一个错误,因为 API 非常简单,而且我能够在单独的演示应用程序中可靠地重现该错误https://github.com/timcour/mf-message-compose-失败演示.git

- (void)displaySMSComposerSheet
{
    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
    picker.messageComposeDelegate = self;

    NSData *data = [_imageDataCache objectForKey:[_imageURLs objectAtIndex:_currentIndex]];
    [picker addAttachmentData:data
               typeIdentifier:(NSString *)kUTTypeGIF
                     filename:@"share.gif"];
    if (![self.recipientTextField.text isEqualToString:@""]) {
        picker.recipients = [NSArray arrayWithObject:self.recipientTextField.text];
    }
    picker.body = [NSString stringWithFormat:@"image: %i", _currentIndex];

    [self presentViewController:picker animated:YES completion:NULL];
}

在多次成功和失败案例中观察 UI 之后,它似乎是 compose 视图中的竞争条件,由于操作系统受到压力而加剧 - 不确定是内存压力还是 CPU 压力(或两者兼而有之?)。在任何情况下,当发送成功时,消息通道的内容会在选择联系人后立即填充其各自对话的内容,可见将新消息附加到末尾。但是当错误浮出水面并且消息消失时,对话的先前消息通常仅在按下发送按钮后才会出现,而不会出现新消息。如果这确实是一个竞争条件,一个猜测是它是 composer VC 的消息获取机制和-viewDidLoad.

有没有人遇到过这个和/或知道解决方法?我将向苹果提交错误报告,但我想找到一个不包括等待苹果修复的解决方案。

笔记:

  • 消息在 iPhone 4 和 iPhone 5s 上消失的频率最高,但在 iPod touch 第 5 代(均运行 iOS 7.0.2)上很少见。

  • 使用 iPhone 4 上的https://github.com/timcour/mf-message-compose-fail-demo.git应用程序,通过尽快将 20 张图像发送给同一个人,可以最轻松地重现该错误。

  • 有一个单独的(但可能相关的)错误。在 MFMCVC 视图中选择输入联系人的电子邮件地址后,vc 会确定是否应该发送 iMessage 或 MMS。在测试期间的某些时候,它做出了错误的决定,并试图将消息作为彩信发送,尽管接收者 iMessage 帐户没有与之关联的电话号码。这导致一条消息在发件人看来好像已成功发送,但实际上未能到达其目的地。

  • 这似乎不是许多用户向苹果抱怨的“iMessage 无法发送消息”错误。

更新:

这是消息消失且无法发送时记录的堆栈跟踪:

Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] ****** Failed to complete all history queries in a blocking request: (
        "********-****-****-****-************"
    )
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 1   IMFoundation                        0x0000000193acb948 IMLogBacktraceToDepth + 80
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 2   IMCore                              0x00000001939d1df8 _NSStringFromIMMessageError + 22604
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 3   IMCore                              0x00000001939c7670 IMPersonStatusComparator + 261116
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 4   ChatKit                             0x00000001923c96b8 <redacted> + 240
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 5   ChatKit                             0x00000001923933b0 <redacted> + 88
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 6   ChatKit                             0x000000019237cb70 <redacted> + 996
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 7   ChatKit                             0x0000000192414cdc <redacted> + 76
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 8   Foundation                          0x000000018e8c0834 __NSFireDelayedPerform + 392
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 9   CoreFoundation                      0x000000018dd1768c <redacted> + 28
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 10  CoreFoundation                      0x000000018dd172fc <redacted> + 804
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 11  CoreFoundation                      0x000000018dd15024 <redacted> + 1324
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 12  CoreFoundation                      0x000000018dc55b78 CFRunLoopRunSpecific + 452
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 13  GraphicsServices                    0x0000000193677830 GSEventRunModal + 168
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 14  UIKit                               0x0000000190c9305c UIApplicationMain + 1156
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 15  MessagesViewService                 0x000000010009bd80 MessagesViewService + 15744
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 16  libdyld.dylib                       0x000000019a25baa0 <redacted> + 4
Oct 21 12:09:20 Davids-iPhone SpringBoard[16] <Warning>: LICreateIconForImage passed NULL CGImageRef image
4

2 回答 2

1

您的问题是您对选择器没有强烈的参考。将其设为 ivar,并在选择器完全完成其工作时将其设为 nil。

于 2013-10-19T12:25:49.207 回答
0

尝试确保您的时间和日期设置正确。我更改了我的以下载模拟器并忘记将其更改回来。然后我的消息开始消失。在我确定时间后问题得到纠正。干杯

于 2013-11-13T03:13:03.080 回答