cordova-plugin-firebase-authentication icon indicating copy to clipboard operation
cordova-plugin-firebase-authentication copied to clipboard

auto authentication doesn't trigger onAuthStateChanged()

Open skibaalex opened this issue 4 years ago • 2 comments

tried to both solutions i found in here.

`his.auth.verifyPhoneNumber(phoneNumber, 120000).then(async verificationId => { if(verificationId){ loading.dismiss() const alert = await this.alertCtrl.create({ header: 'Verify phone number', message: 'Please provide the SMS code you received on your phone.', inputs: [ { name: 'code', type: 'tel', placeholder: 'SMS Code' }, ], buttons: [ { text: 'Cancel', role: 'cancel', cssClass: 'secondary',

          handler: (blah) => {
            console.log('Confirm Cancel: blah');
          }
        }, {
          text: 'Okay',
          handler: (data) => {
            loading.present()
            this.auth.signInWithVerificationId(verificationId, data.code).then(async res => {
              console.log(res);
              this.toast.show('Signed in')
              this.router.navigate(['home'])
            })
          }
        }
      ]
    });
    await alert.present();
  } else {
    await loading.dismiss()
    this.router.navigate(['home', 'menu'])
  }

this.auth.onAuthStateChanged().subscribe(user => { if(user){ this.user.next(user) this.router.navigate(['home', 'menu']) } else{ this.user.next(null) this.router.navigate(['login']) } })`

skibaalex avatar Jun 18 '20 06:06 skibaalex

also tried to run it as a sync function got the same result

skibaalex avatar Jun 18 '20 07:06 skibaalex

have you solved it?

zelony avatar Apr 09 '21 20:04 zelony