Last active
October 12, 2021 08:43
-
-
Save hieptl/99d3f9bad2adbafb75e887e1bfdb041c to your computer and use it in GitHub Desktop.
SignUpActivity.java - Register CometChat Account - Voice and Video Chat App - Android App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
public class SignUpActivity extends AppCompatActivity implements View.OnClickListener { | |
... | |
private void registerCometChatAccount(String username, String email) { | |
if (username == null) { | |
return; | |
} | |
String uid = UUID.randomUUID().toString(); | |
String avatar = this.generateAvatar(); | |
User user = new User(); | |
user.setUid(uid); | |
user.setName(username); | |
user.setAvatar(avatar); | |
CometChat.createUser(user, Constants.COMETCHAT_AUTH_KEY, new CometChat.CallbackListener<User>() { | |
@Override | |
public void onSuccess(User user) { | |
Toast.makeText(SignUpActivity.this, user.getName() + " has been created successfully", Toast.LENGTH_SHORT).show(); | |
UserModel userModel = new UserModel(uid, username, email, avatar); | |
insertFirebaseDatabase(userModel); | |
} | |
@Override | |
public void onError(CometChatException e) { | |
Toast.makeText(SignUpActivity.this, "Failed to create your account. Please try again", Toast.LENGTH_SHORT).show(); | |
} | |
}); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment