revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.36k stars 317 forks source link

[Question] Make sure NFC is turned off #455

Closed aymkin closed 2 years ago

aymkin commented 2 years ago

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 for NFC in AndroidManifest or Info.plist.

That is just a QR code provider requirement to make sure the NFC is off. How to make it?

Is that possible that another app somehow uses NFC at this time?

Related question on StackOverflow https://stackoverflow.com/questions/70024098/make-sure-nfc-is-turned-off-in-react-native

srluo commented 2 years ago

Hi, keep QRcode scanning over 10cm distances, your phone will never trigger NFC scanning!

Oleksandr Naumkin @.***> 於 2021年11月19日 15:21 寫道:

 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 for NFC in AndroidManifest or Info.plist.

That is just a QR code provider requirement to make sure the NFC is off. How to make it?

Is that possible that another app somehow uses NFC at this time?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

aymkin commented 2 years ago

Hi, keep QRcode scanning over 10cm distances, your phone will never trigger NFC scanning!

Not sure I can teach a thousand users to keep iPhones not closer than 10 cm.

aymkin commented 2 years ago

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.

And have no idea how to implement requestAutomaticPassPresentationSuppression(responseHandler:) for react native application.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 5 days with no activity.

BhavyaKoshiya commented 1 year ago

@aymkin Did you manage to add this in the app?

aymkin commented 1 year ago

@aymkin Did you manage to add this in the app?

Yes, we did it

BhavyaKoshiya commented 1 year ago

@aymkin Can you provide detailed instructions or a piece of code or something that can guide me through how can i do it with react native?

fikkatra commented 5 months ago

Try adding this to the didFinishLaunchingWithOptions in AppDelegate.m:

if ([PKPassLibrary isPassLibraryAvailable]) {
    [PKPassLibrary requestAutomaticPassPresentationSuppressionWithResponseHandler:^(PKAutomaticPassPresentationSuppressionResult result) {
        if (result == PKAutomaticPassPresentationSuppressionResultSuccess) {
            RCTLogInfo(@"Apple Pay Automatic Pass Presentation suppressed");
        } else {
            RCTLogInfo(@"Could not suppress Apple Pay Automatic Pass Presentation");
        }
    }];
}

This code won't work without adding the correct entitlement. In the entitlement’s file of the target in Xcode, add the com.apple.developer.passkit.pass-presentation-suppression key with a Boolean value of YES. You need permission from Apple to include this entitlement.