Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11ae795703 | ||
|
|
7c0feb912c |
@@ -42,6 +42,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
|||||||
public void onHostResume() {
|
public void onHostResume() {
|
||||||
if (this.smartCard == null) {
|
if (this.smartCard == null) {
|
||||||
this.smartCard = new SmartCard(getCurrentActivity(), reactContext);
|
this.smartCard = new SmartCard(getCurrentActivity(), reactContext);
|
||||||
|
smartCard.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
|||||||
private CardChannel cardChannel;
|
private CardChannel cardChannel;
|
||||||
private EventEmitter eventEmitter;
|
private EventEmitter eventEmitter;
|
||||||
private static final String TAG = "SmartCard";
|
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 WALLET_PATH = "m/44'/0'/0'/0/0";
|
||||||
private static final String WHISPER_PATH = "m/43'/60'/1581'/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.reactContext = reactContext;
|
||||||
this.nfcAdapter = NfcAdapter.getDefaultAdapter(activity.getBaseContext());
|
this.nfcAdapter = NfcAdapter.getDefaultAdapter(activity.getBaseContext());
|
||||||
this.eventEmitter = new EventEmitter(reactContext);
|
this.eventEmitter = new EventEmitter(reactContext);
|
||||||
|
eventEmitter.emit("keyCardDidInit", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -65,15 +67,22 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
this.cardManager.start();
|
if (!started) {
|
||||||
if (this.nfcAdapter != null) {
|
|
||||||
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
|
this.cardManager.start();
|
||||||
activity.registerReceiver(this, filter);
|
started = true;
|
||||||
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
|
|
||||||
return 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 {
|
} else {
|
||||||
log("not support in this device");
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "react-native-status-keycard",
|
"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)",
|
"description": "React Native library to interact with Status Keycard using NFC connection (Android only)",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user