react-native-nfc-manager | React Native NFC module for Android & iOS | iOS library
kandi X-RAY | react-native-nfc-manager Summary
kandi X-RAY | react-native-nfc-manager Summary
React Native NFC module for Android & iOS
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Starts the callback
- Connect to the device
- Handles writeNDEF request
- Parse the NDEF intent
- Checks if the device is supported by the device
- Checks if MIFare is supported
- Read a single block
- Append bytes to a WritableArray
- Converts an ndef message into an array of NDEF records
- Convert a JSONArray to a byte array
- Transforms an rn request to an RTree array
- Request a NDEF message
- Determines the maximum transceive length of the device
- Retrieves the number of blocks in a specific device
- Sends a new tag when a new tag is found
- Transfer a specific sector to a mobile device
- Sets an ndef message
- Transfare card
- Decrement a specific card
- Format an ndef array
- Get the NDEF status of the NDEF tag
- Registers a tag event
- Writes a single block
- Reads a mifare Card
- Set the timeout in milliseconds
- Increment a single card
react-native-nfc-manager Key Features
react-native-nfc-manager Examples and Code Snippets
Community Discussions
Trending Discussions on react-native-nfc-manager
QUESTION
I am currently working on a simple app, where the user scans the NFC tag and receives the data stored on it on the screen.
I followed this example and everything works fine when I try to authenticate one sector and read & write data from it but, but when I try to read data from two sectors at once I receive the "Transceive fail" error.
I am testing the app on a Samsung J6 device using a Mifare 1k Card.
Here is my code:
...ANSWER
Answered 2022-Feb-02 at 16:36.forEach()
doesn't wait for async callbacks (see this article), so your readBulk
function is actually calling this.read()
on all sectors at once, without waiting for cleanup. forEach
is just running through and firing off callbacks for all of the elements in this.sectors
.
To wait for each auth/read/cleanUp cycle before continuing, you can refactor it like so:
QUESTION
I am currently working on a simple app, which scans an NFC tag and reads the data from it. To implement it, I followed this example here.
For testing, I am using a real android device (Samsung Galaxy J6) and a Mifare NFC card.
At the launch of the app, everything seems fine, the NfcManager has been successfully started, the tag event has been registered (using NfcManager.registerTagEvent),but the problem occurs when requestTechnology has been called and the NFC card scanned.
The difference I noticed is regarding the intent in Android: before running requestTechnology and scanning the card against the phone, the intent and the action attached to it look like this => the action is on the main thread.
After that, the intent and the action look like this.
It seemed strange to me that the action has changed from the main thread.
The Android code is exactly like given in the link above and the code in React Native looks like this:
...ANSWER
Answered 2022-Jan-11 at 22:35I'm not sure why you are looking at the Intent
Action as it is of no significance to NFC really.
Some background of how Android handles NFC should help explain it.
In Android all Tag detection is handled by a System NFC service/App.
When you App is not running and a NFC Tag is detected the System Service works out if any App has requested to be started when that type of Tag is seen. It then crafts an Intent to get the System Launcher
to launch the main Activity of you app and bundles information about the NFC data in the extras section of the Intent
for the System Launcher to pass on in the Intent to your app at Launch time.
When you are doing requestTechnology
your App is already running and you are telling the System NFC Service to pass the NFC data directly to your App, the System Launcher does not need to be involved as your App is already running.
Now Android has two methods of passing this data directly to your running App, enableForegroundDispatch
or the later and much better enableReaderMode
.
You configured react-native-nfc-manager
to use the older enableForegroundDispatch
which tells the system NFC service to send the Tag details directly to your running Activity. So it does not need to add an Action to tell the system Launcher what to do. But to deliver that Intent
with the extras contain data about the Tag directly to your App, the only way for it to do that is to basically restart your App which causes a Pause
and Resume
.
But react-native-nfc-manager
handles all this for you, so you should not need to worry about what is in the Intent
Note you can configure react-native-nfc-manager
to use enableReaderMode
and instead of overloading an Intent to deliver this data to you, if basically creates a Thread in your running App and gives the Thread the Tag data directly and thus does not need to pause and resume your App (plus you get more control of things like NFC detection sound with this newer method)
So overall the behaviour you are seeing is expected and normal and nothing you should be concerned about or have a problem with.
Note iOS handles this completely differently but again react-native-nfc-manager
handles this via it's iOS specific methods.
QUESTION
I'm currently developing a cross platform React Native application. (Non-expo)
I'm using the following:
...ANSWER
Answered 2021-Dec-16 at 18:12import React from 'react';
import {
StyleSheet,
SafeAreaView,
StatusBar,
View,
Dimensions,
} from 'react-native';
import {TextInput} from 'react-native-paper';
const {width, height} = Dimensions.get('window');
const App = props => {
return (
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: StatusBar.currentHeight,
marginHorizontal: 16,
},
input: {
margin: 12,
color: 'white',
backgroundColor: 'green',
},
});
export default App;
QUESTION
I'm using an NTAG I2C plus 2k memory tag and using the react-native-nfc-manager library to interface with the tag.
Is there a way to specify the sector that you're intending to write to?
I know there is an API to specify the page offset to write to, but how do you specify the sector the page offsets are in?
(Updated to include below code sample)
...ANSWER
Answered 2021-Aug-09 at 21:18So "NTAG I2C plus 2k" seems to be a Certified Type 2 tag using NfcA comms.
It's datasheet
This Tag has additional commands over the Type 2 Standard to select the sector because Type 2 Tag's don't normally have Sectors.
So reading the datasheet Section 10.12 you would transceive the following commands bytes an example
C2h FFh
- Select Sector
03h 00h 00h 00h
- Sector 3
Then write to page address as normal with the A2h
command byte
react-native-nfc-manage offers an nfcAHandler
with a transceive method to send and receive these low level commands to the NFC chip.
Update:
For iOS it treats Type 2 Tags as Mifare Ultralight's and thus sendMifareCommandIOS
from the API to send the same commands.
(Both Android and iOS have the nfcAHandler
)
Note I've not tried this, I just do things with normal Type 2 Tags
QUESTION
I’m writing a React Native application which has to communicate with NFC MiFare Ultralight tags. I have NXP NTAG I2C PLUS ISO14443-3 tags.
I’m using the react-native-nfc-manager library for this. On android I didn’t notice any problems just on the iOS side. I’m testing on iOS 13 and 14 and my device is an iPhone 7.
I am able to find and connect to NFC Mifare Ultralight tags (can read and write them too), but in the 75% of the situations I get the following error during the communications:
ANSWER
Answered 2021-Feb-18 at 07:40At the end I managed to try out our app on multiple iPhones and the NFC worked properly. We also found out that our test device is a refurbished unit and we think that maybe that is the problem's cause.
QUESTION
Version 2 of react-native-nfc-manager is supposed to support disabling the scan sound (https://github.com/whitedogg13/react-native-nfc-manager/issues/60#issuecomment-464352677), however it doesn't seem to work.
This is the call:
...ANSWER
Answered 2020-Jul-11 at 22:38Update:
Impossible for ios, and supposed to work for android (it does work natively)
That undocumented Flag is very specific to the undocumented in this library Advanced Android Native direct enableReaderMode
API usage.
The iOS NFC API's and the basic older Android API's have no control over the sounds made by the platform on Tag detection.
Additional Android Specific
And looking at the code for Android https://github.com/whitedogg13/react-native-nfc-manager/blob/master/android/src/main/java/community/revteltech/nfc/NfcManager.java
The following seems to be reported to partially work (I note that it sets other advanced options that mean it probably would only detect a tag once every 10 seconds)
QUESTION
I am trying to emulate an NDEF message (NFC Forum Type 4 Tag) using ReactNative. I could not find any working source code or module to achieve this. The only working application is from Maxsoft.bg named NFC NDEF Tag Emulator which is not open source.
So far I've used react-native-nfc-manager
and react-native-nfc-hce
, but I couldn't make it work.
I also checked the android documentation but I couldn't find a working example/sourcecode there as well.
I found it really strange that I couldn't find even one working source code! So, it would be great if you could help me with a working ReactNative or Android source code.
...ANSWER
Answered 2020-Jul-13 at 20:09NDEF Message with HCE Android should provide you with the answer for Native Java for Android, the best answer also has linked a github repo with source code demo.
QUESTION
this is my very first post so please be gentle. I am mostly looking for Information that could lead me to a good library or a document that could help me out with what im trying to achieve. So far I tried using this library that I found on github to add nfc functionality to my app, which works great with cards and tags but I have no idea how to make it communicate with my pi reader.
Any help would be much appreciated. Thanks in advance!
...ANSWER
Answered 2020-Mar-26 at 22:12I don't know about React-Native library but you can access the underlying Android API's so here is a pointer using the Android API's
But some background first, normally in NFC there is a reading device and a NFC Card. The Reader initialise the NFC comms and the card responds. BUT there is the option of device to device (peer to peer) comms, this uses different underlying comm protocols than device to card
The right hand column of the image below describes it well
The Peer to Peer method is called Android Beam and unfortunately been depreciated in favour of Bluetooth/Wifi Direct and is not available in Android 10 and above.
Documentation for Android Beam is https://developer.android.com/guide/topics/connectivity/nfc/nfc#p2p
and
BUT
there is another more complicated option, it is possible for an Android Device to Emulate a NFC card, this is called Host Card Emulation (HCE), this is probably possible to do on the Raspberry Pi as well.
Therefore one device pretends to be a NFC Card and the other device reads/writes to it as a Card.
With HCE you can emulate a Standard Type 4 Tag and then read/write NDEF messages, the answer here https://stackoverflow.com/a/60813707/2373819 goes in to more detail about how to do this.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-native-nfc-manager
You can use react-native-nfc-manager like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the react-native-nfc-manager component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page