revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.4k stars 318 forks source link

Can't retrieve tag information with background tag on IOS #715

Closed ImperialCrowns closed 3 months ago

ImperialCrowns commented 7 months ago

Hey !

I wrote the following code :

const initNFC = () => {
  const onBackgroundTag = async (tag: TagEvent | null) => {
    console.log('onBackgroundTag', tag);
  };

  const initalizeBackgroundTag = async () => {
    // changed
    await NfcManager.start();

    const bgTag = await NfcManager.getBackgroundTag();
    onBackgroundTag(bgTag);

    // listen to other background tags after the app launched
    NfcManager.setEventListener(NfcEvents.DiscoverBackgroundTag, onBackgroundTag);
  };
  initalizeBackgroundTag();
};

function App() {
  initNFC();
  return (
    <View>
      <Text>Hello World</Text>
    </View>
  );
}

export default App;

I'm trying to retrieve tag informations when reading tag in background but the return value of NfcManager.getBackgroundTag is always null. What am I doing wrong ? Is there something I miss ? Is it possible to do it ?

Environment:

I've already tried many solutions proposed in previous issues, and it don't work.

BhavyaCodeAlchemy commented 7 months ago

It's Working fine in android ?

ImperialCrowns commented 7 months ago

Yes, on Android it works perfectly.

gigeos commented 7 months ago

Same for me

I can't retrieve the tagId when the application is launched in background on iOS thanks to the little NFC notification that appears when a tag is touched.

github-actions[bot] commented 4 months 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 3 months ago

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

wuguishifu commented 1 month ago

I'm also having this issue, I can't get any scan information.

Also, if the issue is tagged for iOS, saying that it works perfectly on Android is probably not going to be relevant information.

ChronoByteCosmonaut commented 1 day ago

Same!!!