Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-native-nfc-ios
Advanced tools
Readme
⚠️ Apple CoreNFC is only available for iOS11 on iPhone 7 and iPhone 7 Plus devices. It does not seems to be available on simulator at the moment, but it should be available later.
Install the module
npm install --save react-native-nfc-ios
Link the native module to your project
react-native link react-native-nfc-ios
Add the NFC capability key to your .entitlements
file
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>NDEF</string>
</array>
Add the NFCReaderUsageDescription
key to your project's Info.plist
<key>NFCReaderUsageDescription</key>
<string>Ready to use NFC 🚀</string>
As CoreNFC, the API will return arrays of messages, each message containing an array of records.
[
{
"records": [
{
"type": "VQ==", // base64 encoded for 55, URI record
"payload": "UmVhY3QgTmF0aXZlIE5GQyBpT1M=", // base64 encoded for "React Native NFC iOS"
"identifier": null, // No identifier in the tag
"typeNameFormat": "WELL_KNOWN_RECORD",
}
]
}
]
Every record will have a Base64 encoded type
, payload
and identifier
.
The typeFormatName
will be one of the following constant :
EMPTY_RECORD
WELL_KNOWN_RECORD
MIME_MEDIA_RECORD
ABSOLUTE_URI_RECORD
EXTERNAL_RECORD
UNKNOWN_RECORD
UNCHANGED_RECORD
You can import those constants form the module.
import { EMPTY_RECORD } from 'react-native-nfc-ios';
import base64 from 'base-64';
import { NFCNDEFReaderSession } from 'react-native-nfc-ios';
const messages = await NFCNDEFReaderSession.readTag();
const payloadB64 = messages[0].records[0].payload;
const payload = base64.decode(payloadB64);
console.log(payload);
// "React Native NFC iOS"
This API is designed to stay as close as possible to CoreNFC.
import { NFCNDEFReaderSession } from 'react-native-nfc-ios';
const readerSession = new NFCNDEFReaderSession();
const listener = readerSession.addEventListener('NDEFMessages', (messages) => {
console.log(messages);
});
// Show the NFC reader
readerSession.begin();
// Close the NFC reader
readerSession.invalidate();
// Remove the event listener
readerSession.removeEventListener('NDEFMessages', listener);
// Or Remove all events listeners
readerSession.removeAllEventListeners('NDEFMessages');
// ⚠️ Release the native instance to free memory
readerSession.release();
As with the native CoreNFC API you can set the alert message
// With the Simple API
const messages = await NFCNDEFReaderSession.readTag({
alertMessage: 'Please put your NFC Tag',
});
// As you instantiate a new NFCNDEFReaderSession
const readerSession = new NFCNDEFReaderSession({
alertMessage: 'Please put your NFC Tag',
});
// Change reader session alert message
readerSession.setAlertMessage('New alert message');
FAQs
Use iOS 11+ CoreNFC with React Native
The npm package react-native-nfc-ios receives a total of 0 weekly downloads. As such, react-native-nfc-ios popularity was classified as not popular.
We found that react-native-nfc-ios demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.