Reputation: 518
In my React Native app, one of the screens shows the QR code. That QR code should be placed to the QR code reader, which has also NFC capabilities.
My task is to make sure that the NFC is turned off. Yep, my app does not have any NFC features or capabilities. No permissions are set in AndroidManifest or Info.plist.
That is just a QR code provider (NS from the Netherlands) requirement to make sure the NFC is off. How to make it?
Is that possible that another app somehow uses NFC at this time?
Update:
Generally, the issue is with Apple Pay and Google Pay. While trying to scan the QR code from the screen both payment applications are popped up, which prevents reading the QR code.
So the idea is just to disable those payment applications while using our app.
for iOS is possible to use entitlement https://developer.apple.com/documentation/passkit/pkpasslibrary/1617078-requestautomaticpasspresentation
did not find something similar for Android yet.
related issue on Github https://github.com/revtel/react-native-nfc-manager/issues/455
Upvotes: 1
Views: 7145
Reputation: 518
So the problem with Apple Pay and Google Pay is as follow:
So the idea is just to disable those payment applications while using our app.
Upvotes: 1
Reputation: 178
I had to use NFC capabilities in a RN app. This is the package I've used: https://github.com/revtel/react-native-nfc-manager. The setup is simple on Android but can be tricky on iOS: https://github.com/revtel/react-native-nfc-manager/blob/main/setup.md
You have methods such as isEnabled(): Promise<boolean>;
or isSupported(): Promise<boolean>;
. I believe they will be enough for you.
Disclaimer:
I never tried to use those functions to check that directly: I usually check for the changes in the state since I need to give out some warnings.
Also I don't simply check for on or off. I use something because I need to make sure the iPhone can use the NFC for read/write (and not just payments)
try {
await NfcManager.isSupported(NfcTech.Iso15693IOS);
} catch (error) {
// set state = off and unsupported
Upvotes: 1