我们已经向商店发布了本机 IOS 和 Android 应用程序。目前即将完成 react-native 版本以替换原生应用程序。React-native 应用程序使用与原生相同的 firebase 项目。Firebase 身份验证适用于原生应用和 react-native android 应用。在 react-native ios 上,我们无法使用 google 登录。
错误日志:
错误:[auth/internal-error] 发生内部错误,请重试。NativeFirebaseError: [auth/internal-error] 发生内部错误,请重试。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 调用@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 调用@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:
很难从错误消息中找出到底出了什么问题。
当我们配置 react-native IOS 应用程序以使用登录到其他 Firebase 项目(用于开发目的)时,谷歌登录工作正常。在这两种情况下,IOS 捆绑包 ID 都是相同的。
所有与应用程序相关的代码和配置都根据react-native-firebase 库文档完成。
在新创建的具有相同 IOS 捆绑 ID 且未添加任何其他辅助功能代码的新创建的 react-native 项目上,该问题也可重现。
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;
当在生产 Firebase 实例上添加具有其他包 ID 的新 IOS 项目并将这些包设置为 react-native 应用程序时,Firebase 身份验证运行良好。
所以它看起来不像反应本机应用程序代码中的问题,而是与捆绑ID相关的问题。同时,具有相同捆绑 ID 的 IOS 原生应用运行良好。
帮我找出 Firebase 身份验证不起作用的原因?