How to get all friends programmatically from openfire server in objective C, I am using XMPP
Framework for chat Functionality.
Here is a function to fetch friends.
Add your host name in below function.
func getList() {
let query = try! XMLElement(xmlString: "<query xmlns='http://jabber.org/protocol/disco#items' node='all users'/>")
let iq = XMPPIQ(type: "get", to: XMPPJID(string: "Your Host Name"), elementID: xmppStream.generateUUID(), child: query)
iq?.addAttribute(withName: "id", stringValue: "get")
xmppStream.send(iq)
}
You will get the list in delegate method.
extension YourClassName: XMPPRosterDelegate {
func xmppRosterDidEndPopulating(_ sender: XMPPRoster!) {
if let jids = xmppRoster.xmppRosterStorage.jids(for: xmppStream) as? [XMPPJID] {
print("JIDS: \(String(describing: jids))")
for item in jids {
print(item.user)
}
}
}
}
You can have a look at my this link for XMPP Connection and different delegates.