cancel
Showing results for 
Search instead for 
Did you mean: 

Can't perform multiple operations in one NFC session on Android

shahbaz
Associate II

Hi,

I am working on a React Native project for an NFC app that needs to run on both iOS and Android. I am using the react-native-nfc-manager library to perform NFC operations. The NFC tag I am using is ST25DV, which supports NDEF and NfcV (ISO15693) technologies.

Some basic functionalities the app would perform are reading and writing raw memory blocks to the memory.

I noticed when I am using iOS device to perform read write operation, it can do so while keeping the tag intact with iOS device. I don't have to practically take the tag away from device and bring it near again to start the new nfc session.

In case of Android, to perform the writing functionality, I have to first send the command from device by pressing button, then device will start looking for NFC tag. I bring the NFC tag near the device; it detects it and locks in the session and sends the command to the tag and closes the session. Thats how the code is written.

Now if I want to read back from the tag, I press the read button and it starts looking for the tag. But I have to take the tag away from the device and bring it near to the device again for the device to detect the tag and send the new command.

The surprising thing is that ST's proprietary app in Android doesn't operate this way. You can keep the tag near to device and it will perform different operations without ever taking the tag away from device.

Is this limitation of React Native or just the Android device?

5 REPLIES 5
victor laraison
ST Employee

Is your question related to iOS or Android?
Your subject mentions iOS, but it seems the issue is occurring on Android. Could you please confirm?

Its on Android. Sorry I got it wrong in the title. 

France Berthelot
ST Employee

Hello,

I do not have knowledge on React Native for Android, but found the following that can help you :

In React Native for Android, you might encounter errors like "multiple operations cannot be performed on one session" when working with certain native modules, especially those dealing with resources that require exclusive access (such as NFC, Bluetooth, or database sessions).

Many Android APIs (e.g., NFC, BLE, database, camera) use the concept of a session:

  • You "open" a session to perform operations.
  • Only one operation can be active at a time within that session.
  • If you try to start a new operation before the previous one finishes (or the session is closed), you get an error.

For example, with react-native-nfc-manager, you can only have one NFC session open at a time.
If you try to start a new scan or write operation before the previous one is finished (or cancelled), you’ll get this error.

This is typically what you encountered. 

Concerning ST's proprietary app in Android, it is a Java based development, we receive at app level (Activity) an intent  from system and based on this intent we (using our ST25SDK + app) got depending of Tag technology the level of Tranceive function of the Android Tag (ISODEP, ...) and we Transceive commands.

I think it is a limitation of React Native.

Hoppe this clarify!

Rgds,FB

Hi France,

I also believe this may be a React Native limitation, given the differences in how it behaves on each platform. I understand the single-session limitation you mentioned in your response.

However, the issue I’m seeing is related to how Android and iOS handle these sessions individually.

  • On Android, between each session, the tag must be removed and then brought back in order to continue with the next session.

  • On iOS, the tag can remain in place, and the next session will still proceed without needing to remove and re-present the tag.

France Berthelot
ST Employee

Hello

The approach is quite different on Android and iOS

For Android

  • Automatic Detection (Background):

    • When an NFC tag is brought near the device, Android can automatically detect it—even if the app is not running.
    • If your app declares the right intent filters in the manifest (e.g., for NDEF_DISCOVERED), Android can launch your app or bring it to the foreground when a matching tag is detected.
    • This allows for "tap-to-launch" experiences.
  • Foreground Dispatch:

    • When your app is in the foreground, you can register for NFC events and handle tags directly.
    • Multiple apps can register, but only the foreground app gets the event.

For iOS

  • No Background Detection:

    • iOS does not support background NFC tag detection for third-party apps.
    • The user must explicitly open the app and start an NFC scan session (using Core NFC).
  • User-Initiated Scanning :

    • The app must present a scan UI (system sheet), and the user must tap "Scan" to begin.
    • Only after the user initiates scanning can the app detect and interact with a tag.

In summary, Android is an Automatic detection and iOS is with explicit user interaction, this explains how Android and iOS handle sessions 

Perhaps, you can search in React Native around the way to declare the right intent filters in the manifest ...

Just for your information, on another topic, on Android devices, Tag may become "out of date" after some times or depending of the implementation, this is an Android feature intended by design.  This appears, when app store a tag handle and try to use it later on. Perhaps React Native implement a good way to avoid this !

 

Hope it clarify a bit

Rgds,FB