How to put Custom fields to XMPP vCard Android/SMACK
Asked Answered
M

1

6

I am currently developing a chat application and I am using the following Vcard to store User information.

public void run() {
VCard vcard = new VCard();
vcard.setJabberId(xmppConnection.getUser());
vcard.setNickName(user.getChatId());
vcard.setFirstName(user.getUsername());
vcard.setPhoneHome("CELL", user.getMobileNo()); }

In addition to the above values I want to add new fields to the Vcard like

vcard.setNotificationType(user.getNotType())
vcard.setAlerts(user.getAlerts())

Is this possible? If so please help me on how to do it. Thanks.

Mctyre answered 19/9, 2014 at 10:58 Comment(4)
Be careful, you seem to want to store configuration preference in Vcard. VCard are intended to be public and can be retrieved by others.Subsidiary
That is not a problem as long as I can save those data. Is it possible?Mctyre
yes, it is possible, but you are using a feature for a need that is very different to what it is intended. Why don't you use XMPP private storage ? xmpp.org/extensions/xep-0049.htmlSubsidiary
But the simplicity is there. We can request a Vcard, save a vcard easily and get the common fields like Name, ID, Phone no. etc simply. I'am not saying what you suggest is bad but this way its is simpler right?Mctyre
C
4

I know it's an old question but maybe someone would need the answer..

You can use vCard.setField(String field, String value)

For Example :

vcard.setField("NotificationType", user.getNotType());

And to get it back :

vcard.getField("NotificationType");
Culture answered 25/1, 2015 at 20:33 Comment(1)
Glad I could help ^_^Culture

© 2022 - 2024 — McMap. All rights reserved.