getTotalUnreadCount static method
Future<int>
getTotalUnreadCount(
{ - dynamic errorCallback(
- int? errorCode,
- String? errorMessage
)?,
})
Implementation
static Future<int> getTotalUnreadCount(
{
Function(int? errorCode, String? errorMessage)? errorCallback
}) async
{
if (!_isInitialized(errorCallback: errorCallback)) { return 0; }
if (!_checkAuthInfo(errorCallback: errorCallback)) { return 0; }
try {
String url = "/channels/unread/count";
Map<String, dynamic> response = await HttpUtil.get(url);
int totalUnreadCount = response["count"];
return totalUnreadCount;
} on TPException catch(e) {
Logger.log("$e");
if(errorCallback != null) { errorCallback(e.getCode(), e.getMessage()); }
} catch(e){
Logger.log("$e");
if(errorCallback != null) { errorCallback(-1, e.toString()); }
}
return 0;
}