HELP! How do I integrate native firebase google login with my capacitor app?

I am losing my mind. I have tried so many things.
First, I tried this:

I got the token from google and then I sent the token to my backend nodejs api where I verified the token and created a new token and passed back to the ionic app. This was working just fine on my local system on browser but then I realized that it does not open a native google login screen in emulator/phone but opens a browser popup. That looks horrible.

So I tried,

Didn’t work. Also, this seems to be not a very popular plugin, looking at the weekly downloads.

I am very new to ionic and mobile development in general. Could someone for the love of God please point to something that will see me all the way through implementing social login in my ionic app?

I am using Capacitor + angular + ionic 4.

Hi,

The thing is Firebase web library needs the app to be served from origins with the file:// or ionic:// scheme.

This is required so that Firebase Auth can properly handle signInWithRedirect and signInWithPopup operations.
Firebase Auth will treat http://localhost origins as web-based browser apps.

Capacitor apps are hosted on a local HTTP server and are served with the http:// protocol, so there is no match between these protocols.

For this reason, we need to use the native SDKs to perform social authentication from our native (iOS and Android) apps.

I used Capacitor Firebase Auth plugin to perform native login with Google, Facebook and Twitter and it works like a charm!

The plugin handles the authentication on Native layer and propagate the token to the web view layer. After the sign-in process completes, the user will be signed in within both tiers.

I wrote a twitter thread about this with more information. Hope it helps!

Thank you, Dayana. Let me try that out and get back to you.

error: package com.baumblatt.capacitor.firebase.auth does not exist
 import com.baumblatt.capacitor.firebase.auth.CapacitorFirebaseAuth;

I tried executing : npx cap sync as suggested here :here

But it didn’t solve it.

Can you please share your ionic info output?

I started fresh. Now I am getting the in-app login screen. I am also getting the permission screen. But after that the app crashes.

Error in android studio console:

D/CapacitorFirebaseAuth: Firebase Sign In with Credential succeed.
    Building authentication result
W/o.ionic.starte: Accessing hidden method Ljava/lang/invoke/LambdaMetafactory;->metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; (blacklist, linking, denied)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: io.ionic.starter, PID: 18641
    java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)
        at com.getcapacitor.MessageHandler.sendResponseMessage(MessageHandler.java:91)
        at com.getcapacitor.PluginCall.success(PluginCall.java:56)
        at com.baumblatt.capacitor.firebase.auth.CapacitorFirebaseAuth$2.onComplete(CapacitorFirebaseAuth.java:213)
        at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process: Sending signal. PID: 18641 SIG: 9

ionic info:

Ionic:

   Ionic CLI                     : 5.4.16 (C:\Users\arbaaz\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 5.3.4
   @angular-devkit/build-angular : 0.1000.8
   @angular-devkit/schematics    : 10.0.8
   @angular/cli                  : 10.0.8
   @ionic/angular-toolkit        : 2.3.3

Capacitor:

   Capacitor CLI   : 2.4.2
   @capacitor/core : 2.4.2

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v12.18.3 (C:\Program Files\nodejs\node.exe)
   npm    : 6.14.6
   OS     : Windows 10

Hi, I am trying to use capacitor-firebase-auth for authentication too. However, it returned “Google Sign In failure.” when I tried to use the cfaSignIn() method in the Android emulator. Please help.