Yubico / yubikit-android

Yubico Mobile Android SDK - YubiKit
Apache License 2.0
109 stars 40 forks source link

How i can get serial from NFC Yubikey ? #36

Closed Lzyct closed 3 years ago

Lzyct commented 3 years ago

Hi, i'm current develop App with support to read Serial from NFC during app in background. How i can read serial from Yubikey without run Activity, because listener only work when App in Foreground Thanks

dainnilsson commented 3 years ago

The Android NFC APIs require an Activity, so you can't get around that. What you can do, however, is to launch the Activity when a YubiKey is scanned, much like in the USB case. This allows the NFC Tag to be passed to the Activity via an Intent. Unfortunately the current SDK doesn't let you use that Tag to get an NfcSession, so that you can then use the ManagementApplication and read the serial. The next version of the SDK will make that possible.

As a workaround for now, you can implement the serial reading using the Android NFC API directly, and I've updated my sample app to do so: https://github.com/dainnilsson/yubikit-read-serial-sample/commit/0a3321803fa11826f2df7388c77361f0174ba369

Lzyct commented 3 years ago

It's working great ! Thanks

Lzyct commented 3 years ago

Hi @dainnilsson , i have issue when in my device install Microsoft Edge Browser. It's automatically open Edge and ignore my apps

dainnilsson commented 3 years ago

It looks like Edge is a bit too aggressive in its behavior here (I found this while Googling: https://stackoverflow.com/questions/62874828/edge-browser-becomes-default-browser-for-nfc-links). Unfortunately I'm not able to help you with this. You may have to report an issue with Microsoft to get this resolved.