How to create an account from Smack 4.1

2020-07-14 12:30发布

问题:

I'm trying to create an account from Smack for Android on jabber.at. Here is my code :

XMPPTCPConnectionConfiguration conf= XMPPTCPConnectionConfiguration.builder()
                                .setServiceName("jabber.at")
                                .build();
XMPPTCPConnection connection = new XMPPTCPConnection(conf);

connection.addConnectionListener(xmppConnectionListener);
connection.connect();

AccountManager accountManager = AccountManager.getInstance(connection);
Map<String, String> map = new HashMap<String, String>();
map.put("username", usr);
map.put("password", pwd);
map.put("email", email);
accountManager.createAccount(usr, pwd, map);

I got an error:

W/System.err﹕ org.jivesoftware.smack.packet.XMPPError@2beba168
W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:217)
W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:198)

I have tried with and without the Map, same error. According to Mathias Ertl from jabber.at, it is possible to create accounts remotely, so I'm doing something wrong somewhere. Any idea ?

回答1:

check if your server support remote account creation.

accountManager.supportsAccountCreation()