javascriptionic-frameworkfirebase-authenticationangularfire

signInWithEmailAndPassword in AngularFireAuth not response(stuck) for successful user credentials only on iPad devices on ionic cordova application


I developed an ionic cordova application that connected to the firebase backend. It is working perfect for the android applications.

When I built it to the ios and run using XCode iPhone simulators(Ex: iPhone 12, 13, 14, 15), it is working good.

But after run on the iPAD devices like iPad Air(5th Generation), it is only responds to the invalid login credentials and nothing responds to the successful user credentials.

Here, is my package json file.

 "dependencies": {
    "@angular/animations": "^16.0.0",
    "@angular/cdk": "^16.0.0",
    "@angular/common": "^16.0.0",
    "@angular/compiler": "^16.0.0",
    "@angular/core": "^16.0.0",
    "@angular/fire": "^16.0.0",
    "firebase": "^9.7.0",
    ...........................
  }

App-component.ts

  const app = initializeApp(environment.firebaseConfig);
  console.log('ios => ', this.platform.is('ios'));
  console.log('hybrid => ', this.platform.is('hybrid'));
  if (this.platform.is('ios')) {
    initializeAuth(app, {
      persistence: indexedDBLocalPersistence
    });
  }

LoginService.ts

this.angularFireAuth
      .signInWithEmailAndPassword(email, password)
      .then(res => {
        console.log('Login success => ', res);
        ...............
....................

I tried different solutions like "downgrade firebase version" etc. But it did not resolved this issue for the iPad devices.

Does anyone got this issue before? Please help!


Solution

  • I fixed this problem with the below changes.

    1. First, I convert my ionic cordova project to an ionic capacitor project. (Angular v17.0.2, @angular/fire v17.0.1)

    2. Updated the login method as below.

    LoginService.ts

    import {Auth,signInWithEmailAndPassword} from '@angular/fire/auth';
    
    constructor(private auth: Auth,
                .................
    
    async login(email: string, password: string) {
        try {
          const res = await signInWithEmailAndPassword(this.auth, email, password);
          if (res && res.user && res.user.refreshToken) {
              .........................
          }
        } catch (e: any) {
              .........................
        }
    }