I am beginner in XMPP. I want to implement chat application with OpenFire server. I have integrated "pod 'XMPPFramework/Swift'" Pod... I am able to make the proper connection with the server, but when I want to send any message to another Jabberid, I am receiving an error
I am beginner in XMPP. I want to implement chat application with OpenFire server. I have integrated "pod 'XMPPFramework/Swift'" Pod... I am able to make the proper connection with the server, but when I want to send any message to another Jabberid, I am receiving an error
SEND: <iq type="error" to="DOMAINMANE" id="348-5581"><query xmlns="jabber:iq:version"/><error type="cancel" code="501"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
Here is the code,which I tried `extension AppDelegate{ private func setupStream() { //xmppRoster = XMPPRoster(rosterStorage: xmppRosterStorage) xmppRoster.activate(xmppStream) self.xmppStream.addDelegate(self, delegateQueue: DispatchQueue.main) self.xmppRoster.addDelegate(self, delegateQueue: DispatchQueue.main)
}
func xmppStream(_ sender: XMPPStream, didReceive iq: XMPPIQ) -> Bool { print("Did receive IQ") return false }
func xmppStream( sender: XMPPStream, didReceive message: XMPPMessage) { print("Did send message (message)") } func xmppStream( sender: XMPPStream, didReceive presence: XMPPPresence) { print("IN APPDELEGATE -----> ", presence) let presenceType = presence.presenceType?.rawValue let myUsername = sender.myJID?.user let presenceFromUser = presence.from?.user print("MY USERNAME ",myUsername) print("OTHER USER NAME ",presenceFromUser) print("PRESNET ",presenceType) //HERE ALSO NOT GETTING ANOTHER ONLINE USER, SO THAT I CAN ADD INTO ONLINE BUDDIES LIST /if presenceFromUser != myUsername { print("Did receive presence from (presenceFromUser)") if presenceType == "available" { delegate.buddyWentOnline(name: "(presenceFromUser)@(GlobleConstants.XMPPHOSTNAME)") } else if presenceType == "unavailable" { delegate.buddyWentOffline(name: "(presenceFromUser)@(GlobleConstants.XMPPHOSTNAME)") } }/ }
} extension AppDelegate : XMPPRosterDelegate{ func xmppRoster(_ sender: XMPPRoster, didReceiveRosterItem item: DDXMLElement) { print("Did receive Roster item") } }`
And now inside of the controller, I am trying to fetch online buddies by
func setupUI(){ appDelegate.delegate = self if appDelegate.connect() { self.title = appDelegate.xmppStream.myJID?.user appDelegate.xmppRoster.fetch() } self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") }
Also , when I try to send a sample message to the receiver , I am facing the same error. Here is code to send the sample message.
func sendSimpleMessage(sender: XMPPStream){ let body = DDXMLElement.element(withName: "body") as! DDXMLElement let message = DDXMLElement.element(withName: "message") as! DDXMLElement message.addAttribute(withName: "type", stringValue: "chat") message.addAttribute(withName: "to", stringValue: GlobleConstants.receiverJID) message.addChild(body) sender.send(message) }
Anyone having solution for the same?