getInboxNotificationCount method

  1. @override
Future<DataResult<int>> getInboxNotificationCount()
override

Get the number of unread notification count to display on the screen

Implementation

@override
Future<DataResult<int>> getInboxNotificationCount() async{
  final userId = _userId;
  final device = await getDeviceInfo();
  final platform = device?.platform;
  final result = await NUIWeb.get(module: NUIWEB_MODULE).doGET(
      url: "notification/getNotificationCount",
      params: {
        "userId": userId
      },
      headers: {
        "Authorization": platform ?? "-",
        "X-DeviceOs": platform ?? "-"
      },
      entity: NUIPushStandardResponseEnt<NUINotificationCountPayload>(NUIEntType.OBJECT, (data) => asObject(NUINotificationCountPayloadEntity(), data))
  );

  if(result.success == true){
    logNUI(_MODULE, "Get notification count successful");
    return DataResult<int>(
        success: true,
        message: result.message,
        data: result.body?.data?.notificationCount ?? 0,
        code: NUIPushCode.GET_NOTIFICATIONS_SUCCESS.name
    );
  }
  else{
    logNUI(_MODULE, "Failed to get notification count");
    return DataResult(
        success: false,
        message: result.message,
        code: NUIPushCode.GET_NOTIFICATIONS_FAILED.name
    );
  }
}