checkPermissionAndStartAdProcess method

Future<void> checkPermissionAndStartAdProcess()

Implementation

Future<void> checkPermissionAndStartAdProcess() async {

  await _waitingOperation?.cancel();

  final waitingMs = intervalWaitMs;

  if (waitingMs <= 0) {
    _innerCheckProcess();
  } else {
    _waitingOperation = CancelableOperation.fromFuture(
      Future.delayed(Duration(milliseconds: waitingMs), () => true),
      onCancel: () async {
        _waitingOperation = null;
        return false;
      },
    );

    _waitingOperation?.value.then((value) {
      if (value) {
        _waitingOperation = null;
        checkPermissionAndStartAdProcess();
      }
    });
  }
}