Open panstromek opened 1 month ago
Using the repo latest code, ie later than RC4 but don't know if different, I was able to get Google sign in to work under Capacitor 6 on an iPhone on iOS 17.6. Do you need to add await in front of your calls? If you are in an app, then miss out the initialize() parameters?
In my Android and iOS app I simply have this with no await:
GoogleAuth.initialize()
and then when button pressed have this to sign in:
const response = await GoogleAuth.signIn();
If I restart my app and the login has been saved, then initialize won't have been called, so to log out I do this with await
try {
await GoogleAuth.initialize()
await GoogleAuth.signOut()
} catch (e) {
}
I don't think the problem is missing await
, because the crash happens no matter how long I wait between init/signIn.
Either way, something like this shouldn't cause a full app crash anyway, it should just be a rejected Promise at worst.
I'm facing the same issue on android the catlog is giving init error
`user: User | null = null;
constructor() { } ngOnInit(): void { GoogleAuth.initialize()
} async signIn() { this.user = await GoogleAuth.signIn() as User; console.log(this.user);
} async refresh() { const authCode = await GoogleAuth.refresh(); console.log('refresh', authCode); } async signOut() { await GoogleAuth.signOut() this.user = null; } } `
Seems like the backtrace points to this line in GoogleSignIn iOS package:
https://github.com/google/GoogleSignIn-iOS/blob/6.2.4/GoogleSignIn/Sources/GIDSignIn.m#L529
which throws with error Your app is missing support for the following URL schemes: ..."
. So it seems like it's something with the url schemes, not sure what yet.
The iOS package already has new major version, btw, but I'm not sure if upgrading that could help.
same problem, i downgraded to rc.v2. For IOS works but not for Android, the opposite as v4.
Update: i deleted the plugin and reinstalled last version "@codetrix-studio/capacitor-google-auth": "github:CodetrixStudio/CapacitorGoogleAuth", now it's working also for IOS.. really weird
@davidepoletti21 - I agree - this bug is super weird - can you confirm which version you have now that you "reinstalled last version" - do you mean you're on 3.3.6 and not one of the release candidates and it's working for you?
@davidepoletti21 - I agree - this bug is super weird - can you confirm which version you have now that you "reinstalled last version" - do you mean you're on 3.3.6 and not one of the release candidates and it's working for you?
that's the problem. I did npm install "CodetrixStudio/CapacitorGoogleAuth and if i check the version with npm list it says 3.4.0-rc.4. But some days ago with that version IOS wasn't working, deleted and reinstalled and now it's working either on Android and IOS.. who knows
@davidepoletti21 @panstromek I'm having the same issues with version3.4.0-rc.4. and capacitor 6. any solution to work properly ios/android?
@jhenriquez07 no i'm still getting the problem. Even if on my device is working i'm receiving many feedback about crash on IOS with google sign-in. Apple review also rejected my last build because of that
@jhenriquez07 @davidepoletti21 I believe you should call the GoogleAuth.initialize
method regardless of whether the platform is web or not.
@jhenriquez07 @davidepoletti21 I believe you should call the
GoogleAuth.initialize
method regardless of whether the platform is web or not.
thanks. that's it now ios and android works fine
In my case, the crash seems to go away when I remove clientId from the initialize call (based on this comment https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues/378#issuecomment-2290472677):
GoogleAuth.initialize({
// clientId: '...',
grantOfflineAccess: false,
});
The problem seems to be that this clientId (in my case) was not the correct clientId for iOS. I'll see if this fixes the issue for other users and works for all platforms when I release a new version of the app.
Either way - the crash is definitely a problem. The plugin should catch the exception thrown by the Google Auth library and reject the promise with the error message instead.
I made a PR to update the doc for v6. ClientId is now use in priority from initialize function. If you want to keep the same behavior as before do not send it in mobile. Or send the right one for each platform
Version of the plugin: RC4
code:
capacitor.config.ts entry
I got the exception from test flight reports.
This points to this line in the code:
https://github.com/CodetrixStudio/CapacitorGoogleAuth/blob/e808d9e642c893aab11936aee05853d27e371309/ios/Plugin/Plugin.swift#L85
Seems like it could be null pointer exception? I don't know enough about Swift to tell.