Closed codejudas closed 6 months ago
I observed the same behaviour in my expo app and solved it by providing the iosUrlScheme option to the config plugin. You can read more here.
@htcdang I already have this in my app.json
for a few days now of trying to get this working:
"plugins": [
....,
"@react-native-google-signin/google-signin",
{
"iosUrlScheme": "com.googleusercontent.apps.xxxxxxxxx"
}
],
Hello and thanks for reporting,
judging by the stack trace (mentions of unsupportedSchemes
and relevantURLSchemes
) I'm guessing that the error has to to do with checking the url schemes the app supports.
I was unable to reproduce this on my test project so without a runnable reproduction, I won't be able to assist further.
As for the config plugin iosUrlScheme
parameter, please note that this parameter is only available to sponsors of the module, it's not part of the public package.
Finally, in the provided snippet
GoogleSignin.configure({
scopes: [
"https://www.googleapis.com/auth/userinfo.profile",
],
webClientId: Platform.OS === 'android' ? <android_client_id> : <web_client_id>,
iosClientId: Platform.OS === 'ios' ? <ios_client_id> : undefined,
offlineAccess: false,
});
the webClientId
parameter is wrong: it should always be the web client id, not the android_client_id
.
I'm going to close this but feel free to provide a runnable repro so I can debug this. Thank you 🙂
@vonovak Your analysis of the stack trace helped me find the issue! I opened the project in Xcode and in the Info > Url Schemes section there was an empty url scheme for some reason, removing that fixed the crash.
With some trial and error I found that this section I had added to my app.json was causing the empty url schemes:
{
"expo": {
"ios": {
...,
"infoPlist": {
"CFBundleURLTypes": [
{
"CFBundleURLSchemes": "com.googleusercontent.apps.xxxxxxxxxxxxx"
}
]
}
}
}
}
Per [this documentation|https://docs.expo.dev/versions/latest/config/app/#infoplist] on the expo website, but probably I did something wrong. I think I had added this because I had googled some stuff about needing the url bundles in the info.plist and thought that would do it.. evidently not.
Anyways just putting this here in case some other unfortunate soul happens to stumble into the same set of circumstances. Thanks for your help!
I am still facing the same issue! The app is getting crashed on iOS. On Android it is working fine. My app is managed by expo so I cannot use xcode. I am not using the sponsored version.
app.json
"plugins": [ "expo-apple-authentication", [ "@react-native-google-signin/google-signin", { "iosUrlScheme": "com.googleusercontent.apps.xxx-xxx" } ] ], "ios:{ "bundleIdentifier": "myapp", "infoPList": { "CFBundleURLTypes": [{"CFBundleURLSchemes":["com.googleusercontent.apps.xxx-xxx"]}], "UIRequiresFullScreen": true, .....
GoogleLogin.js
const SignIn = async () => { try { GoogleSignin.configure({ webClientId: "xxx-xxx.apps.googleusercontent.com", androidClientId: "xxx-xxx.googleusercontent.com", iosClientId: "xxx-xxx.apps.googleusercontent.com", }) // GoogleSignin.configure({ // scopes: [ // "https://www.googleapis.com/auth/userinfo.profile", // ], // webClientId: Platform.OS === 'android' ? 'xxx-xxx.apps.googleusercontent.com' : 'xxx-xxx.apps.googleusercontent.com', // iosClientId: Platform.OS === 'ios' ? 'xxx-xxx.apps.googleusercontent.com' : undefined, // offlineAccess: false, // }); await GoogleSignin.hasPlayServices(); const userInfo = await GoogleSignin.signIn();
I am unable to get any userInfo, instead the app crashes. Unable to get any logs!
I am using:
"expo": "~49.0.6", "react-native": "0.72.6", "@react-native-google-signin/google-signin": "^11.0.0"
Thanks in advance for any suggestion/help.
The problem is that the config plugin only works when using GoogleService-Info.plist
. I've looked through the code and the config plugin uses expo/config-plugins
IOSConfig.Google.withGoogle
internally which does nothing with iosUrlScheme
and so when you run expo prebuild
it fails to add the scheme to the ios apps Info.plist
.
That's why configuring it directly works. Which is what the expo docs suggest. i.e. You could also add it to ExpoConfig['scheme']
because it can be an array
{
"ios": {
...
"infoPlist": {
"CFBundleURLTypes": [
{
"CFBundleURLSchemes": ["com.googleusercontent.apps.17898xxxxxx-xxxxxqhqj0exxxxxpl03xxx"]
}
]
}
}
}
I'm further confused with this library because the docs reference versions 12 and 13 that do not exist in npm
Is anyone able to solve this yet? I have followed the above steps and still have the same issue of app crashing on clicking 'Google Signin'. The crash occurs when executing Googlesignin.Singin(). Using iOS dev build.
I am using an expo-managed workflow.
This is my app.json
"googleServicesFile": "./GoogleService-Info.plist", "infoPlist": { "CFBundleURLTypes": [ { "CFBundleURLSchemes": ["com.googleusercontent.apps.-----"] } ],
Also tried this:
"plugins": [ [ "@react-native-google-signin/google-signin", { "iosUrlScheme": "com.googleusercontent.apps.--------" } ],
Have also tried adding directly to plist file:
`
I don't know what got it working but I finally did manage to get it working on iOS. I am using Expo managed workflow and I do run it with EAS build to do prebuild step.
@erickreutz Thank you very much. It works!
The app crashes on iOS when clicking the SignIn button, it works on Android.
I've made sure to configure the reverse client id in the url schemes.
I've managed to get the following error from XCode when I reproduce the crash:
(nomad is the name of my app btw)
Reproducing the issue
GoogleSignInButton.tsx
App.tsx
Expected Behavior
Sign in proceeds as expected, console log gets printed.
Actual Behavior
The entire app crashes with a
SIGABRT
signal for versions > 8.x.x, and the exception above for version == 8.x.x.Environment
I've tried the following versions of
@react-native-google-signin/google-signin
:CocoaPods could not find compatible versions for pod "ExpoAdapterGoogleSignIn"
)Emulator iOS version is
iOS 17.0
, i'm running it on an M2 Mac if that matters. React Native version is0.72.6
Expo version is49.0.15
Podfile is auto-generated by expo, but I've configured it to add this line based on various stack overflow/github issues trying to debug the crash: