markAsDelivered method
Mark a message as delivered with given payload from push notification
Implementation
Future<void> markAsDelivered({required Map<String, dynamic> data}) async {
Map<String, dynamic>? sendbird = data['sendbird'];
String? appId, userId, channelUrl, sessionKey;
int? createdAt;
if (sendbird != null) {
Map<String, dynamic>? recipient = sendbird['recipient'];
Map<String, dynamic>? channel = sendbird['channel'];
Map<String, dynamic>? session = sendbird['session_key'];
createdAt = sendbird['created_at'];
appId = sendbird['app_id'];
if (recipient != null) userId = recipient['id'];
if (channel != null) channelUrl = channel['channel_url'];
if (session != null) sessionKey = session['key'];
}
if (appId != null &&
userId != null &&
channelUrl != null &&
sessionKey != null &&
createdAt != null) {
SendbirdSdk(appId: appId);
_int.sessionManager.setUserId(_int.state.userId ?? userId);
_int.sessionManager.setSessionKey(sessionKey);
await _int.api.send(GroupChannelMarkAsDeliveredRequest(
channelUrl: channelUrl,
userId: userId,
timestamp: createdAt,
));
} else {
throw InvalidParameterError();
}
}