Send / receive friend request Using XMPP server in Android

I am creating an application based on XMPP chat Messenger. Now we have a configuration function that needs to be implemented in the application, for example, “Send / receive a friend’s request” in the messenger. How can we do this. Please help with your suggestions.

roster = _connection.getRoster(); roster.createEntry(userID, nickname, null); 

We are currently using this method, but it has directly added the contact to my messenger contact list. Now I want to ask if there is any new friend request coming up, like BBM (Blackberry Messenger). then he must ask for confirmation before adding directly to the contact lists that he is currently doing.

Please help as soon as possible.

+4
source share
2 answers

I can help you. I have a fully functional messaging app. I assume that you are using Smack or Asmack as the XMPP library.

Add Friend

 Presence request = new Presence(Presence.Type.subscribe); packet.setTo(" john@ejabberd.org "); mXMPPConnection.sendPacket(packet); 

Accepting Request

 Presence accept = new Presence(Presence.Type.subscribed); accept.setTo(" john@ejabberd.org "); mXMPPConnection.sendPacket(accept); 

Ask me if you need anything else :) Greetings

0
source

Send a friend request / invitation [user1 @domain],

 Presence presence = new Presence(Presence.Type.subscribe); presence.setTo(" user2@domain "); connection.sendStanza(presence); 

Accept friend’s request / invitation [user2 @domain],

 Presence presence = new Presence(Presence.Type.subscribed); presence.setTo(" user1@domain.com "); connection.sendStanza(presence); 

Each time user2 logs in, the server will send subscription subscription packages to user2 until user2 sends any response to the request.

0
source

All Articles