react-native-nfc-manager icon indicating copy to clipboard operation
react-native-nfc-manager copied to clipboard

How to toggle NFC on/off programmatically on Android POS devices (Sunmi V2)

Open 1453alabanda opened this issue 6 months ago • 0 comments

Description

I'm developing a React Native application for Sunmi V2 Android POS devices and need to programmatically turn NFC on/off when the user taps the toggle button. Currently, I can check if NFC is enabled using NfcManager.isEnabled() and redirect to settings using NfcManager.goToNfcSetting(), but I want to enable/disable NFC directly from my app without user intervention.

Current Implementation

const toggleNfcScan = async () => {
    const isEnabled = await NfcManager.isEnabled();
    
    if (!isEnabled) {
        // Currently redirecting to settings
        await NfcManager.goToNfcSetting();
        // But I want to enable NFC programmatically
    }
    
    // Start scanning...
};

Use Case Our POS application needs to:

Check NFC status when user taps the scan button If NFC is disabled, enable it automatically Start scanning for NFC cards Disable NFC when done (optional)

Environment

Device: Sunmi V2 Android POS React Native: 0.72.x react-native-nfc-manager: latest Android version: 8.1 (API 27)

Questions

Is it possible to add a method like NfcManager.enable() or NfcManager.disable() to the library? For POS devices with system-level permissions, what would be the best approach? Has anyone successfully implemented this on Sunmi or similar POS devices?

Any guidance or workaround would be greatly appreciated. Thank you!

1453alabanda avatar May 15 '25 07:05 1453alabanda