login method Null safety
An app user logs in to the chat server with a password or token.
Param userId The username.
Param pwdOrToken The password or token.
Param isPassword Whether to log in with password or token.
true: (default) Log in with password.
false: Log in with token.
Throws A description of the exception. See ChatError.
Implementation
Future<void> login(String userId, String pwdOrToken,
[bool isPassword = true]) async {
EMLog.v('login: $userId : $pwdOrToken, isPassword: $isPassword');
Map req = {
'username': userId,
'pwdOrToken': pwdOrToken,
'isPassword': isPassword
};
Map result = await ClientChannel.invokeMethod(ChatMethodKeys.login, req);
try {
ChatError.hasErrorFromResult(result);
_currentUserId = userId;
} on ChatError catch (e) {
throw e;
}
}