how can I block user xmpp in swift 3

2019-02-27 01:45发布

问题:

I am working on XMPP Chat application in iOS. The send and Received functionality working fine. But I want to implement block user feature in Chat. How can I implement Block user using XMPPBlocking and fetch all block user list? Please find the code below for sending a message.
let senderJID = XMPPJID.init(string: xmppClass.getXMPPJID(strJID: self.message.to_user_id)) let msg = XMPPMessage(type: "chat", to: senderJID)

    let messageID = XMLElement(name: "message_id", stringValue: self.message.message_id)
    let isSend = XMLElement(name: "is_send", stringValue: "1")
    let isDelivered = XMLElement(name: "is_delivered", stringValue: "0")
    let isRead = XMLElement(name: "is_read", stringValue: "0")
    let from_user_id = XMLElement(name: "from_user_id", stringValue: self.message.from_user_id)
    let to_user_id = XMLElement(name: "to_user_id", stringValue: self.message.to_user_id)
    let message_type = XMLElement(name: "message_type", stringValue: "text")
    let media_id = XMLElement(name: "media_id", stringValue: "0")

    let mediaUrl = XMLElement(name: "media_url", stringValue: "")
    let thumbImage = XMLElement(name: "thumb_url", stringValue: "")

    let timestamp = XMLElement(name: "timestamp", stringValue: self.message.timestamp)
    let offline = XMLElement(name: "offline", stringValue: "Offline Message")

    msg?.addBody(self.message.message)
    msg?.addAttribute(withName: "id", stringValue: self.message.message_id)

    msg?.addChild(messageID)
    msg?.addChild(isSend)
    msg?.addChild(isDelivered)
    msg?.addChild(isRead)
    msg?.addChild(from_user_id)
    msg?.addChild(to_user_id)
    msg?.addChild(media_id)
    msg?.addChild(message_type)
    msg?.addChild(mediaUrl)
    msg?.addChild(thumbImage)
    msg?.addChild(timestamp)
    msg?.addChild(offline)                

    Global.appDelegate.xmppClassObj.xmppStream?.send(msg)


Please help for block and unblock user XMPPBlocking,XMPPBlockingDelegate

标签: ios swift3 xmpp