Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
Problema de inicio de sesión de AngularFireAuth e Ionic 5

He estado trabajando en una nueva aplicación para iOS y Android. Lo estoy desarrollando en Angular 12 usando Ionic 5 , Capacitor y Firebase 9 .

Si bien estoy acostumbrado a configurar páginas de autenticación (inicio de sesión/registro/restablecimiento de pwd) con AngularFireAuth, tengo problemas para hacer lo mismo con Ionic y Capacitor. Mis páginas, servicios y guardias funcionan bien en el navegador, pero tan pronto como ejecuto "sincronización de tapa iónica", construyo en XCode e intento ejecutarlo en mi iPhone, mi función de inicio de sesión no se ejecuta.

Aquí está mi código hasta ahora:

Servicio de autenticación:

 import { Injectable, NgZone } from '@angular/core'; import { User } from './authUser.model'; import { Router } from '@angular/router'; import { AngularFireAuth } from '@angular/fire/compat/auth'; import { AngularFirestore, AngularFirestoreDocument } from '@angular/fire/compat/firestore'; @Injectable({ providedIn: 'root' }) export class AuthService { userData: any; constructor( public afStore: AngularFirestore, public ngFireAuth: AngularFireAuth, public router: Router, public ngZone: NgZone ) { this.ngFireAuth.authState.subscribe(user => { if (user) { this.userData = user; localStorage.setItem('user', JSON.stringify(this.userData)); JSON.parse(localStorage.getItem('user')); } else { localStorage.setItem('user', null); JSON.parse(localStorage.getItem('user')); } }); } // Login in with email/password SignIn(email, password) { console.log('signing in from service'); return this.ngFireAuth.signInWithEmailAndPassword(email, password); }

Página de inicio de sesión:

 import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AuthService } from '../shared/auth.service'; @Component({ selector: 'app-login', templateUrl: './login.page.html', styleUrls: ['./login.page.scss'], }) export class LoginPage implements OnInit { constructor( public authService: AuthService, public router: Router ) { } ngOnInit() { } logIn(email, password) { this.authService.SignIn(email.value, password.value) .then((res) => { console.log('signing in from page'); if (this.authService.isEmailVerified) { this.router.navigate(['tabs']); } else { window.alert('Email is not verified'); return false; } }).catch((error) => { console.log(error); window.alert(error.message); }); } }

¡Gracias por tus aportes!

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

He degradado así y luego no hay problemas. Pero esto es muy decepcionante, ya que no podemos usar las funciones nuevas y las mejoras de rendimiento de la última versión de Firebase ahora con las aplicaciones iOS nativas de Ionic.

 npm un @angular/fire firebase npm i @angular/fire@6.1.5 firebase@8.9.0

Nota: también debe cambiar las importaciones de esta manera en todos los lugares:

 import { AngularFireAuth } from '@angular/fire/auth';
over 4 years ago · Santiago Trujillo Report

0

Si usa pods de importación de Cocoapods/FirebaseAuth

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!