0
我在MSMessage中傳遞摘要消息,但是當嘗試獲取在另一端收到的消息時,它返回nil。如何從接收消息中獲取MSMessage摘要文本?
以下是用於創建消息的代碼。
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
返回nil。
override func didReceive(_ message: MSMessage, conversation: MSConversation) {
print("DID RECEIVE MESSAGE: \(message.summaryText)")
}
此外,當用戶水龍頭上的消息,那麼也將返回零
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)
}
}
}
任何一個有想法,爲什麼出現這種情況或任何東西是哪裏錯了?
是啊,queryItems能很好地通過使用名稱和值對信息的數據。謝謝。 – technerd