[@nativescript/google-signin] Google button not emitting tap event
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>
Which platform ?
Android
I am using Vanilla JS (no Angular) but having the same issue as well on Android.
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.
I tried something similar to what @felixkrautschuk did, and I also wasn't able to get the tap event to raise on Android.
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();
}
}));
}
}
Fixed in v2 latest.