Add nfc state events
This commit is contained in:
parent
8fb12850d7
commit
38ca8597e2
|
@ -110,9 +110,13 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
|||
boolean on = false;
|
||||
switch (state) {
|
||||
case NfcAdapter.STATE_ON:
|
||||
eventEmitter.emit("keyCardOnNFCEnabled", null);
|
||||
log("NFC ON");
|
||||
break;
|
||||
case NfcAdapter.STATE_OFF:
|
||||
eventEmitter.emit("keyCardOnNFCDisabled", null);
|
||||
log("NFC OFF");
|
||||
break;
|
||||
default:
|
||||
log("other");
|
||||
}
|
||||
|
|
|
@ -11,10 +11,12 @@ import Keycard from "react-native-status-keycard";
|
|||
```javascript
|
||||
import { DeviceEventEmitter } from 'react-native';
|
||||
|
||||
// Listen to connect/disconnect events
|
||||
// Listen to connect/disconnect and nfc events
|
||||
componentDidMount () {
|
||||
DeviceEventEmitter.addListener("keyCardOnConnected", () => console.log("keycard connected"));
|
||||
DeviceEventEmitter.addListener("keyCardOnDisconnected", () => console.log("keycard disconnected"));
|
||||
DeviceEventEmitter.addListener("keyCardOnNFCEnabled", () => console.log("nfc enabled"));
|
||||
DeviceEventEmitter.addListener("keyCardOnNFCDisabled", () => console.log("nfc disabled"));
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue