Skip to content

Commit

Permalink
feat: detect Android NFC on / off state
Browse files Browse the repository at this point in the history
  • Loading branch information
whitedogg13 committed Jun 25, 2022
1 parent cb48982 commit d3b9a53
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Screens/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ function HomeScreen(props) {
onBackgroundTag,
);

// listen to the NFC on/off state on Android device
if (Platform.OS === 'android') {
NfcManager.setEventListener(
NfcEvents.StateChanged,
({state} = {}) => {
NfcManager.cancelTechnologyRequest().catch(() => 0);
if (state === 'off') {
setEnabled(false);
} else if (state === 'on') {
setEnabled(true);
}
},
);
}

Linking.addEventListener('url', (event) => {
if (event.url) {
onDeepLink(event.url, false);
Expand Down

0 comments on commit d3b9a53

Please sign in to comment.