Hello, recently we have been trying to get NFC support between two Android devices in Unity (since Apple apparently doesn’t support NFC connections between phones) but we have run into problems. Is this still supported, and if so, where is a good resource to learn how to implement it? We have tried assets but none worked, and we’ve tried writing it ourselves using AndroidJavaObject and Java code, but we have never been able to do more than write to our own NFCs instead of sending information to others. If anyone can help with this issue please let me know, and thanks for the help in advance!
There are a few NFC-centered assets on the asset store.
We have purchased and tried Digits NFC Toolkit | Integration | Unity Asset Store
and NFC | Integration | Unity Asset Store. The first one instantly crashes on 2 of our 4 testing devices and doesn’t send an NFC message when in proximity of another device running the same app. The second doesn’t crash, but still doesn’t transfer messages from one sensor to another, even if the phones are on top of each other.
Seeing this is made me think that it isn’t possible any more, but Android claims to support it (which all of our testing devices are). After the assets didn’t work we attempted to reverse engineer the solution, however got to the same point of being able to write to our own NFC, but not able to transfer that data to the other device’s NFC. Any reasons the signal wouldn’t get received by the application if we know that they are enabled and have data ready to transfer?
I have no idea how the NFC stack works, but likely there are all kinds of separate properties and permission and even perhaps digital certificates that have to be set up to make it generally work. There may even be specific transaction sequences required for specific types of hosts, I don’t know.
Assuming NFC actually still works, and assuming all the required APIs are exposed in a way you can get at with the AndroidJavaObject stuff you tried, it seems like it SHOULD work. But remember the apps behavior is also dependent on all the permissions and entitlements specified in the final AndroidManifest.xml file.
Yes, we have had to modify the manifest a bit to gain permission to access the sensor data and functions. From our debugging, we have those permissions and have no problem accessing the data on the device’s NFC or writing to our own NFC. The issue only comes in when connecting to another NFC nearby. Unfortunately no errors are thrown, so this is an issue that doesn’t raise red flags to the app. It must either not recognize the NFC chip at all or just simply ignore the connection when prompted. Could a system based application be using the sensor, making it unavailable?