0

Good morning! I have a strange problem where i can run & authenticate my user on my ios device perfectly fine running the app using the command below.

ionic capacitor run -l --external

Using an emulator, it works sometimes, though not always.

When I try to deploy the app using Xcode, the app opens and looks normal, but if I try to send authentication requests to firebase, the app just keeps on loading, although the requests are successfully performed.

Misbehaving loading screen

Successful requests...

I first thought the problem was because of using LocalStorage so I rebuilt everything using Ionic Storage. But that didn't help.

I tried different versions of adding the Firebase SDK in Swift or in the Cocoa Pods file but the behaviour doesn't change so I don't believe that this is a issue with a wrong firebase configuration, what is the proper way to do this by the way - or is Ionic doing this for me already?

The output of Xcode doesn't provide any valuable information either.

    2021-12-01 11:20:13.990875+0100 App[3162:27661] Writing analzed variants.
2021-12-01 11:20:14.125754+0100 App[3162:27661] KeyboardPlugin: resize mode - native
⚡️  Loading app at capacitor://localhost...
2021-12-01 11:20:14.552490+0100 App[3162:27661] Writing analzed variants.
⚡️  WebView loaded
⚡️  [log] - Angular is running in development mode. Call enableProdMode() to enable production mode.
⚡️  [log] - null
⚡️  To Native ->  App addListener 60635511
2021-12-01 11:20:21.393141+0100 App[3162:27661] [Accessibility] WKContentView[@] set up: @ pid: @ MACH_PORT -830404096

login-function

loginWithEmail() {
    let email: string = this.loginForm.get("email").value;
    let password: string = this.loginForm.get("password").value;

    this.loadingService.present({
      message: "Logging in . . ."
    });

    this.authService
      .loginWithEmail(email, password)
      .then((result) => {
        this.authService.SetUserData(result.user)
        this.resetLoginForm();
        this.loginSuccess();
        this.router.navigateByUrl("/tabs/intensity");
      })
      .catch(error => {
        console.log(error);
        this.loginFailed(error);
      });
  }

login-success

  loginSuccess() {
    this.loadingService.dismiss();

    this.toastService.present({
      message: "Welcome back!",
      duration: 3000,
      color: "secondary"
    });
  }

login-with-email

import { AngularFireAuth } from "@angular/fire/compat/auth";
...
 async loginWithEmail(email: string, password: string) {
    return await this.afAuth.signInWithEmailAndPassword(email, password);
  }

set user-data function

SetUserData(user) {
    this.user = user;
    const userRef: AngularFirestoreDocument<any> = this.afs.doc(`users/${user.uid}`);
    const userData: User = {
      uid: user.uid,
      email: user.email,
      displayName: user.displayName,
      photoURL: user.photoURL,
      emailVerified: user.emailVerified
    }
    return userRef.set(userData, {
      merge: true
    })
  }

Running it multiple times some times I get this error.

API error: <_UIKBCompatInputView: 0x7fb965726040; frame = (0 0; 0 0); layer = <CALayer: 0x600002f718a0>> returned 0 width, assuming UIViewNoIntrinsicMetric

I am really stuck on this and would appreciate any help. Thank you & kind regards.

Ionic 6.18.1 Angular 12.1.5 Xcode Version 13.1 (13A1030d)

d3Roux
  • 307
  • 1
  • 10
  • When you say the request is successfully performed, do you mean the authentication request is fired and it returns a 200 response? And then your app stops working? – Super_Simon Dec 01 '21 at 11:16
  • Yes the request is going through and retrieving the proper information about the user, but somehow the app does not continue after this as otherwise the Loading popup would close according to the code if I get everything right.. trying since days to figure out why this is happening.. Is there something I have to do to be able to use the device storage with Ionic/Storage? – d3Roux Dec 01 '21 at 11:19
  • I don't think it's a storage issue, I think it's a keyboard issue - bizarrely. Have you tried removing the keyboard plugin and retrying? – Super_Simon Dec 01 '21 at 11:22
  • I also can't see where you're dismissing your loading controller, unless you're doing it in your `loginSuccess()` method? – Super_Simon Dec 01 '21 at 11:27
  • @Super_Simon ah sorry I added the loginSuccess method for better insight, I am dismissing it there. What do you mean with removing the keyboard plugin? Need to figure out how to do that :S – d3Roux Dec 01 '21 at 11:30
  • Have you added a keyboard plugin or are you using the standard one with Capacitor? – Super_Simon Dec 01 '21 at 11:33
  • I am just using a normal ion-input of the ionic framework, thought this would work.. https://ionicframework.com/docs/api/input#usage – d3Roux Dec 01 '21 at 11:34
  • Ah yes, then scrap that idea about the keyboard. I'll have a look at see if I can work out what's wrong. – Super_Simon Dec 01 '21 at 11:36
  • @Super_Simon I found out that this problem might result from the AngularFireAuth module whereas the callback is never called although the request has been successful. Think this is a bug somewhere but no idea how to resolve it yet.. anyone other ideas? – d3Roux Dec 02 '21 at 11:48

0 Answers0