hasValidCredentials method

Future<bool> hasValidCredentials()

Verifies whether the appId is valid

Implementation

Future<bool> hasValidCredentials() async {
  // We check the completer first because _headlessWebView may be null because we haven't loaded the version asset yet.
  if (!_completer.isCompleted) {
    if (_me == null) {
      throw StateError(
          'The me property needs to be set for the Session object before calling hasValidCredentials');
    }

    if (kDebugMode) {
      print(
          '📗 session hasValidCredentials: !_completer.isCompleted, awaiting for _completer.future');
    }
    await _completer.future;
  }

  if (_headlessWebView == null) {
    throw StateError(
        'The hasValidCredentials method cannot be called after destroying the session');
  }

  if (kDebugMode) {
    print('📗 session hasValidCredentials: execute');
  }

  _validCredentialsCompleter = Completer();

  _execute(
      'session.hasValidCredentials().then((value) => window.flutter_inappwebview.callHandler("JSCValidCredentials", JSON.stringify(value)));');

  return _validCredentialsCompleter.future;
}