我下载了Applozic Chat SDK for android。目前,我发现您可以使用用户名和密码登录用户帐户。我很想知道如何实现代码以检查用户是否正确输入了密码?
答案 0 :(得分:0)
在进行Applozic登录/注册时,您需要设置 user.setAuthenticationTypeId(User.AuthenticationType.APPLOZIC.getValue()); 并设置密码。如果密码不正确,您将获得异常在UserLoginTask的onFailure中,您可以检查此字符串异常无效的姓名/密码
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);