XMPP服务器:已创建帐户但未保存属性

时间:2015-03-31 04:23:31

标签: android xmpp ejabberd asmack

我正在 ejabberd 服务器上创建新用户。用户已创建。 在下面的代码中,用户918已创建,但未保存任何属性。

ejabberd服务器的访问规则是:[register, [{allow,all}]]

但是,我传递的createAccount()属性不会保存在 ejabberd 服务器上。

使用的库 - asmack-android-8-4.0.7,dnsjava-2.1.7。 XMPP服务器 - ejabberd 2.1.11

代码是

    ConnectionConfiguration config = new ConnectionConfiguration("myserver.co");
     config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
     conn1 = new XMPPTCPConnection(config);
     conn1.connect();

     AccountManager accMan = AccountManager.getInstance(conn1);
     Map<String, String> attributes = new HashMap<String, String>();
     attributes.put("phone", "237");
     attributes.put("misc", "123");

     accMan.createAccount("918", "hellopass", attributes);

     conn1.login("918", "hellopass");
     accMan = AccountManager.getInstance(conn1);
     Log.d(TAG, "acc IMEI " + accMan.getAccountAttribute("misc")); // null returned here
    Log.d(TAG, "acc phone " + accMan.getAccountAttribute("phone")); // null returned here

上面发布的最后两行代码,返回null值。

我不知道我错过了什么,以正确创建具有属性的帐户也被保存。

感谢 Vilpesh。

1 个答案:

答案 0 :(得分:0)

属性不存储在帐户上,而是存储在Vcard上。注册用户时,只能传递用户名和密码。 有关用户信息,您应该查看设置Vcard。