Firebase Auth doesn't work on F7 + Cordova + IOS (location.protocol must be http, https ...)

Hi, I’m writing this cuz i am suffering from firebase auth.

I followed this to enable firebase auth on cordova app:
https://firebase.google.com/docs/auth/web/cordova

It works perfectly on cordova android build,
and it also works on PWA(both of ios and android),
but on cordova ios build, it throws an error like this
Error: This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.

I used signInWithRedirect method because it’s the only option to use firebase auth on cordova app.

I tried search simillar cases with me, but any of thoes couldn’t solve my problem.

Can I get advices for this problem?

Thx to reply,
I already checked that post but i understand that the answer is not for cordova environment.

As i wrote above, firebase is providing a way to use javascript(web) sdk on cordova app ( Authenticate Using OAuth Providers with Cordova  |  Firebase ),
and it works on cordova-android app.

If i use firebase iOS sdk i need to work using iOS native.
Is this the only way? :sob:

Btw, I solved many problems from your comments on this forum. Thx always.

You need to use some firebase cordova plugin that will use native SDK, not the web one

I solved this problem by using plugins which nolimits4web mentioned.

After get auth credentials with those plugins,
I tried to auth.signInWithCredential method which is included on Firebase JS SDK.

Thx.

Which plugin do You use?

This tripped me up a while back. You can solve this without a plugin by using ‘browserLocalPersistence’ if you are in a capacitor app. This is my current working code in a v8+vue3 project:

import { initializeApp, getApps } from "firebase/app";
import { getFirestore, connectFirestoreEmulator } from "firebase/firestore";
import {
browserLocalPersistence,
getAuth,
initializeAuth,
} from "firebase/auth";
import { Capacitor } from "@capacitor/core";

const firebaseConfig = {...}

export const firebaseApp = !getApps().length
	? initializeApp(firebaseConfig)
	: getApps();
export const db = getFirestore(firebaseApp);

export const auth = Capacitor.isNativePlatform()
? initializeAuth(firebaseApp, { persistence: browserLocalPersistence })
: getAuth();

Hope this helps you!

1 Like

Thanks for your response.
I am using Cordova.
I’ll check if I can adapt.