Кросс-платформа Ionic4 Firebase Google Auth не работает с React - PullRequest
0 голосов
/ 12 июля 2020

Войдите в систему с помощью Google на двух платформах, android и настольном Интернете. Когда я нажимаю кнопку входа в веб-сценарий, ничего не происходит.

Когда я нажимаю кнопку входа в сценарий android, появляется панель аутентификации Google. После того, как я выберу свою учетную запись Gmail для входа, ничего не произойдет. Ожидается перенаправление на главную / панель управления.

Кнопка для входа в систему.

<IonButton color="red" expand="full" onClick={googleLoginWebOrMobile} >
                                    Google+
                                </IonButton>
function googleLoginWebOrMobile() {
        if(isPlatform('capacitor')) {
            return nativeGoogleLogin();
        } else {
            return webGoogleLogin();
        }
    }
    
    async function nativeGoogleLogin(){
        GooglePlus.login({
            'webClientId':'xxx.xxx.xxx',
            'offline': true
        }).then(async res=>{
            await firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken)).
            then(succes=>{
                history.replace('/home/dashboard')
                history.go(history.length)
                toast("Logare cu succes!")
            }).catch(ns=>{
                toast("Logare eșuată cu Google")
            })
        })
    
    }

    async function webGoogleLogin(){
        GooglePlus.login({
            'webClientId':'xxx.xxxx.xx,
            'offline': true
        }).then(async res=>{
            const provider = new firebase.auth.GoogleAuthProvider();
            return  await firebase.auth().signInWithPopup(provider).
            then(succes=>{
                history.replace('/home/dashboard')
                history.go(history.length)
                toast("Logare cu succes!")
            }).catch(ns=>{
                toast("Logare eșuată cu Google")
            })
        })
    }
...