1

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.

related issue on Github https://github.com/revtel/react-native-nfc-manager/issues/455

Alex Aymkin
  • 508
  • 1
  • 9
  • 15
  • 1
    For iOS you can apply to Apple for a special [entitlement](https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/ApplePayandPassKitEntitlements/ApplePayandPassKitEntitlements.html#//apple_ref/doc/uid/TP40011195-CH7-SW3) that allows your app to turn off NFC detection so that Apple Pay is not triggered in this scenario. – Paulw11 Nov 18 '21 at 18:44
  • Really need to have more detail on the QR code Reader, is it's NFC capabilities as a NFC Reader or as an NFC Tag? – Andrew Nov 18 '21 at 22:45
  • The general solution is to disable Apple Pay and Google Pay. * Apple instruction http://www.codereviewcache.com/disable-apple-pay/ – Alex Aymkin Nov 22 '21 at 07:29

2 Answers2

1

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
  • 1
    On Android at least you cannot programmatically turn NFC off, you have to prompt the user to do that, I guess you might have the same problem with iOS but are not sure of that. – Andrew Nov 18 '21 at 22:42
1

So the problem with Apple Pay and Google Pay is as follow:

  • try to scan the QR code on a mobile device
  • Actual behavior: payment application is popped up
  • Expected behavior: QR stays on the screen

So the idea is just to disable those payment applications while using our app.

Alex Aymkin
  • 508
  • 1
  • 9
  • 15