Load Vcards with Smack (Android) in Openfire Server
Asked Answered
N

1

6

I am implementing a messaging application with the XMPP protocol and Openfire server on android platform. I need save and load my own Vcard and other users vcard. At the moment, I managed to keep my vCard on the server and can load it again. The problem is with the other users Vcards, server always return XMPPError: feature-not-implemented - cancel.

I use this libraries:

compile 'org.igniterealtime.smack:smack-android:4.1.2-SNAPSHOT'
compile 'org.igniterealtime.smack:smack-tcp:4.1.2-SNAPSHOT'
compile 'org.igniterealtime.smack:smack-extensions:4.1.2-SNAPSHOT'

Show the code:

Save my own Vcard (Work fine).

VCardManager vCardManager = VCardManager.getInstanceFor(connection);
VCard vCard;
vCard = vCardManager.loadVCard();
vCard.setNickName("User name");
URL urldefault = new URL("Avatar URL");
InputStream stream = urldefault.openStream();
byte[] avatar1 = readBytes(stream);
vCard.setAvatar(avatar1, "avatar1/jpg");
vCard.setEmailHome("user email");
vCard.setPhoneHome("mobile", "888888888");
vCardManager.saveVCard(vCard);

Load my own Vcard (Work fine)

VCard vCard = null;
VCardManager vCardManager = VCardManager.getInstanceFor(connection);
vCard = vCardManager.loadVCard();

The problem is here. Load other user Vcard:

VCardManager vCardManager = VCardManager.getInstanceFor(connection);
boolean isSupported = vCardManager.isSupported(user);
if (isSupported)  // return true
    vCard = vCardManager.loadVCard(user);

The user name to load Vcard is correct.

Any ideas?

Thanks in advance.

Nightjar answered 5/6, 2015 at 15:52 Comment(6)
hope You are seeing this, it´s an older post, but I got exactly the same problem. But the jid I try to load is [email protected], without the Smack extension. Have You any kind of idea why it doesn´t work?Excrescent
mmm I resolved my problem with the jid of the user without the /Smack. What version you are using in your application?Baroque
thanks for reply...I am using Smack 4.1.6 API, But yesterday I read some bug reports and seems that it is server dependant. My jid is proper, so that could not be the problem. One more question, Your connection, are You just logged in with Your jid or do I need to do some changes on Connection before calling the vcard of another user?Excrescent
Not is neccesary to make any more changes. I logging with my JID and from there I can consult other users vCard. However, my experience with the use of vCard is that they are a bit unstable. If only you use to manage the avatar can work well, if you enter a lot of information the result is worse.Baroque
Strange....ok, but again, many thanks for your reply.....Excrescent
@AlejandroMartínezMartínez, #66638168 , I am also facing issue in loading VCard , but in diff scenario. using smack version ':4.3.4', if possible can you please guide me?Peltry
I
8

The issue you might be facing is the suffix for the JID. The connection.getUser() method returns the JID as [email protected]/Smack. To get the vCard details, you need to query it as [email protected] (without the /Smack). Try that out and let me know if it works.

Isometropia answered 8/6, 2015 at 2:15 Comment(1)
Fantastic!!. In connection.getUser() i`ll received usuario@jabber/Smack. I try with usuario@jabber only and it work fine. Thank you!!Baroque

© 2022 - 2024 — McMap. All rights reserved.