Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Not compatible with iOS 16.2 #817

Open
5 of 17 tasks
gabriujo opened this issue Feb 6, 2025 · 9 comments
Open
5 of 17 tasks

bug: Not compatible with iOS 16.2 #817

gabriujo opened this issue Feb 6, 2025 · 9 comments

Comments

@gabriujo
Copy link

gabriujo commented Feb 6, 2025

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Functions
  • Cloud Messaging
  • Cloud Storage
  • Performance
  • Remote Config

Version

6.3.1

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

The app works perfectly on devices with iOS 17 and 18 but with previous versions, for example 16.2, it shows a blank screen as soon as it starts. In the XCode console I see the following error when starting the application:

[ FirebaseAuthentication ] <CapacitorFirebaseAuthentication.RuntimeError: 0x60000298b8e0>

I need to have support for at least iOS version 16 and this is blocking me from developing and publishing the app.

Expected behavior

That the application starts without problems on iOS versions >=16.

Reproduction

Steps to reproduce

Other information

No response

Capacitor doctor

Before submitting

  • I have read and followed the bug report guidelines.
  • I have attached links to possibly related issues and discussions.
  • I understand that incomplete issues (e.g. without reproduction) are closed.
@gabriujo gabriujo added bug/fix Something isn't working needs: triage labels Feb 6, 2025
@robingenz
Copy link
Member

I've just tested it and I cannot reproduce your issue. It works fine for me on iOS 16. Feel free to debug it yourself and create a PR.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

This issue has been labeled as needs: reproduction. This label is added to issues that need a code reproduction.

Please provide a Minimal, Reproducible Example using this template in a public GitHub repository so we can debug the issue.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for us to reproduce the issue.

@wayzie-jm
Copy link

wayzie-jm commented Feb 11, 2025

I'm using version 7 of Capacitor and @capacitor-firebase/authentication and am having the same issue on iOS 17 and 18.

⚡️ Loading app at capacitor://localhost... [ FirebaseAuthentication ] <CapacitorFirebaseAuthentication.RuntimeError: 0x30261e500>

Can someone weigh in on whether the current version still requires the fix mentioned here? I ask because this dates back to Capacitor 3 and there is no mention of this in the current docs. I attempted this change but it did not address the issue.

Just adding that I'm using next.js.

@wayzie-jm
Copy link

I created a minimal example in next.js. It produces the same error although the app does partially load. I hope this helps either identify a mistake on my end or the cause of the error in just a few files.

firebase.js:

import { initializeApp } from "firebase/app";
import { getAuth, indexedDBLocalPersistence, initializeAuth } from "firebase/auth";
import { getFirestore } from 'firebase/firestore'; 
import { getStorage } from 'firebase/storage';
import { getFunctions } from 'firebase/functions';
import { Capacitor } from '@capacitor/core';



const firebaseConfig = {
  apiKey: "xxx,
  authDomain: "xxx",
  databaseURL: "xxx",
  projectId: "xxx,
  storageBucket: "xxx",
  messagingSenderId: "xxx",
  appId: "xxx",
  measurementId: "xxx"
};

const app = initializeApp(firebaseConfig);

const getFirebaseAuth = async () => {
    if (Capacitor.getPlatform() !== 'web') { 
      try {
          const auth = initializeAuth(app, {
              persistence: indexedDBLocalPersistence, 
            });
          return auth;
      } catch (error) {
          console.error("Error initializing Firebase Auth for Capacitor:", error);
          return null; 
      }
    } else {
      return getAuth(app); 
    }
  };
  
  let auth;
  
  (async () => {
      auth = await getFirebaseAuth();
  })();
  
  const db = getFirestore(app);
  const storage = getStorage(app); 
  const functions = getFunctions(app);

  
  export { auth, db, storage, functions }; 

auth.js (auth provider):

'use client'
import React, { createContext, useState, useEffect, useContext } from 'react';
import { onAuthStateChanged } from "firebase/auth";
import { auth } from './firebase'; 

const AuthContext = createContext();

export const AuthProvider = ({ children }) => {
  const [authUser, setAuthUser] = useState(null);
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    const unsubscribe = onAuthStateChanged(auth, (user) => {
      setAuthUser(user);
      setIsLoading(false);
    });

    return () => unsubscribe(); 
  }, []);

  return (
    <AuthContext.Provider value={{ authUser, isLoading }}>
      {children}
    </AuthContext.Provider>
  );
};

export const useAuth = () => useContext(AuthContext);

layout.js:

import { AuthProvider } from "../../firebase/auth";
import './globals.css';

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <AuthProvider> {/* Wrap your app with AuthProvider */}
          {children}
        </AuthProvider>
      </body>
    </html>
  );
}

page.js:

'use client'
import { useEffect, useState } from 'react';
import { Capacitor } from '@capacitor/core';
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

export default function Home() {
  const [user, setUser] = useState(null);
  const [error, setError] = useState(null);

  useEffect(() => {
    const checkAuth = async () => {
      try {
        const currentUser = await FirebaseAuthentication.getCurrentUser();
        console.log("Current User:", currentUser);
        setUser(currentUser);
      } catch (err) {
        console.error("Firebase Auth Error:", err);
        setError(err);
      }
    };

    checkAuth();
  }, []);

  return (
    <div>
      <h1>Firebase Auth Test</h1>
      {user && <p>User is logged in: {user.uid}</p>}
      {error && <p>Error: {error.message}</p>}
    </div>
  );
}

@robingenz
Copy link
Member

I need a minimum, reproducible example as described here.

@wayzie-jm
Copy link

I need a minimum, reproducible example as described here.

Happy to help but in my case the issue may be related to next.js. Do you have a next.js template you would like me to use?

@robingenz
Copy link
Member

If it's related to Next.js, then it's probably not an issue with this plugin but with your implementation. We can only provide support for the plugin since our time is limited. That's why we need this minimal, reproducible example.

@wayzie-jm
Copy link

We can move this to a separate issue as I feel I strayed from the original bug. It seems even the demo app throws this runtime error so I think it's unrelated. I believe this is an issue with the plugin.

[ FirebaseAuthentication ] <CapacitorFirebaseAuthentication.RuntimeError: 0x301286f60>

@robingenz
Copy link
Member

I'm not able to reproduce it with the demo app. That's my problem. Feel free to debug it and create a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants