inouiw / capacitor-native-google-one-tap-signin

Wraps native android One Tap sign-in api for ionic capacitor apps
MIT License
9 stars 4 forks source link

SIgnIn not being resolved #25

Open taivo1 opened 1 week ago

taivo1 commented 1 week ago

Here

https://github.com/inouiw/capacitor-native-google-one-tap-signin/blob/16485787309e806d2c0dba9d4f01d99719a653f9/src/web/GoogleIdentityServicesClient.ts#L60

and here:

https://github.com/inouiw/capacitor-native-google-one-tap-signin/blob/16485787309e806d2c0dba9d4f01d99719a653f9/src/web/GoogleIdentityServicesClient.ts#L53

the promise is not being handled, maybe it should reject the promise.

I'm having issues when calling tryAutoOrOneTapSignInWithCallback in Web, it just keeps hanging there once I close the dialog.

// Trigger auto sign-in and if not successful try one-tap sign-in. Pass a callback.
await GoogleOneTapAuth.tryAutoOrOneTapSignInWithCallback(onResultHandler);
// this line is never reached due to the previous call is not resolved so the button is not initialized.
// Add a handler to the button shown below. Pass a callback.
await GoogleOneTapAuth.addSignInActionToExistingButtonWithCallback(
  'google-signin-existing-btn-parent', 'google-signin-existing-btn', onResultHandler);
inouiw commented 5 days ago

Hi @taivo1 ,

thank you for posting the issue and for using the plugin. I will check tonight if I can find the error. Currently I am wonderning why the callback method is async. This could explain why the callback is not called. You can try to call tryAutoOrOneTapSignInWithCallback without await.

David

inouiw commented 5 days ago

Hi @taivo1 ,

I tested the code in the demo app and it is working. awaiting the method is correct because it ensures that you get feedback if there is an exception.

Before calling await GoogleOneTapAuth.addSignInActionToExistingButtonWithCallback('google-signin-existing-btn-parent', 'google-signin-existing-btn', onResult);, you need to call GoogleOneTapAuth.initialize({ clientId: clientId });, but I assume you did it because you would get an error result displayed in the developer console if not.

It could be an issue how you defined the existing button. In the demo project it is as follows.

<div id='google-signin-existing-btn-parent'>
    <button id='google-signin-existing-btn' style={{ padding: 20, backgroundColor: '#3dc418' }}>Custom Sign-in Button</button>
</div>

see https://github.com/inouiw/capacitor-native-google-one-tap-signin/blob/main/demo/react/src/pages/Page1.tsx

If this did not help, mybe you could provide more of your code.

inouiw commented 10 hours ago

Hi @taivo1, there were some promises that did not return in case of an exception. I fixed that. Would be great if you could check if you get a proper error result now. The version that includes the fix is 6.1.7

taivo1 commented 5 hours ago

Thanks, after quick testing with my app facing still the same issue, but will try to get you more proper example of my use case in a few days.