EddyVerbruggen / nativescript-fingerprint-auth

:nail_care: 👱‍♂️ Forget passwords, use a fingerprint scanner or facial recognition!
MIT License
134 stars 33 forks source link

Help with resumeEvent #44

Closed kkoates closed 5 years ago

kkoates commented 5 years ago

We have a use case to prompt users for biometrics when ios or android resumes. Before switching to the custom android ui the following code was working:

          applicationOn(resumeEvent, (args: ApplicationEventData) => {

                    this.deviceService.initBiometricIDAvailablity();

                    // verify fingerprint ...
          });

We have switched to the custom ui on android so we could eliminate passcode fallback (working great); however, this also stops the resumeEvent from being triggered. I think this has something to do with extending the activity in appcompat-activity.android.

I've tried the non cross platform android on resume which fires the event but loses access to where our services and properties are defined for biometrics.

          android.on(AndroidApplication.activityResumedEvent, function (args: AndroidActivityEventData) {

                    this.deviceService.initBiometricIDAvailablity();  // TypeError: Cannot read property 'initBiometricIDAvailablity' of undefined

                    // verify fingerprint ...
          });

Any tips on how to achieve on resume with custom android ui would be greatly appreciated.

kkoates commented 5 years ago

I was able to get onresume back going with this style:

application.android.on(application.AndroidApplication.activityResumedEvent, () => { 

   // code working as expected

}

Maybe this will help others.