smstuebe / xamarin-fingerprint

Xamarin and MvvMCross plugin for authenticate a user via fingerprint sensor
Microsoft Public License
491 stars 116 forks source link

FingerPrint Plugin works in sample app but not in a PCL Marshmellow - FormsAppCompatActivity #22

Closed tonyignat closed 7 years ago

tonyignat commented 7 years ago

Recently we were trying to implement app level fingerprint authentication through PCL. We used Plugin.Fingerprint nuget package and referenced it. The sample which was downloaded from the Git works but once we implement it with our PCL it just returns 'false' where it detects the fingerprint sensor when its available and works with sample application.

While comparing the two projects we found that there is one change in the Android Project’s MainActivity Our Project: public class MainActivity : FormsAppCompatActivity {

Working Sample App: xamarin-fingerprint-master

public class MainActivity : FormsApplicationActivity {

When I do this code change in my application code, the 'object reference not found error' is displayed during load application operation. What is the difference between these code and how should we handle it to make fingerprint sensor work through our mobile app. Is this the problem or whether there is something else we are missing here ?

It will be a great help is you could help us on this. If you have a different sample using another plugin, it would also help us greatly. All we need is to implement this mostly through PCL.

smstuebe commented 7 years ago

You have to install the package to your PCL and your App projects XYZ.Android, XYZ.iOS, etc. Right Click Solution -> Manage NuGet Packages for Solution -> Select FP plugin -> Check all neccessary Projects -> install

sairamb87 commented 7 years ago

@smstuebe - We have installed FP plugin from nuget in to our PCL and also in our Android & iOS project. But still we could not solve this issue.

Considering Android, We are targetting API 23 with Marshmallow 6.0. When we set this configuration, by default our MainActivity.cs implements FormsAppCompatActivity.

public class MainActivity : FormsAppCompatActivity

When we navigate to same file in your sample, we could see as below which implements FormsApplicationActivity but not FormsAppCompatActivity

public class MainActivity : FormsApplicationActivity

Which is not allowing us to initialize your plugin, Even if we do so by replacing the implementation, it throws false everytime. Can you please help us ?

smstuebe commented 7 years ago

Have you called CrossFingerprint.SetCurrentActivityResolver as described in the setup docs? https://github.com/smstuebe/xamarin-fingerprint#android

sairamb87 commented 7 years ago

We tried using your plugin, now with out any errors am able to debug using Android Virtual Devices (Nexus 5).

Followed your steps in setting up FingerPrint using Android Virtual Device - Extended Controls and it shows to me that "You have added 2 Fingerprints to the device".

Now when i debug, its always returning result.Authenticated = false.

We even tried to setup finger touch 1 as explained, but in Telnet after keying in emulator ID, it's not allowing us to enter commands other than avd, auth, help and exit/quit.

Due to which i had setup the finger1 and finger2 using AVD - Extended controls.

Also, DialogControl is creating problems, means in Portable library it says "DialogConfiguration" could not be found. (We have added Plugin.Fingerprint from Nuget, but still this error is coming up)

Mostly, issue of returning false is highlighted. It would be good, if we get fingerprint_error help on this :+1:

Thanks in Advance :)

smstuebe commented 7 years ago

Hmm I can't really help you any further with your simulator setup. Have you tested it with a real device? Which version have you installed? Stable or beta?

sairamb87 commented 7 years ago

No, we haven't got chance to test this yet in real device, we might be doing that tomorrow. :( I have installed stable version 1.2.0 using Nuget.

smstuebe commented 7 years ago

Ok. Setting up the simulators is always a bit tricky. Which emulator are you using? The new Android simulator doesn't require the telnet action and provides a UI for it.

image

sairamb87 commented 7 years ago

I am using Android Virtual Device (AVD) i.e., Android SDK Emulator with Visual Studio. I have configured Nexus 5 API 23 (but not Nexus 5X).

Also, added fingerprint as shown in the picture, but still when i click on Authenticate, it gives me false. fp1

Am getting Not Available status on my Page.

fp2

smstuebe commented 7 years ago

The only reason I could imagine is that the OS is returning false for IsHardwareDetected, because the Nexus 5 doesn't have a FP Sensor. Could you try it with a 5X?

Nevertheless: This shows me, that I should make the plugin more chatty using some log output.

ronpf commented 7 years ago

@sairamb87 The "Touch Sensor" UI function has never worked for me. I've been using the telnet commands with no problem.

sairamb87 commented 7 years ago

@ronpf - Can you please help us with step by step of using telnet commands, we tried telnet before trying it in UI, but hard luck. Both the cases, it didn't work.

Thanks in advance.

smstuebe commented 7 years ago

Have you tried it with a Nexus 5X image?

ronpf commented 7 years ago

@sairamb87

  1. This information is if you're using a mac
  2. Must be using a sim with API 23 (or 24) with finger print auth configured on the sim.
  3. See this about getting your sims auth-token etc http://stackoverflow.com/questions/37442566/android-console-authentication-required/37503734

Once you have that info open an Tools | SDK Command Prompt from via xamarin studio. a) Enter command: telnet 127.0.0.1 5554 (or your correct host / port. use command 'adb devices' to find connect sims or devices) b) Enter command: auth [your auth token] . c) If everything is good you will see 'OK' d) open your app and it's fingerprint dialog e) enter command: finger touch 1 This should trigger a successful result.

Here's output from my SDK Command prompt:

HPSJ-iMac:android-sdk-mac_x86 rfreschi$ telnet 127.0.0.1 5554 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Android Console: Authentication required Android Console: type 'auth ' to authenticate Android Console: you can find your in '/Users/rfreschi/.emulator_console_auth_token' OK auth [myauthtoken] Android Console: type 'help' for a list of commands OK finger touch 1 OK