Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create libraries for NFC reader APIs #2971

Open
gy-mate opened this issue Nov 19, 2024 · 3 comments
Open

Create libraries for NFC reader APIs #2971

gy-mate opened this issue Nov 19, 2024 · 3 comments
Labels
enhancement New features, or improvements to existing features.

Comments

@gy-mate
Copy link

gy-mate commented Nov 19, 2024

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:

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

@gy-mate gy-mate added the enhancement New features, or improvements to existing features. label Nov 19, 2024
@mhsmith
Copy link
Member

mhsmith commented Nov 19, 2024

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.

@gy-mate
Copy link
Author

gy-mate commented Nov 19, 2024

@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.

@freakboy3742
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

3 participants