我下载了适用于 Android 的 Applozic Chat SDK。目前我发现您可以使用用户名和任何密码登录用户帐户。我想知道我应该如何实现代码来检查用户是否正确输入了密码?
问问题
396 次
1 回答
0
在进行 Applozic 登录/注册时,您需要设置user.setAuthenticationTypeId(User.AuthenticationType.APPLOZIC.getValue()); 并设置密码。如果密码不正确,您将在 UserLoginTask 的 onFailure 中收到异常,您可以在异常Invalid uername/password中检查此字符串
UserLoginTask.TaskListener listener = new UserLoginTask.TaskListener() {
@Override
public void onSuccess(RegistrationResponse registrationResponse, Context context) {
//After successful registration with Applozic server the callback will come here
}
@Override
public void onFailure(RegistrationResponse registrationResponse, Exception exception) {
//If any failure in registration the callback will come here
//Here Invalid uername/password exception will be thrown if password is wrong check for the string Invalid uername/password in exception
}};
User user = new User();
user.setUserId(userId); //userId it can be any unique user identifier
user.setDisplayName(displayName); //displayName is the name of the user which will be shown in chat messages
user.setEmail(email); //optional
user.setImageLink("");//optional,pass your image link
user.setPassword(password);//Set the password
user.setAuthenticationTypeId(User.AuthenticationType.APPLOZIC.getValue());//You need to set the Authentication type
new UserLoginTask(user, listener, this).execute((Void) null);
于 2016-10-18T08:30:34.893 回答