When using firebase.auth().signInWithPopup(googleAuthProvider);
, it works fine in the web app, but nothing happens in the iOS simulator using Ionic Capacitor. Do I need to use some kind of in app browser? Is there another way to sign in with google using Ionic Capacitor?
EDIT: I've started using @capacitor-firebase/authentication as suggested. Here's what I've done so far:
yarn add @capacitor-firebase/authentication
import { FirebaseAuthentication } from "@capacitor-firebase/authentication";
import { GoogleAuthProvider } from "firebase/auth";
...
const result = await FirebaseAuthentication.signInWithGoogle();
// 2. Sign in on the web layer using the id token
const credential = GoogleAuthProvider.credential(
result.credential?.idToken
);
firebase.auth().signInWithCredential(credential);
plugins: {
FirebaseAuthentication: {
skipNativeAuth: false,
providers: ["google.com"],
},
},
Yet when clicking the “Sign In With Google” button. Nothing happens, but I would expect a popup to appear to be able to log in with google.
You need to use the Firebase Android and iOS SDK. The Firebase JS SDK has some limitations in the web view. Here is an example using a Capacitor Firebase Authentication plugin:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signInWithGoogle = async () => {
const result = await FirebaseAuthentication.signInWithGoogle();
return result.user;
};