React Native Google Sign-In (@react-native-community/google-signin). error.code === statusCodes.IN_PROGRESS

1.4k Views Asked by At

I have successfully implemented google-signin into my RN app with Firebase using code below. When I click button first time it creates FB account....then subsequent times it logs me in.

Everything works fine.....but then from time to time when I click to log in, it returns the error code of statusCodes.IN_PROGRESS I want to be able to handle this error (by terminating sign-in or something??) but have no idea how.....can anyone help?

p.s. exact line of code causing error = const {accessToken, idToken} = await GoogleSignin.signIn();.....its also giving me this warning Warning: previous promise did not settle and was overwritten. You've called "signIn" while "signIn" was already in progress and has not completed yet.

import firebase from '@react-native-firebase/app';
import auth from '@react-native-firebase/auth';
import {GoogleSignin, statusCodes} from '@react-native-community/google-signin';
import {LoginManager, AccessToken} from 'react-native-fbsdk';

export const _getFbGoogleCredential = async () => {
  await GoogleSignin.hasPlayServices();
  const {accessToken, idToken} = await GoogleSignin.signIn();

  const firebaseCredential = await auth.GoogleAuthProvider.credential(idToken, accessToken);
  return firebaseCredential;
};

export const _googleSignIn = async () => {
  try {
    const firebaseCredential = await _getFbGoogleCredential();
    const fbUserObj = await auth().signInWithCredential(firebaseCredential);

  } catch (error) {
    if (error.code === 'auth/account-exists-with-different-credential') {
      //xx
    } else if (error.code === statusCodes.SIGN_IN_CANCELLED) {
      //xx
    } else if (error.code === statusCodes.IN_PROGRESS) {
      //HERE IS THE ISSUE
    } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
      //xx
    } else {
      //xx
    }
  }
};
1

There are 1 best solutions below

0
On

I also had this same error

Warning: previous promise did not settle and was overwritten. You've called "signIn" while "signIn" was already in progress and has not completed yet.

and i was able to fix is by NOT using GoogleSigninButton that comes with the package @react-native-google-signin/google-signin

The GoogleSigninButton has a bug so just use any other button component...weird fix but hey it works. Behold the culprit