Compare commits

...
Author SHA1 Message Date
Dmitry Novotochinov 11ae795703 emit init event 2019-01-11 21:02:16 +03:00
Dmitry Novotochinov 7c0feb912c Call start() after SmartCard initialized 2019-01-11 20:35:29 +03:00
3 changed files with 19 additions and 9 deletions
@@ -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";
@@ -54,6 +55,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
this.reactContext = reactContext;
this.nfcAdapter = NfcAdapter.getDefaultAdapter(activity.getBaseContext());
this.eventEmitter = new EventEmitter(reactContext);
eventEmitter.emit("keyCardDidInit", null);
}
public String getName() {
@@ -65,15 +67,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 -1
View File
@@ -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": {