0

I am trying to add a user to my roster using the following code:

    let storage = XMPPRosterCoreDataStorage.sharedInstance()
    let roster = XMPPRoster.init(rosterStorage: storage!, dispatchQueue: DispatchQueue.main)
    roster.addDelegate(self, delegateQueue: DispatchQueue.main)
    roster.activate(self.stream)
    roster .addUser(XMPPJID(string: "john@www.example.com")!, withNickname: "john") 

I am able to add user successfuly but I recieved the following Error:

XMPPRoster: initWithRosterStorage:dispatchQueue: - Unable to configure storage!

Can any one clarify why I am unable to configure storage

Ahmed
  • 1,229
  • 2
  • 20
  • 45
  • stream.activate(roster) i think – Muhammed Azharudheen Aug 13 '18 at 05:28
  • there is no problem in your code.something to check : when you are adding user what is the status of your connection ? i mean are you connected and authenticated ? – andesta.erfan Aug 13 '18 at 06:36
  • yes I am connected and authenticated – Ahmed Aug 13 '18 at 07:20
  • have you declare availability to server ? after authentication you have to send an empty presence to the server .after that server will send you all roster and core data storage will be populated .there is no problem in this 5 line of code because i,m using exactly the same.there is problem somewhere else – andesta.erfan Aug 13 '18 at 07:43
  • 1
    please try XMPPRoster(rosterStorage: storage!, dispatchQueue: DispatchQueue.main) instead of XMPPRoster.init in line 2 – andesta.erfan Aug 13 '18 at 07:48
  • @andesta.erfan thanks it works ok – Ahmed Aug 15 '18 at 05:11

0 Answers0