revtel / react-native-nfc-manager

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

NfcManager is null when calling NfcManger.isSupported() on android with react native cli #590

Closed amitach closed 1 year ago

amitach commented 1 year ago

RN v0.70.5 compileSdkVersion = 31 version: 3.14.1

React.useEffect(() => {
        async function check() {
            try {
                supported = await NfcManager.isSupported();
                if (supported) {
                    console.log("NFC supported");
                } else {
                    console.log("Nfc not supported");
                }
            } catch (e) {
                console.warn("Error in nfc manager", e.message);   //Error in nfc manager Cannot convert null value to object
            }
        }
        check();
    }, []);

It is working fine on iOS, I am assuming it's not able to call the native library, I read that manual linking is no longer required and looking at the other issues I have run the command react-native run-android and that didn't work either. I am not sure how to fix this, I am new to react native so any pointer would be great. If you need any other information I'll provide it accordingly.

amitach commented 1 year ago

Nevermind, someone had put the following in the react-native-config-js

  dependencies: {
    'react-native-nfc-manager': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
   },

Removed it and it worked