fetchLoggedInDevices method
~english Gets the list of currently logged-in devices of a specified account.
Param userId The user ID.
Param pwdOrToken The password or token.
Param isPwd Whether a password or token is used: (Default)true: A password is used; false: A token is used.
Return The list of the logged-in devices.
Throws A description of the exception. See EMError. ~end
~chinese 获取指定账号下登录的在线设备列表。
Param userId 用户 ID。
Param pwdOrToken 密码或者 token。
Param isPwd 是否使用密码或 token:(默认)true:使用密码;false:使用 token。
Return 获取到到设备列表。
Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 ~end
Implementation
Future<List<EMDeviceInfo>> fetchLoggedInDevices({
required String userId,
required String pwdOrToken,
bool isPwd = true,
}) async {
try {
Map req = {'userId': userId, 'password': pwdOrToken, 'isPwd': isPwd};
Map result = await Client.instance
.callNativeMethod(ChatMethodKeys.getLoggedInDevicesFromServer, req);
EMError.hasErrorFromResult(result);
List<EMDeviceInfo> list = [];
result[ChatMethodKeys.getLoggedInDevicesFromServer]?.forEach((info) {
list.add(EMDeviceInfo.fromJson(info));
});
return list;
} catch (e) {
rethrow;
}
}