I am building an app where I need to find online/offline status of only those users with whom I have exchanged messages in past. Not all the users available on the server. Thanks in advance.
-You can get particular user's online/offline status using XMPPIQ You need to create XMPPIQ with 'type get' as following
let query = XMLElement(name: "query", xmlns: "jabber:iq:last")
let streamUUID = self.xmppStream.generateUUID()
let iq = XMPPIQ(type: "get", to: XMPPJID(string: jid) , elementID: streamUUID , child: query)
self.xmppStream.send(iq)
return streamUUID!
then there is delegate method in XMPPStreamDelegate protocol named 'didReceive iq:', you need to provide handle IQ result in thi smethod as follows,
func xmppStream(_ sender: XMPPStream!, didReceive iq: XMPPIQ!) -> Bool {
if iq.isResultIQ() {
iq.lastActivitySeconds() == 0{
print("user is online")
}else{
print("user is offline")
}
}
return false
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With