Flutter / Firebase Facebook Логин: FacebookLoginStatus возвращает .error, почему? - PullRequest
0 голосов
/ 10 марта 2020

Я пытаюсь создать логин через Facebook с BLo C в моем приложении. У меня проблема с signInWithFacebook, точнее с ожиданием _facebookLogin.logIn (['email']), который возвращает результат с ошибкой состояния

консоль отладки:

LoginWithFacebookPressed
I/flutter (18219): ========================= Event To State (Facebook)========================
I/flutter (18219): ==================== signInWithFacebook =====================
I/flutter (18219): awaiting result
W/ActivityThread(18219): handleWindowVisibility: no activity for token android.os.BinderProxy@2402dae
I/flutter (18219): Instance of 'FacebookLoginResult'
I/flutter (18219): result ready
I/flutter (18219): verif if with result.status = FacebookLoginStatus.error
I/flutter (18219): result.status != logged in
I/flutter (18219): status is:
I/flutter (18219): FacebookLoginStatus.error
I/flutter (18219): user: null
I/flutter (18219): ==================== signInWithFacebook end =====================
I/flutter (18219): the _user is null

Это поток, который запускается, когда событие - LoginWithFacebookPressed. LoginState.success () показывает все пользовательские интерфейсы приложения.

Stream<LoginState> _mapLoginWithFacebookPressedToState() async* {
    try {
      print('========================= Event To State (Facebook)========================');
      FirebaseUser _user = await _userRepository.signInWithFacebook();
      LoginState execute;
      if (_user == null) {
        print('the _user is null');
        execute = LoginState.failure();
      } else {
        print('LoginState.success');
        execute = LoginState.success();
      }
      yield execute;
    } catch (_) {
      print('LoginState.failure');
      yield LoginState.failure();
    }
  }

это метод, который возвращает экземпляр пользователя firebase:

Future<FirebaseUser> signInWithFacebook() async {
    FirebaseUser _user;
    print('==================== signInWithFacebook =====================');
    print('awaiting result');
    final _result = await _facebookLogin.logIn(['email']);
    print(_result.toString());
    print('result ready');
    print('verif if with result.status = ${_result.status}');
    if (_result.status == FacebookLoginStatus.loggedIn) {
      print('result.status == logged in');
      final AuthCredential _credential = FacebookAuthProvider.getCredential(
          accessToken: _result.accessToken.token);
      print('awaiting user = FB user');
      await _firebaseAuth.signInWithCredential(_credential);
      _user = await _firebaseAuth.currentUser();
      print('user = FB user check.');
    } else {
      print('result.status != logged in');
      print('status is:');
      print(_result.status);
      _user = null;
    }
    print('user: $_user');
    print('==================== signInWithFacebook end =====================');
    return _user;
  }
...