简体   繁体   中英

Make sure NFC is turned off in React Native

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM