我在 MSMessage 中传递摘要消息,但是当尝试获取另一端收到的消息时,它返回 nil。
下面是创建 Message 的代码。
fileprivate func composeMessage(with url: String, andEventInfo eventInfo: NSDictionary?) -> MSMessage {
let message = MSMessage(session:MSSession())
message.url = URL(string: url)
message.layout = createTemplateForEvent(eventInfo: eventInfo!)
message.summaryText = "SAMPLE MESSAGE"
return message
}
在当前会话中发送消息
let message = composeMessage(with: url!,andEventInfo: eventInfo)
activeConversation?.insert(message, completionHandler: { (error) in
print(error)
})
现在,在接收端
这里summaryText
返回零。
override func didReceive(_ message: MSMessage, conversation: MSConversation) {
print("DID RECEIVE MESSAGE: \(message.summaryText)")
}
此外,当用户点击消息时,它也会返回 nil
override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
guard let conversation = activeConversation else { fatalError("Expected an active converstation") }
// Present the view controller appropriate for the conversation and presentation style.
if presentationStyle == .expanded {
if conversation.selectedMessage != nil {
print(conversation.selectedMessage?.summaryText)
presentViewController(for: conversation, with: presentationStyle)
}
}
}
任何人都有想法,为什么会发生这种情况或任何事情出错?