plugins icon indicating copy to clipboard operation
plugins copied to clipboard

[@nativescript/google-signin] Google button not emitting tap event

Open guillemc23 opened this issue 4 years ago • 6 comments

Hello guys, I'm using Angular for my project and after loading the Google Button, it does show and render perfectly, but its not emitting its tap event.

I'm importing it as:

registerElement('GoogleSignInButton', () => require('@nativescript/google-signin').GoogleSignInButton);

and then using it as

<GoogleSignInButton #googleBtn row="1" colorScheme="light" colorStyle="wide" (tap)="handleSignIn()" [isEnabled]="!processing"></GoogleSignInButton>

guillemc23 avatar Nov 07 '21 23:11 guillemc23

Which platform ?

triniwiz avatar Nov 08 '21 05:11 triniwiz

Android

guillemc23 avatar Nov 08 '21 12:11 guillemc23

I am using Vanilla JS (no Angular) but having the same issue as well on Android.

felixkrautschuk avatar Jan 03 '22 17:01 felixkrautschuk

I also tried to register a tap-handler from the loaded-event of the Button like this:

XML <ui:GoogleSignInButton loaded="onGoogleSignInButtonLoaded"/>

TS

export function onGoogleSignInButtonLoaded(args: EventData) {
  const btn = args.object as GoogleSignInButton;

  btn.on(Button.tapEvent, (args: TapGestureEventData) => {
    alert("TAP!");
  });
}

While the loaded event handler is called as expected, the tap event is still not raised on Android.

felixkrautschuk avatar Jan 04 '22 10:01 felixkrautschuk

I tried something similar to what @felixkrautschuk did, and I also wasn't able to get the tap event to raise on Android.

guillemc23 avatar Apr 28 '22 11:04 guillemc23

I made some further investigations and it seems that this issue occurs on the native Android GoogleSignInButton as well, where the android:onClick="myClickMethod" is not working. https://stackoverflow.com/questions/41046869/google-sign-in-button-not-responding https://stackoverflow.com/questions/27303642/google-sign-in-button-not-working-android

The "solution" is to add the click listener in code:

export function onGoogleSignInButtonLoaded(args: EventData) {
    const googleSignInButton = args.object as GoogleSignInButton;

    if(isAndroid) {
        googleSignInButton.android.setOnClickListener(new android.view.View.OnClickListener({
            onClick: () => {
                doGoogleSignIn();
            }
        }));
    }
}

felixkrautschuk avatar Jul 06 '22 16:07 felixkrautschuk

Fixed in v2 latest.

NathanWalker avatar May 17 '23 23:05 NathanWalker