2016-09-22 25 views
1

可以爲MSMessage實例設置唯一的id和或tag?我目前的應用程序基於從服務器使用整數ID作爲標識符獲取的數據。當選擇先前的消息時,我想通過獲取當前消息的idtag(如果可能)並在查詢中將其用於我的服務器來相應地修改視圖。MSMessage的設置標籤或唯一標識符

override func willBecomeActive(with conversation: MSConversation) { 
    //Retrive id from selected message 
    if conversation.selectedMessage != nil{ 
     //Do things 
    } 
    } 

回答

1

您可以使用郵件的URL來在它添加一個「id」鍵:

guard let components = NSURLComponents(string: myBaseURL) else { 
    fatalError("Invalid base url") 
} 

let id = NSURLQueryItem(name: "id", value: yourIdHere) 
components.queryItems = [id] 

guard let url = components.url else { 
    fatalError("Invalid URL components.") 
} 

message.url = url 

使用日期爲您的ID或任何的哈希你想