revtel / react-native-nfc-manager Goto Github PK
View Code? Open in Web Editor NEWReact Native NFC module for Android & iOS
License: MIT License
React Native NFC module for Android & iOS
License: MIT License
How to parse plain text (Not URI) from a tag?
We can see the tag data in payload, But we are unable to parse the text data .
Is there any method to parse "plain-text"?
According to the document from Google:
https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html
And also CRNA project eject to Expokit are also default to 26:
expo/expo@e4b0ff0
When I call NfcManager.requestNdefWrite(bytes)
the promise never resolves nor is an error ever caught. It just fires off the request and waits as though it's taking forever to write the Ndef. Is this the expected behavior?
I imagine that it should complete immediately after requesting a write. Am I understanding this correctly, that NfcManager.requestNdefWrite(bytes)
is creating the "radio wave" output of the bytes
input, and once that process is completed successfully it should log "write completed"? If that is the case, can someone please point out the reason why this output is not generated?
_startDetection = () => {
NfcManager.registerTagEvent(this._onTagDiscovered)
.then(result => {
console.log('registerTagEvent OK', result)
// Make sure I register tag event first
if (Platform.OS === 'android') this._requestNdefWrite();
})
.catch(error => {
console.warn('registerTagEvent fail', error)
})
}
_requestNdefWrite = () => {
function strToBytes(str) {
let result = [];
for (let i = 0; i < str.length; i++) {
result.push(str.charCodeAt(i));
}
return result;
}
let { isWriting } = this.state;
if (isWriting) {
return;
}
const urlBytes = strToBytes('https://google.com');
const headerBytes = [0xD1, 0x01, (urlBytes.length + 1), 0x55, 0x01];
const bytes = [...headerBytes, ...urlBytes];
this.setState({isWriting: true});
NfcManager.requestNdefWrite(bytes)
.then(() => console.log('write completed')) // Doesn't ever complete!
.catch(err => console.warn(err)) // Logs "cancelled" after calling NfcManager.cancelNdefWrite()
.then(() => {
this.setState({isWriting: false})
console.log('set state writing false') // Logs after calling NfcManager.cancelNdefWrite()
});
}
_stopDetection = () => {
NfcManager.unregisterTagEvent()
.then(result => {
console.log('unregisterTagEvent OK', result)
NfcManager.stop();
if (Platform.OS === 'android') NfcManager.cancelNdefWrite();
})
.catch(error => {
console.warn('unregisterTagEvent fail', error)
})
}
Hi,awesome lib(碉堡了,老哥)!
I have successfully scan a NFC with this lib on iPhone, but I can not find out the tag id(which can be find on Android). Is there any way we can get the that on iOS? thanks! :D
Hello,
I installed the latest version you just published and I get result 'undefined' in any case I checked.
with undefined, I can't really check if the phone support in nfc or not, I don't have any indication to know..
Hello. I've setup my code based on the provided example. Im running the app on my iPhone 7+ and followed the instructions on the video. But when I trigger _startTrigger the app crashes and I cant seem to find an error. Any help would be greatly appreciated.
Hi there,
I was trying to implement this package on my react-native project, but when I try to reference the functions from the NFCManager
from react-native-nfc-manager
, all the functions catch
error instead of going to .then
.
"react-native": "^0.47.0",
:
"react": "^16.0.0-alpha.12",
Android Device:
Android Version: 7.1.1
I did the following setting steps:
npm install -s react-native-nfc-manager
react-native link react-native-nfc-manager
I try to print its error message, it says:
you could ignore the string start
, the start
is hard code. 😂
Is there any steps that I missing? Thx~
I would like to be able to write, in addition to read, some basic tags from an Android phone (my understanding is such actions are not currently permitted on iOS.) Is there any plan to implement this? I wish I could help but my Android/java is lacking.
(Edit: I do notice that phonegap-nfc supports it so maybe I'll take a look at porting it.)
I can't access the meta info for the tag, such as UID.
NfcManager.registerTagEvent(
tag => {
console.warn(tag)
},
'Hold your device over the tag',
true
)
iOS & Android
The tag
returned does not include any information about the id. tag.ndefMessage[0].id
exists but is an empty array.
Either tag.ndefMessage[0].id
returns the UID or tag.uid
returns the UID.
None
Hello,
I'm trying to get feedback from the nfc plugin if the user cancel or not give permission for nfc, can I do that?
I see you have support to know if the phone support nfc but I want to know if the phone support nfc and also have allow permission for use nfc.
I got this error after install and link the module, please help 😢
Task :app:compileDebugJavaWithJavac
C:\Users\myers\Desktop\movifree\android\app\src\main\java\com\movifree\MainApplication.java:6: error: package community.revteltech.nfc does not exist
import community.revteltech.nfc.NfcManagerPackage;
^
C:\Users\myers\Desktop\movifree\android\app\src\main\java\com\movifree\MainApplication.java:29: error: cannot find symbol
new NfcManagerPackage(),
^
symbol: class NfcManagerPackage
2 errorsFAILURE: Build failed with an exception.
my package.json
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-camera": "^1.1.4",
"react-native-nfc-manager": "^0.5.0",
"react-native-qrcode-scanner": "^1.0.1",
"react-navigation": "^2.3.1",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-logger": "^3.0.6"
},
Edit:
After further testing with another device, i'm able to receive a payload that isnt pointing to the google store. This means that the example app is receiving the payloads correctly and that my issue is with sending the NDEF message from the example app to another device.
// <-- urlToWrite is the url entered by the user into the textinput
const urlBytes = strToBytes(urlToWrite);
const headerBytes = [0xD1, 0x01, (urlBytes.length + 1), 0x55, 0x01];
const bytes = [...headerBytes, ...urlBytes];
console.log("bytes");console.log(bytes)
this.setState({isWriting: true});
NfcManager.requestNdefWrite(bytes)
.then(() => console.log('write completed'))
.catch(err => console.warn(err))
.then(() => this.setState({isWriting: false}));
}
I have successfully built/launched the app for android that was in the examples folder. I'm writing successfully to another device (which is also running the example) so i know the tag was sent. The problem is the payload is always http://play.google.com/store/apps/details?id=[sending app name]&feature=beam
The below console output is from the onTagDiscovered() method where i have also added some extra console.log lines to get more info. There are only 2 ndefmessages no matter what i do and neither contain what i was expecting (ie google.com). I thought there might be an error in the payload that was being sent out but when I tried using another nfc app (called NFC Tools) to send a URI that was reddit.com the result was the same. http://play.google.com/store/apps/details?id=[sending app name]&feature=beam.
Shouldn't the payload contain the info that i'm sending?
I'm using an Axon 7 Mini and I have NFC enabled in the settings.
Anyone else have this issue with the same device or a different one?
Hi @whitedogg13,
Thanks for all your work on this, I'm excited to start using it. I've tried both your sample app and building some code into my own app and I'm seeing an issue where NfcManager
is undefined:
import NfcManager, {NdefParser} from 'react-native-nfc-manager';
export default class Login extends React.Component {
componentDidMount() {
NfcManager.isSupported().then((isSupported) => Alert.alert(isSupported));
}
}
When I run this app, I get this error:
TypeError: Cannot read property 'isSupported' of undefined
Any idea what I might be missing?
HomeScreen: read nfc tag
_onTagDiscovered = tag => {
try {
let url = this._parseUri(tag);
if (url) {
let nodeID = url.split('/');
this.props.navigation.navigate("ScreenB", {nodeID: nodeID[nodeID.length - 1]});
}
} catch (error) {
}
};
it reads fine and propagates to next screen until app goes in background and return to the foreground(android). Suppose I press back button and app goes in the background. when I reopen the app it reads well but can't propagate to the next screen.
Warning I am getting: can only update a mounted or mounting components. This usually means you called setState, replaceState or forceUpdate .....
any issue with react navigation or nfc manager?
Btw thanks for your effort. any suggestion is welcomed :)
I have the library installed and working on iOS. I have set a button to run NfcManager.start()
which opens the iOS prompt to scan the device. When pressing the button the first time, the prompt shows up. When pressing cancel then the button a second time, nothing shows up.
const handleOnPress = () => {
console.warn('pressed')
NfcManager.start()
const { sendReading } = this.props
NfcManager.registerTagEvent(
tag => {
const reading = NdefParser.parseText(tag.ndefMessage[0])
sendReading(reading)
},
'Hold your device over the tag',
true
)
}
iOS
Prompt not showing up a second time when the button is tapped.
Android
Works perfectly. This is because it's an "always-on" state, rather than requiring a button to toggle a prompt.
After tapping the button a second time, I expected the prompt to show up again.
stop()
when it is closed and restart it. This didn't work. See code below.const handleOnPress = () => {
console.warn('pressed')
NfcManager.start({
onSessionClosedIOS: () => {
NfcManager.stop().then(() => handleOnPress())
},
})
const { sendReading } = this.props
NfcManager.registerTagEvent(
tag => {
const reading = NdefParser.parseText(tag.ndefMessage[0])
sendReading(reading)
},
'Hold your device over the tag',
true
)
}
NFCNDEFReaderSession
Sending `NfcMangerSessionClosed` with no listeners registered.
-- it may be related to that?I'm getting this error when trying to use this on a Google Pixel (1st generation regular, not XL). NFC is enabled on my phone; when I open the app, I get the below error.
[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'NativeNfcManager.isSupported')]
- node_modules/react-native-nfc-manager/NfcManager.js:95:6 in <unknown>
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
- node_modules/react-native-nfc-manager/NfcManager.js:96:8 in isSupported
* null:null in componentDidMount
- node_modules/react-proxy/modules/createPrototypeProxy.js:61:45 in proxiedComponentDidMount
- node_modules/react-native/Libraries/Renderer/ReactNativeRenderer-dev.js:8979:12 in commitLifeCycles
- ... 22 more stack frames from framework internals
When I click "Start Tag Detection" I get a similar error:
10:50:34: undefined is not an object (evaluating 'NativeNfcManager.requestNdefWrite')
- node_modules/react-native-nfc-manager/NfcManager.js:41:3 in <unknown>
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
- node_modules/react-native-nfc-manager/NfcManager.js:32:4 in requestNdefWrite
* App.js:136:29 in _requestNdefWrite
- node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js:199:45 in touchableHandlePress
- node_modules/react-native/Libraries/Components/Touchable/Touchable.js:746:34 in _performSideEffectsForTransition
- ... 23 more stack frames from framework internals
Does that mean this package and my device are incompatible? I am attaching my package.json
file to see if there are any problems with my setup that might stop this from working.
{
"name": "nfctest",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "25.0.0",
"react-native-scripts": "1.11.1",
"react-test-renderer": "16.2.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^25.0.0",
"react": "16.2.0",
"react-native": "0.52.0",
"react-native-nfc-manager": "^0.3.1"
}
}
hi,
I copy the codes of AndroidTechTestNdef.js
to my propject. but there are something wrong .
first time i detect the card , i get a warning of 'fail to connect tag'
second time i get the tag, its a object combine with id&&techType, but the getNdefMessage is also cant work.
Do I need to do some configuration in AndroidManifest.xml?
thx
from code
_startDetection = () => { NfcManager.registerTagEvent(tag => { console.log('Tag Discovered', tag); }, 'Hold your device over the tag', true) };
debug error:
NfcManager.registerTagEvent got 1 arguments, expected 3
com.facebook.react.bridge.JavaMethodWrapper.invoke JavaMethodWrapper.java:344 com.facebook.react.bridge.JavaModuleWrapper.invoke JavaModuleWrapper.java:166 com.facebook.react.bridge.queue.NativeRunnable.run NativeRunnable.java android.os.Handler.handleCallback Handler.java:739 android.os.Handler.dispatchMessage Handler.java:95 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage MessageQueueThreadHandler.java:31 android.os.Looper.loop Looper.java:155 com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run MessageQueueThreadImpl.java:194 java.lang.Thread.run Thread.java:818
SDK:27
BuildTool: 27.0.2
React native: 0.46.4
"react-native-nfc-manager": "0.1.0",
Hello,
I am getting the following error after react-native run-android
package community.revteltech.nfc does not exist
import community.revteltech.nfc.NfcManagerPackage;
I saw this on android docs: https://developer.android.com/reference/android/nfc/tech/Ndef#makeReadOnly()
Is it possible to make a NFC tag readOnly with this package?
HI,If the state(isEnabled) of the NFC changes, there is no way to monitor it.
I think the isEnabled()
method should return null or throw exception
IF the android device actually DOES NOT have NFC
...node_modules/react-native/React/Base/RCTBundleURLProvider.m:17:53: error: use of undeclared identifier 'undefined'; did you mean 'underline'?
const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
^~~~~~~~~~~~~~
underline
In file included from <built-in>:359:
<command line>:5:24: note: expanded from here
#define RCT_METRO_PORT undefined
^
In module 'Darwin' imported from...
Hello,
is there any option to check with this plugin if iphone\android has nfc in the phone?
I created an NFC Screen & I've decided to initialize the NFC when I navigate to it. In my componentDidMount function I have the code shown below.
componentDidMount = () => {
NfcManager.start({
onSessionClosedIOS: () => {
console.log('session closed');
this._stopDetection();
this.props.navigation.goBack();
},
});
};
This works just fine the first time around. I'll navigate to the screen, then on cancel it'll take me back, then I'll navigate to the screen again & when I click cancel I get the following error message.
I took a look at the source code & found that the issue is that Events.SessionClosed
event listener is being removed properly. So I've submitted a pull request #8 with a fix for this. :-)
Hi There,
After adding this module, we now have 14k unsupported devices because of the NFC requirement. I have tried adding the required false to the uses-permission in the android manifest, but it seems like it somehow gets overwritten?
We have wrapped the plugin so we only serve the function with the plugin if the device has NFC but still Play console deems it unsupported for devices without NFC.
<uses-permission android:name="android.permission.NFC" android:required="false" />
Any ideas?
Currently I just get this tag info:
Object {
"id": Array [
4,
109,
-123,
10,
116,
76,
-127,
],
"maxSize": 142,
"ndefMessage": Array [
Object {
"id": Array [],
"payload": Array [
1,
101,
98,
115,
108,
46,
104,
107,
],
"tnf": 1,
"type": Array [
85,
],
},
],
"techTypes": Array [
"android.nfc.tech.NfcA",
"android.nfc.tech.MifareUltralight",
"android.nfc.tech.Ndef",
],
"type": "NFC Forum Type 2",
}
How do I get the stored data from NFC card?
Hi,
I have followed the Readme and trying the example.
The example screen showing however the app crashed after i pressed start tag detection
My environment:
environment:
OS: Android 4.2.1
Packages: (installed)
react: 16.3.0-alpha.1
react-native: 0.54.3
react-native-nfc-manager: ^0.3.2
Logcat in android studio:
E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
java.lang.NullPointerException
at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:86)
at java.lang.StringBuilder.<init>(StringBuilder.java:95)
at com.facebook.react.devsupport.DevSupportManagerImpl$JSExceptionLogger.log(DevSupportManagerImpl.java:303)
at com.facebook.react.devsupport.DevSupportManagerImpl.handleException(DevSupportManagerImpl.java:287)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:501)
at com.facebook.react.bridge.CatalystInstanceImpl.access$900(CatalystInstanceImpl.java:40)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:517)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:33)
at android.os.Looper.loop(Looper.java:137)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:856)
Would you please let me know how to fix the issue. Thank you.
I have installed react-native-nfc-manager in my app and it works perfectly on Android but not on my iPhone 8.
Note: This is my first time using a react-native link
'ed module.
NfcManager.start({
onSessionClosedIOS: () => {
console.log('ios session closed')
},
})
.then(result => {
console.warn('start OK', result)
})
.catch(error => {
console.warn('device does not support nfc!')
})
NfcManager.registerTagEvent(
tag => {
// console.warn('Tag Discovered', tag)
// console.warn(JSON.stringify(tag, null, 2))
// console.warn(tag.ndefMessage[0])
console.warn(NdefParser.parseText(tag.ndefMessage[0]))
},
'Hold your device over the tag',
true
)
Android
Warning of start OK undefined
. When scanning an NDEF NFC card, I get the message that's encoded. In other words, the line of console.warn(NdefParser.parseText(tag.ndefMessage[0]))
prints out the message I want.
iOS
Warning of device does not support nfc!
. Another warning of
Sending `NfcManagerSessionClosed` with no listeners registered.
Both to behavior like Android's current behavior listed above.
react-native link
would do it under-the-hoodHi, I'm trying to disable the native scan sound so that I can use my own instead. Is there any way to use the enableReaderMode API instead of enableForegroundDispatch so that I can use the FLAG_READER_NO_PLATFORM_SOUNDS flag?
Hi we are using this package and are very impressed.
Just was curious, is the package asking for permissions to use NFC on the device (Android / iOS) or should / can we add that manually?
e.g. on Android (AndroidManifest.xml):
<uses-permission android:name="android.permission.NFC" />
const NfcManagerEmitter = new NativeEventEmitter(NativeNfcManager);
In nfcmanager.h case issue:
There is
#import <CoreNFc/CoreNfc.h>
should be:
#import <CoreNFC/CoreNFC.h>
Hello,
I'm trying to use in nfc with phone that support it. what I did it
` componentDidMount() {
console.log('props scanpage', this.props);
NfcManager.isSupported()
.then(supported => {
this.setState({ supported });
if (supported) {
this._startNfc();
}
})
}
_startNfc() {
NfcManager.start({
onSessionClosedIOS: () => {
console.log('ios session closed');
}
}).then(result => {
console.log(result)
this.setState({ nfcSupport: true })
}).catch(err => {
this.setState({ nfcSupport: false })
})
if (Platform.OS === 'android'){
NfcManager.registerTagEvent(tag => {
console.log('Tag Discovered', tag);
}, 'Hold your device over the tag', true)
NfcManager.isEnabled()
.then(enabled => {
console.log(enabled)
this.setState({ nfcSupport: enabled ? true : false, nfcAllow: enabled ? true : false })
})
.catch(err => {
console.log(err);
})
}`
but I don't see any response or any listener change when the nfc is work.
in ios it's works fine.
react-native-nfc:preBuild UP-TO-DATE
:react-native-nfc:preReleaseBuild UP-TO-DATE
:react-native-nfc:checkReleaseManifest
:react-native-nfc:preDebugAndroidTestBuild UP-TO-DATE
:react-native-nfc:preDebugBuild UP-TO-DATE
:react-native-nfc:preDebugUnitTestBuild UP-TO-DATE
:react-native-nfc:preReleaseUnitTestBuild UP-TO-DATE
:react-native-nfc:prepareComAndroidSupportAppcompatV72301Library
:react-native-nfc:prepareComAndroidSupportSupportV42301Library
:react-native-nfc:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library
:react-native-nfc:prepareComFacebookFrescoDrawee130Library
:react-native-nfc:prepareComFacebookFrescoFbcore130Library
:react-native-nfc:prepareComFacebookFrescoFresco130Library
:react-native-nfc:prepareComFacebookFrescoImagepipeline130Library
:react-native-nfc:prepareComFacebookFrescoImagepipelineBase130Library
:react-native-nfc:prepareComFacebookFrescoImagepipelineOkhttp3130Library
:react-native-nfc:prepareComFacebookReactReactNative0504Library
:react-native-nfc:prepareComFacebookSoloaderSoloader010Library
:react-native-nfc:prepareOrgWebkitAndroidJscR174650Library
:react-native-nfc:prepareReleaseDependencies
:react-native-nfc:compileReleaseAidl
:react-native-nfc:compileReleaseNdk UP-TO-DATE
:react-native-nfc:compileLint
:react-native-nfc:copyReleaseLint UP-TO-DATE
:react-native-nfc:compileReleaseRenderscript
:react-native-nfc:generateReleaseBuildConfig
:react-native-nfc:generateReleaseResValues
:react-native-nfc:generateReleaseResources
:react-native-nfc:mergeReleaseResources
:react-native-nfc:processReleaseManifest
:react-native-nfc:processReleaseResources
:react-native-nfc:generateReleaseSources
:react-native-nfc:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:react-native-nfc:compileReleaseJavaWithJavac
:react-native-nfc:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
D:\ProjectDirectory\node_modules\react-native-nfc\android\src\main\java\com\novadart\reactnativenfc\ReactNativeNFCPackage.java:21: error: method does not override or implement a method from a supertype
@Override
^
1 error
:react-native-nfc:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-nfc:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I tried with yarn and npm install both but facing the same issue.
Need Help to write plain text. Is there any option where we can right plain text. Right now whatever we write is saved as URL.
Thanks in Advance !
I just started with an empty react-native project "react-native init..."
Any advice?
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
> A problem occurred configuring project ':react-native-nfc-manager'.
> Could not resolve all dependencies for configuration ':react-native-nfc-manager:classpath'.
> Could not download gradle-core.jar (com.android.tools.build:gradle-core:1.5.0)
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle-core/1.5.0/gradle-core-1.5.0.jar'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle-core/1.5.0/gradle-core-1.5.0.jar'. Received status code 502 from server: Bad Gateway
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 20.305 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
I am currently trying to work with React Native, where I have to process given data from a NFC chip. This chip has 2 types of data. One is the tags, the other is the datablocks itself in hex. Is it possible to access this data?
Hi,
When I run NfcManager.start()
, an error occurs saying "Attempt to get length of null array" and pointing to your NfcManager.java
line 70. It indicates that invoke function does not accept null param. FYI, I tested on multiple Android devices, with and without a callback function as NfcManager.start()
param.
So, I changed NfcManager.java
line 70 callback.invoke
param to a string and it works (callback.invoke("null");
instead of callback.invoke(null);
). I know that it is not a solution at all, so I just notice you about it because I don't have time to fix it and to send you a pull request.
Regards.
Hello,
i'm trying to implement this plugin into my code and run nfc but I get these lines in console log
`registerTagEvent OK undefined
ios sessionClosed`
when I run the startDetection manually I get also the same issues..
part of my code
`import { calcSize } from '../../utillities/utilites';
const { height, width } = Dimensions.get('window');
import NfcManager, { NdefParser } from 'react-native-nfc-manager';
export default class NfcScan extends Component {
constructor(props) {
super(props);
this.state = {
supported: true,
enabled: false,
tag: {},
spinValue: new Animated.Value(0),
opacityAnimate: new Animated.Value(1),
width: new Animated.Value(calcSize(197)),
nfcDetection: false
}
}
componentDidMount() {
// StatusBar.setHidden(true);
NfcManager.start({
onSessionClosedIOS: () => {
console.log('ios session closed');
}
}).then(result => {
if(!result){
console.log("not nfc detected");
}else
console.log('start OK', result);
})
.catch(error => {
console.warn('start fail', error);
this.setState({supported: false});
})
if (Platform.OS === 'android') {
NfcManager.getLaunchTagEvent()
.then(tag => {
console.log('launch tag', tag);
if (tag) {
console.log(tag);
this.setState({ tag });
}
})
.catch(err => {
console.log(err);
})
NfcManager.isEnabled()
.then(enabled => {
console.log(enabled);
this.setState({ enabled });
})
.catch(err => {
console.log(err);
})
}
}`
Hi,
I've been using your javascript library to make a basic NFC read/write app and it has worked well up untill now. My issue is that I need to format the tags to Ndef from NdefFormatable. Your library doesn't supply functions for this and the only alternative is porting a massive java library from chariotsolution's Phone-gap, which is not possible in my amount of given time (and skill).
Could you supply a method for formatting the tags to Ndef? Or give a reasoning I need to follow in order to code it myself.
Thanks
Hi,
How can we protect the data written using NdefWrite from eavesdropping, do we have to use any extra encryption methods.
Hi, i can read the tag properly, but i can't write.
It appear a warning "you should requestTagEvent first"
I'm using your APP as example to test before i make my app implementation.
I have my Huawei P8 connected as emulator.
If you need more information, let me know.
Thank you
Hi,
I am trying to test your example then I got this build error:
error: bundling failed: Error: Couldn't find preset "env" relative to directory "/home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/react-native-nfc-manager" at /home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19 at Array.map (native) at OptionManager.resolvePresets (/home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20) at OptionManager.mergePresets (/home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10) at OptionManager.mergeOptions (/home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14) at OptionManager.init (/home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12) at File.initOptions (/home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/babel-core/lib/transformation/file/index.js:212:65) at new File (/home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/babel-core/lib/transformation/file/index.js:135:24) at Pipeline.transform (/home/yuqi/code/react-native/Genu9/clients/react-native/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
I did npm i --save react-native-nfc-manager
and react-native link react-native-nfc-manager
successfully, but I didn't include pod 'react-native-nfc-manager', :path => '../node_modules/react-native-nfc-manager/'
into the Podfile, because I can't find where it is. Does this Podfile have anything to do with the build error?
Thank you and forgive me if I ask a stupid question...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.