technerd technerd - 1 year ago 137
iOS Question

How to get MSMessage summary text from Received Message?

I am passing summary message in MSMessage , but when try to get when message received at other end, it returns nil.

Below is code for create 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

To Send Message in Current Conversation

let message = composeMessage(with: url!,andEventInfo: eventInfo)
activeConversation?.insert(message, completionHandler: { (error) in


Now, At receiving end

returns nil.

override func didReceive(_ message: MSMessage, conversation: MSConversation) {

print("DID RECEIVE MESSAGE: \(message.summaryText)")

Also when user tap on message, then also it returns 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 {


presentViewController(for: conversation, with: presentationStyle)



Any one have idea, why this happens or any thing is going wrong ?

Answer Source

May this will be helpful

override func didReceive(_ message: MSMessage, conversation: MSConversation) {
// Called when a message arrives that was generated by another instance of this
// extension on a remote device.

// Use this method to trigger UI updates in response to the message.
guard let messageURL = message.url else { return }
guard let urlComponents = NSURLComponents(url: messageURL, resolvingAgainstBaseURL: false), let queryItems = urlComponents.queryItems else { return }

print("URL Components", urlComponents)
print("queryItems", queryItems)

for item in queryItems {
    print("Received \( with value \(item.value)")


Reference & helped Source:

And Also Refer : iOS10 iMessage : Unable to insert data into iMessage using MSConversation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download