I'm developing a mobile application using IONIC 6 with Reactand Typescript with Capacitor 5.0 on Windows 10 with Java-17. The application uses the Phonegap-nfc plugin for NFC communication. The app works fine on older Android devices (Android 8.0), but when I try to compile it on newer Android devices (Android 12), it doesn't work and exit inmediatly.
I have tried installing plugins for both Capacitor and Cordova, but the problem persists. When I don't have the Phonegap-nfc plugin installed, the app works without issues, but when I install it, the error occurs.
I have looked at the official documentation and other pages, but I haven't found a solution. Does anyone have any idea why this is happening and how I can fix it?
With phonegap-nfc plugin this is my component: NFC Component
See https://github.com/chariotsolutions/phonegap-nfc/issues/478
and
https://github.com/chariotsolutions/phonegap-nfc/issues/465
But it seems this plugin is not maintained any more (though there are forks with fixes applied)
There was a change in Android 12 that affected an old way of using NFC via Intents. When using an Intent on Android 12 you have to specify it's mutability (NFC needs mutable Intents) See https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability So you probably need an updated Plugin, hopefully one that uses a newer and better way of using NFC without Intents
There is a fix linked to the issue to specify the mutability of the Intent.
You don't specify how you use the plugin, but it does offer readerMode
(https://github.com/chariotsolutions/phonegap-nfc#nfcreadermode) which does not use Intents and this is not affected by the change in Android 12
Though there is another change in Android 12L that the plugin does not handle properly (even with readerMode
) and can sometimes cause a crash due to a new Security Exception that can be thrown.