我试图将GoogleSignin集成到我的react-native应用程序中。
但我得到了一个例外,因为:
"您的应用缺少对以下网址方案 [#id.apps.googleusercontent.com] 的支持"在目标 RNGoogleSign 上使用参数调用登录时引发 ( )
我已经参考了反应原生谷歌登录链接
请帮忙。提前谢谢。
参考 反应原生谷歌登录 iOS 登录问题
和提伯鲁米海的答案
'对我来说,我在JS文件#id.apps.usercontent.com 中使用了#id.apps.googleusercontent.com 而不是#。
验证您是否在 INFO.plist 和 js 文件中定义了相同的 URL 方案,如下所示:
await GoogleSignin.configure({
iosClientId: '#id.apps.googleusercontent.com',
webClientId: '#id.apps.googleusercontent.com',
offlineAccess: false
});
然后在您的 INFO.plist 中,URL 应该是:
'com.googleusercontent.apps.#id' 和 "#id.apps.googleusercontent.com" 这解决了我的问题。
我的答案
我需要将两个网址方案添加到信息列表文件中,如下所示:
'com.googleusercontent.apps.#id'
和
"#id.apps.googleusercontent.com">
以及捆绑标识符。
发生这种情况是因为我已经在JS文件中添加了ClientId,如链接中所示:
GoogleSignin.configure({
iosClientId: <FROM DEVELOPER CONSOLE>, // only for iOS
}).then(() => {
// you can now call currentUserAsync()
});
但它只要求添加REVERSED_CLIENT_ID
在"信息"面板中配置 URL 类型
添加方案设置为REVERSED_CLIENT_ID的 URL(在 plist 中找到)
我通过替换正确的文件 googleservice-info.plist 解决了这个问题 我正在使用另一个项目中的另一个文件。请注意,您的GoogleService-info.plist来自相关的Firebase。