Create libraries for NFC reader APIs
What is the problem or limitation you are having?
Toga doesn't support NFC readers.
Describe the solution you'd like
Support NFC readers on Android and iOS.
Describe alternatives you've considered
Using native platform APIs. But learning and implementing them separately can be time-consuming.
Additional context
This was already suggested several times:
- https://discord.com/channels/836455665257021440/836455665257021443/1050878483678646392
- https://discord.com/channels/836455665257021440/836455665257021443/1158711066004574238
- https://discord.com/channels/836455665257021440/836455665257021443/1300540888833069087
For iOS it should be implemented here, I guess: https://github.com/beeware/toga/tree/main/iOS/src/toga_iOS/libs And here for Android: https://github.com/beeware/toga/tree/main/android/src/toga_android/hardware
iOS documentation: https://developer.apple.com/documentation/corenfc Android: https://developer.android.com/develop/connectivity/nfc/nfc Web: https://developer.mozilla.org/en-US/docs/Web/API/Web_NFC_API
Similarly to Bluetooth (#2915), it would be better to contribute Android and iOS support to an existing cross-platform NFC library rather than adding it to Toga itself. But let's leave this issue open at least until someone's had a chance to investigate what those libraries are.
@mhsmith We're talking about relevant Python libraries only, right? Because I do not think there are any at the moment.
I could only find nfcpy but that seems to be a lower level implementation that provides drivers for some external devices. I don't think NFC reader devices in Android (and especially in iOS) phones are exposed in a way similar to external ones, so these probably cannot be added to nfcpy.
@mhsmith We're talking about relevant Python libraries only, right? Because I do not think there are any at the moment.
In which case - sounds like a great opportunity to write one :-)
But seriously - the core point is that this may not need to be a feature of Toga. Some hardware (e.g., the camera API) involves a GUI component, which means some interaction with Toga is required. However, if an API can be implemented independent of a GUI representation, then there's no need for it to be part of Toga's core API. NFC and Bluetooth support are two areas where that is definitely the case - you're reading data over the air; how that data is displayed is independent of how the data is read.
The only place this gets complicated is in the choice of bridging layer - an implementation for iOS that uses Rubicon as the ObjC bridging layer will really only be compatible with the BeeWare ecosystem, and not as useful for Kivy (at least, not without duplicating the bridge layer, and dealing with having 2 representations of ObjC objects). But a togax-nfc library that provides a third-party, Toga-integrated NFC capability should be entirely possible. I'd even be open to the idea of extending Toga's core API to provide extension points for hardware, similar to what has been suggested for widgets in #2928.
It seems that all the APIs suggested above is like very low-level NFC stuff. I wonder if implementation of applications of NFC in Toga is not unwarranted -- e.g. a Wallet popup view for iPhones.