ioni c 5 войти в систему с помощью Google с помощью AngularFireAuth на android не удается - PullRequest
0 голосов
/ 27 мая 2020

Я использую ioni c 5 с firebase и использую angularFireAuth, чтобы пользователь мог войти в систему с помощью Google. Я включил вход в консоль firebase и добавил также отпечаток sha1.

в Интернете все работает нормально, но тот же код при развертывании на устройстве ведет себя совсем по-другому.

  1. приведенный ниже код в конструкторе возвращает нулевого пользователя
 this.afAuth.authState.subscribe(async user => {
      console.log("core.js construct afAuth with user", user)
      if (user){
        this.userName = user.displayName;
        this.uid = user.uid
        this.photoURL = user.photoURL
        this.email = user.email

        console.log("logged in user. ensure an account exists if not then create it")
        const payload = {
          "uid": this.uid,
          "userName": this.userName,
          "photoURL": this.photoURL,
          "email": this.email
        }
        await this.boardSvc.updateUser(this.uid, payload)
        this.loggedIn = true
      }
    })
кнопка, которая вызывает приведенный ниже код для входа в систему с помощью Google, открывает вкладку браузера, и на этой вкладке отображается пустая страница. возвращение в приложение по-прежнему не означает входа в систему.
  OAuthProvider(provider) {
      return this.afAuth.signInWithPopup(provider)
          .then((res) => {
              this.ngZone.run(() => {
                  this.router.navigate(['']);
              })
          }).catch((error) => {
              window.alert(error)
          })
    }


  SigninWithGoogle() {
    console.log("start of signin")
    if(this.core.loggedIn === true){
      this.modal.dismiss()
      return
    }
    return this.OAuthProvider(new auth.GoogleAuthProvider())
        .then(res => {
            console.log('Successfully logged in!')
            this.core.loggedIn = true
            this.modal.dismiss()
        }).catch(error => {
            console.log(error)
        });
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...