Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log('launch tag', tag);
if (tag) {
this.setState({ tag });
}
})
.catch(err => {
console.log(err);
})
NfcManager.isEnabled()
.then(enabled => {
this.setState({ enabled });
})
.catch(err => {
console.log(err);
})
NfcManager.onStateChanged(
event => {
if (event.state === 'on') {
this.setState({enabled: true});
} else if (event.state === 'off') {
this.setState({enabled: false});
} else if (event.state === 'turning_on') {
// do whatever you want
} else if (event.state === 'turning_off') {
// do whatever you want
}
}
)
.then(sub => {
this._stateChangedSubscription = sub;
// remember to call this._stateChangedSubscription.remove()
// when you don't want to listen to this anymore