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.

  • 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 example@anotherxmpp.com, without the Smack extension. Have You any kind of idea why it doesn´t work? – Opiatefuchs Feb 23 '16 at 17:59
  • mmm I resolved my problem with the jid of the user without the /Smack. What version you are using in your application? – Alejandro Martínez Martínez Feb 24 '16 at 08:00
  • 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? – Opiatefuchs Feb 24 '16 at 08:30
  • 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. – Alejandro Martínez Martínez Feb 24 '16 at 09:04
  • Strange....ok, but again, many thanks for your reply..... – Opiatefuchs Feb 24 '16 at 09:14
  • @AlejandroMartínezMartínez, https://stackoverflow.com/questions/66637668/loading-vcard-of-multiuserchat-via-jid-throws-bad-request-error-in-smack-with-op , 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? – zephyr Mar 15 '21 at 12:39

1 Answers1

8

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

y0da
  • 396
  • 1
  • 5