canStartVerification static method

Future<bool> canStartVerification(
  1. bool requestServices
)

Checks whether all necessary permissions and services are available in order to start the address verification process.

  • requestServices Attempt to activate / request all necesarry permissions and services

Implementation

static Future<bool> canStartVerification(bool requestServices) async {
  if (Platform.isIOS && !(await OkHi.isLocationServicesEnabled())) {
    throw OkHiException(
      code: OkHiException.serviceUnavailableCode,
      message: "Location services disabled",
    );
  }
  var hasLocationServices =
      Platform.isIOS ? true : await OkHi.isLocationServicesEnabled();
  var hasLocationPermission =
      await OkHi.isBackgroundLocationPermissionGranted();
  var hasGooglePlayService =
      Platform.isIOS ? true : await OkHi.isGooglePlayServicesAvailable();
  if (!requestServices) {
    return hasLocationServices &&
        hasLocationPermission &&
        hasGooglePlayService;
  }
  hasLocationServices =
      Platform.isIOS ? true : await OkHi.requestEnableLocationServices();
  hasLocationPermission = await OkHi.requestBackgroundLocationPermission();
  hasGooglePlayService =
      Platform.isIOS ? true : await OkHi.requestEnableGooglePlayServices();
  return hasLocationServices && hasLocationPermission && hasGooglePlayService;
}