1

我知道使用 iMessage 扩展程序,除非应用程序根据 Apple 的防止自动消息的政策检测到用户交互,否则无法发送消息。

但是,我有一个屏幕截图检测器,当用户对其进行屏幕截图时,它会自动发送一条消息。

当扩展程序已经打开,并且选择一条消息并将其截屏时,一切正常,因为在打开应用程序时存在先前的交互。

但是,如果您在没有打开扩展程序的情况下直接点击消息并对其进行截图,iMessage 将不会发送该消息。

我想知道两件事之一:

  1. 如何绕过并发送消息(不太可能工作)
  2. 如何在显示消息之前检查是否有交互

如果您有任何想法,请告诉我。

activeConversation?.send(message) { error in
   print(error)
}

这是我很确定的错误。但是,我确实检查过并且主动对话不是零

Optional(Error Domain=com.apple.messages.messagesapp-error Code=9 "(null)")
4

1 回答 1

0

Are you testing in the debugger and have you confirmed it still fails without debugging?

As I just answered in this question there is an XCode bug which causes crashes when you have the info.plist key to give you camera permission.

It's a weird side-effect and it took me nearly two days to work out that was happening (I had added the info.plist keys weeks before testing sending messages).

于 2019-06-23T12:25:33.267 回答