NiklasMerz / cordova-plugin-fingerprint-aio

Cordova Plugin for fingerprint sensors (and FaceID) with Android and iOS support
https://www.npmjs.com/package/cordova-plugin-fingerprint-aio
MIT License
317 stars 189 forks source link

Plugin pauses the application #336

Open mayankkataria opened 3 years ago

mayankkataria commented 3 years ago

I want this fingerprint dialog to popup when application resumes (when user press Home button and again reopens the app). But problem is that this plugin also pauses the application when it shows fingerprint dialog and application resumes again when authentication is successful. That's why the popup keeps on coming repeatedly even when authentication is successful because its getting triggered in platform.resume.subscribe() method. My code:

  initializeApp() {
    this.platform.ready().then(() => {
      this.platform.resume
      .subscribe(() => {
        // logic when the application has been resumed after being paused.
        // Show fingerprint dialog
        this.showFingerprint();
      });
      this.updateDarkMode();
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });
  }

  async showFingerprint() {
    try {
      await this.platform.ready();
      const available = await this.faio.isAvailable();
      this.toast = await this.toastController.create({
        message: 'available: ' + available,
        duration: 3000
      });
      await this.toast.present();
      if (this.platform.is('android') && available === 'biometric') {
        const result = await this.faio.show(this.foptions);
        if (result === 'biometric_success') {
          this.toast = await this.toastController.create({
            message: 'Authentication Successful',
            duration: 3000
          });
          await this.toast.present();
        }
    }
    } catch (error) {
      this.toast = await this.toastController.create({
        message: error.message,
        duration: 3000
      });
      await this.toast.present();
    }
  }
cmgustavo commented 3 years ago

Hi, I've the same issue on version 3.0.1 of the plugin. I don't know if it's fixed on new version 4.

Also it happens when using this plugin: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin It shares something, and put the app in "pause" and then it needs to go back and it calls the fingerprint plugin ("resume"). I need to know if it's a bad behaviour of the plugin or something wrong in my implementation.

Thanks.