【问题标题】:Set tag or unique identifier for MSMessage为 MSMessage 设置标签或唯一标识符
【发布时间】:2017-01-31 16:37:27
【问题描述】:

可以为MSMessage 实例设置唯一的id 和/或tag?我当前的应用程序基于使用整数 id 作为标识符从服务器获取的数据。选择以前的消息时,我想通过获取当前消息的ididtagtagtag或@ 987654325和使用该服务器的邮件。

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

【问题讨论】:

    标签: ios swift imessage msmessage


    【解决方案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 或任何您想要的内容

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-13
      • 1970-01-01
      • 2022-09-29
      • 1970-01-01
      • 1970-01-01
      • 2019-04-26
      • 2014-03-05
      • 2012-06-02
      相关资源
      最近更新 更多