2

I am creating an iMessage app for iOS 10 in which I would like to send some data with the layout. When the user taps on the layout that has been sent it will open the iMessage app and access the data that has also been sent. The data is a String.

Should I be using the MSMessage URL to send the data? Once the user taps on the MSMessage layout in iMessage, how do I receive the URL again?

Thank you

Tom Coomer
  • 5,449
  • 12
  • 38
  • 76

3 Answers3

3

Yes, you would use the MSMessage.URL to send and retrieve the data.

When the user taps on a MSMessage, -(void)didBecomeActiveWithConversation:(MSConversation *)conversation will be called. You can access the selected message URL through the passed MSConversation object like so NSURL *url = conversation.selectedMessage.URL

ansonl
  • 778
  • 1
  • 9
  • 29
2

in swift 3 you can get URL from this overdid method of Messageviewcontroller, savedConversation is object of MSConversation

    override func willBecomeActive(with conversation: MSConversation){
        if(savedConversation?.selectedMessage?.url != nil)

           let url = savedConversation?.selectedMessage?.url
           UIApplication.shared.open(url, options: [:], completionHandler: nil)

    }
Shauket Sheikh
  • 2,159
  • 14
  • 31
1

MSMessage's url property is where you can store your custom data.

You can also use iMessageDataKit library. It makes setting and getting data really easy like:

let message: MSMessage = MSMessage()

message.md.set(value: 7, forKey: "user_id")
message.md.set(value: "john", forKey: "username")
message.md.set(values: ["joy", "smile"], forKey: "tags")

print(message.md.integer(forKey: "user_id")!)
print(message.md.string(forKey: "username")!)
print(message.md.values(forKey: "tags")!)

(Disclaimer: I'm the author of iMessageDataKit)

Ahmet Ardal
  • 1,132
  • 1
  • 11
  • 12
  • 1
    This is nice. I'm going to integrate your library into our iMessage extension. Makes it faster for us to develop our prototype. Do you have the intention to update the library for further iOS version (e.g. if some changes occur)? – Baran Emre Jun 11 '18 at 09:18