We have native IOS and Android apps already published to stores. Currently about to finish react-native version to replace native apps. React-native app uses same firebase project that native. Firebase authentication works well on native apps and react-native android app. On react-native ios we are failed to sign in with google.
Error log:
Error: [auth/internal-error] An internal error has occurred, please try again. NativeFirebaseError: [auth/internal-error] An internal error has occurred, please try again. onGoogleButtonPress$@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:98254:89 tryCatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28586:23 invoke@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28759:32 tryCatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28586:23 invoke@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28659:30 http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28669:21 tryCallOne@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3475:16 http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3576:27 _callTimer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30574:17 _callImmediatesPass@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30613:17 callImmediates@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30830:33
It's hard to figure out what exactly went wrong from error message.
When we configuring react-native IOS app to use sign in into other Firebase project (used for dev purpose), google sign in works fine. In both cases IOS bundle id is same.
All app related code and configuration done accordingly to react-native-firebase library docs.
The issue is also reproducible on newly created react-native project with same IOS bundle id and without any other side functionality code added.
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Button,
StatusBar,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import {GoogleSignin} from '@react-native-community/google-signin';
import auth from '@react-native-firebase/auth';
const App: () => React$Node = () => {
async function onGoogleButtonPress() {
const {idToken} = await GoogleSignin.signIn();
const googleCredential = auth.GoogleAuthProvider.credential(idToken);
return auth().signInWithCredential(googleCredential);
}
GoogleSignin.configure({
webClientId:
'<PASTE CLIEND ID FROM GoogleService-Info.plist>',
});
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<View style={styles.body}>
<Button
title="Google Sign-In"
onPress={() =>
onGoogleButtonPress().then(() =>
console.log('Signed in with Google!'),
)
}
/>
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
body: {
backgroundColor: Colors.white,
},
});
export default App;
When added new IOS project with other bundle ID on production Firebase instance and set those bundle into react-native app, Firebase authentication works well.
So it does not look like issue in react native-app code, but something related to bundle id. In same time IOS native app with same bundle id works well.
Help me find out the reason why Firebase authentication does not work?
pod installin the React Native project ios folder. Also check that your GoogleServices-info.plist is in the same directory as your info.plist and that you added that file using Xcode and not just put it in the RN ios folder.