subscribe method Null safety
Subscribes to a user's presence states. If the subscription succeeds, the subscriber will receive the callback when the user's presence state changes.
Param members
The list of IDs of users whose presence states you want to subscribe to.
Param expiry
The expiration time of the presence subscription.
Return Which contains IDs of users whose presence states you have subscribed to.
Throws A description of the exception. See {@link EMError}.
Implementation
Future<List<EMPresence>> subscribe({
required List<String> members,
required int expiry,
}) async {
Map req = {'members': members, "expiry": expiry};
Map result =
await _channel.invokeMethod(ChatMethodKeys.presenceSubscribe, req);
try {
EMError.hasErrorFromResult(result);
List<EMPresence> list = [];
result[ChatMethodKeys.presenceSubscribe]?.forEach((element) {
list.add(EMPresence.fromJson(element));
});
return list;
} on EMError catch (e) {
throw e;
}
}