checkForUnsentReports method

  1. @override
Future<bool> checkForUnsentReports()
override

Checks a device for any fatal or non-fatal crash reports that haven't yet been sent to Crashlytics.

If automatic data collection is enabled, then reports are uploaded automatically and this always returns false. If automatic data collection is disabled, this method can be used to check whether the user opts-in to send crash reports from their device.

Implementation

@override
Future<bool> checkForUnsentReports() async {
  if (isCrashlyticsCollectionEnabled) {
    throw StateError(
        "Crashlytics#setCrashlyticsCollectionEnabled has been set to 'true', all reports are automatically sent.");
  }

  try {
    Map<String, dynamic>? data =
        await channel.invokeMapMethod<String, dynamic>(
            'Crashlytics#checkForUnsentReports');

    return data!['unsentReports'];
  } on PlatformException catch (e, s) {
    convertPlatformException(e, s);
  }
}