mirror of
https://github.com/status-im/react-native-status-keycard.git
synced 2025-02-28 12:00:36 +00:00
Call start() after SmartCard initialized
This commit is contained in:
parent
cd432d19c2
commit
7c0feb912c
@ -42,6 +42,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
public void onHostResume() {
|
||||
if (this.smartCard == null) {
|
||||
this.smartCard = new SmartCard(getCurrentActivity(), reactContext);
|
||||
smartCard.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
private CardChannel cardChannel;
|
||||
private EventEmitter eventEmitter;
|
||||
private static final String TAG = "SmartCard";
|
||||
private Boolean started = false;
|
||||
|
||||
private static final String WALLET_PATH = "m/44'/0'/0'/0/0";
|
||||
private static final String WHISPER_PATH = "m/43'/60'/1581'/0'/0";
|
||||
@ -65,15 +66,22 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
this.cardManager.start();
|
||||
if (this.nfcAdapter != null) {
|
||||
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
|
||||
activity.registerReceiver(this, filter);
|
||||
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
|
||||
return true;
|
||||
if (!started) {
|
||||
|
||||
this.cardManager.start();
|
||||
started = true;
|
||||
|
||||
if (this.nfcAdapter != null) {
|
||||
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
|
||||
activity.registerReceiver(this, filter);
|
||||
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
|
||||
return true;
|
||||
} else {
|
||||
log("not support in this device");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
log("not support in this device");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
{
|
||||
"name": "react-native-status-keycard",
|
||||
"version": "2.3.0",
|
||||
"version": "2.3.1",
|
||||
"description": "React Native library to interact with Status Keycard using NFC connection (Android only)",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user