Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_requestFormat = () => {
let {isWriting} = this.state;
if (isWriting) {
return;
}
this.setState({isWriting: true});
NfcManager.requestNdefWrite(null, {format: true})
.then(() => console.log('format completed'))
.catch(err => console.warn(err))
.then(() => this.setState({isWriting: false}));
}
_requestNdefWrite = () => {
let {isWriting, urlToWrite, rtdType} = this.state;
if (isWriting) {
return;
}
let bytes;
if (rtdType === RtdType.URL) {
bytes = buildUrlPayload(urlToWrite);
} else if (rtdType === RtdType.TEXT) {
bytes = buildTextPayload(urlToWrite);
}
this.setState({isWriting: true});
NfcManager.requestNdefWrite(bytes)
.then(() => console.log('write completed'))
.catch(err => console.warn(err))
.then(() => this.setState({isWriting: false}));
}