react-native-nfc-manager 3.16.2 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +86 -27
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/community/revteltech/nfc/NfcManager.java +188 -30
- package/ios/{NfcManager+Felica.m → NfcManager+Felica.mm} +1 -1
- package/ios/{NfcManager+IsoDep.m → NfcManager+IsoDep.mm} +2 -2
- package/ios/{NfcManager+Mifare.m → NfcManager+Mifare.mm} +1 -1
- package/ios/NfcManager.h +8 -0
- package/ios/{NfcManager.m → NfcManager.mm} +39 -20
- package/ios/{Util.m → Util.mm} +1 -1
- package/package.json +12 -4
- package/react-native-nfc-manager.podspec +5 -2
- package/src/NativeNfcManager.js +5 -1
- package/src/NfcManager.js +8 -0
- package/src/NfcManagerAndroid.js +1 -1
- package/src/NfcManagerIOS.js +3 -6
- package/src/NfcTech/NdefHandler.js +2 -2
- /package/ios/{NfcManager+Iso15693.m → NfcManager+Iso15693.mm} +0 -0
package/android/build.gradle
CHANGED
|
@@ -1,46 +1,105 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
if (project == rootProject) {
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
def reactNativeArchitectures() {
|
|
19
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
20
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
def isNewArchitectureEnabled() {
|
|
24
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
apply plugin: 'com.android.library'
|
|
28
|
+
apply plugin: "kotlin-android"
|
|
29
|
+
|
|
30
|
+
if (isNewArchitectureEnabled()) {
|
|
31
|
+
apply plugin: 'com.facebook.react'
|
|
32
|
+
}
|
|
33
|
+
|
|
1
34
|
def safeExtGet(prop, fallback) {
|
|
2
35
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
3
36
|
}
|
|
4
37
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
38
|
+
def getExtOrDefault(name) {
|
|
39
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties[name]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static def supportsNamespace() {
|
|
43
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
44
|
+
def major = parsed[0].toInteger()
|
|
45
|
+
def minor = parsed[1].toInteger()
|
|
9
46
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
47
|
+
// Namespace support was added in 7.3.0
|
|
48
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
13
49
|
}
|
|
14
|
-
apply plugin: 'com.android.library'
|
|
15
50
|
|
|
16
51
|
android {
|
|
17
|
-
|
|
52
|
+
if (supportsNamespace()) {
|
|
53
|
+
namespace "community.revteltech.nfc"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
compileSdk safeExtGet("compileSdk", 34)
|
|
57
|
+
|
|
58
|
+
compileOptions {
|
|
59
|
+
sourceCompatibility JavaVersion.VERSION_1_9
|
|
60
|
+
targetCompatibility JavaVersion.VERSION_1_9
|
|
61
|
+
}
|
|
18
62
|
|
|
19
|
-
|
|
63
|
+
defaultConfig {
|
|
64
|
+
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
65
|
+
targetSdk safeExtGet("targetSdk", 34)
|
|
66
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
67
|
+
}
|
|
20
68
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
69
|
+
buildFeatures {
|
|
70
|
+
buildConfig true
|
|
71
|
+
}
|
|
24
72
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
73
|
+
buildTypes {
|
|
74
|
+
release {
|
|
75
|
+
minifyEnabled false
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
lintOptions {
|
|
80
|
+
disable "GradleCompatible"
|
|
81
|
+
}
|
|
33
82
|
}
|
|
34
83
|
|
|
35
84
|
repositories {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
39
|
-
url "$rootDir/../node_modules/react-native/android"
|
|
40
|
-
}
|
|
85
|
+
mavenCentral()
|
|
86
|
+
google()
|
|
41
87
|
}
|
|
42
88
|
|
|
89
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
43
90
|
|
|
44
91
|
dependencies {
|
|
45
|
-
|
|
92
|
+
// For < 0.71, this will be from the local maven repo
|
|
93
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
94
|
+
//noinspection GradleDynamicVersion
|
|
95
|
+
implementation "com.facebook.react:react-native:+"
|
|
96
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
46
97
|
}
|
|
98
|
+
|
|
99
|
+
if (isNewArchitectureEnabled()) {
|
|
100
|
+
react {
|
|
101
|
+
jsRootDir = file("../specs/")
|
|
102
|
+
libraryName = "NfcManager"
|
|
103
|
+
codegenJavaPackageName = "community.revteltech.nfc"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
package="community.revteltech.nfc">
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
2
|
<uses-permission android:name="android.permission.NFC" />
|
|
4
3
|
<uses-feature android:name="android.hardware.nfc" android:required="false" />
|
|
5
4
|
</manifest>
|
|
@@ -41,7 +41,7 @@ import org.json.JSONException;
|
|
|
41
41
|
|
|
42
42
|
import java.util.*;
|
|
43
43
|
|
|
44
|
-
class NfcManager extends
|
|
44
|
+
class NfcManager extends NativeNfcManagerSpec implements ActivityEventListener, LifecycleEventListener {
|
|
45
45
|
private static final String LOG_TAG = "ReactNativeNfcManager";
|
|
46
46
|
private final List<IntentFilter> intentFilters = new ArrayList<>();
|
|
47
47
|
private final ArrayList<String[]> techLists = new ArrayList<>();
|
|
@@ -94,6 +94,12 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
94
94
|
return "NfcManager";
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
@ReactMethod
|
|
98
|
+
@Override
|
|
99
|
+
public void echo(String value, Callback callback) {
|
|
100
|
+
callback.invoke(null, value);
|
|
101
|
+
}
|
|
102
|
+
|
|
97
103
|
@Override
|
|
98
104
|
public Map<String, Object> getConstants() {
|
|
99
105
|
final Map<String, Object> constants = new HashMap<>();
|
|
@@ -129,7 +135,7 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
@ReactMethod
|
|
132
|
-
public void requestTechnology(ReadableArray techs, Callback callback) {
|
|
138
|
+
public void requestTechnology(ReadableArray techs, ReadableMap options, Callback callback) {
|
|
133
139
|
synchronized(this) {
|
|
134
140
|
if (!isForegroundEnabled) {
|
|
135
141
|
callback.invoke(ERR_NOT_REGISTERED);
|
|
@@ -217,7 +223,7 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
217
223
|
}
|
|
218
224
|
|
|
219
225
|
@ReactMethod
|
|
220
|
-
public void
|
|
226
|
+
public void queryNdefStatus(Callback callback) {
|
|
221
227
|
synchronized(this) {
|
|
222
228
|
if (techRequest != null) {
|
|
223
229
|
WritableMap writableMap = Arguments.createMap();
|
|
@@ -344,21 +350,22 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
344
350
|
}
|
|
345
351
|
|
|
346
352
|
@ReactMethod
|
|
347
|
-
public void mifareClassicAuthenticateA(
|
|
353
|
+
public void mifareClassicAuthenticateA(double sector, ReadableArray key, Callback callback) {
|
|
348
354
|
synchronized(this) {
|
|
349
|
-
mifareClassicAuthenticate('A', sector, key, callback);
|
|
355
|
+
mifareClassicAuthenticate('A', (int)sector, key, callback);
|
|
350
356
|
}
|
|
351
357
|
}
|
|
352
358
|
|
|
353
359
|
@ReactMethod
|
|
354
|
-
public void mifareClassicAuthenticateB(
|
|
360
|
+
public void mifareClassicAuthenticateB(double sector, ReadableArray key, Callback callback) {
|
|
355
361
|
synchronized(this) {
|
|
356
|
-
mifareClassicAuthenticate('B', sector, key, callback);
|
|
362
|
+
mifareClassicAuthenticate('B', (int)sector, key, callback);
|
|
357
363
|
}
|
|
358
364
|
}
|
|
359
365
|
|
|
360
366
|
@ReactMethod
|
|
361
|
-
public void mifareClassicGetBlockCountInSector(
|
|
367
|
+
public void mifareClassicGetBlockCountInSector(double _sectorIndex, Callback callback) {
|
|
368
|
+
int sectorIndex = (int)_sectorIndex;
|
|
362
369
|
synchronized(this) {
|
|
363
370
|
if (techRequest != null) {
|
|
364
371
|
try {
|
|
@@ -407,7 +414,8 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
407
414
|
}
|
|
408
415
|
|
|
409
416
|
@ReactMethod
|
|
410
|
-
public void mifareClassicSectorToBlock(
|
|
417
|
+
public void mifareClassicSectorToBlock(double _sectorIndex, Callback callback) {
|
|
418
|
+
int sectorIndex = (int)_sectorIndex;
|
|
411
419
|
synchronized(this) {
|
|
412
420
|
if (techRequest != null) {
|
|
413
421
|
try {
|
|
@@ -434,7 +442,8 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
434
442
|
}
|
|
435
443
|
|
|
436
444
|
@ReactMethod
|
|
437
|
-
public void mifareClassicReadBlock(
|
|
445
|
+
public void mifareClassicReadBlock(double _blockIndex, Callback callback) {
|
|
446
|
+
int blockIndex = (int)_blockIndex;
|
|
438
447
|
synchronized(this) {
|
|
439
448
|
if (techRequest != null) {
|
|
440
449
|
try {
|
|
@@ -466,7 +475,8 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
466
475
|
}
|
|
467
476
|
|
|
468
477
|
@ReactMethod
|
|
469
|
-
public void mifareClassicReadSector(
|
|
478
|
+
public void mifareClassicReadSector(double _sectorIndex, Callback callback) {
|
|
479
|
+
int sectorIndex = (int)_sectorIndex;
|
|
470
480
|
synchronized(this) {
|
|
471
481
|
if (techRequest != null) {
|
|
472
482
|
try {
|
|
@@ -503,7 +513,8 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
503
513
|
}
|
|
504
514
|
|
|
505
515
|
@ReactMethod
|
|
506
|
-
public void mifareClassicWriteBlock(
|
|
516
|
+
public void mifareClassicWriteBlock(double _blockIndex, ReadableArray block, Callback callback) {
|
|
517
|
+
int blockIndex = (int)_blockIndex;
|
|
507
518
|
synchronized(this) {
|
|
508
519
|
if (techRequest != null) {
|
|
509
520
|
try {
|
|
@@ -540,7 +551,9 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
540
551
|
}
|
|
541
552
|
|
|
542
553
|
@ReactMethod
|
|
543
|
-
public void mifareClassicIncrementBlock(
|
|
554
|
+
public void mifareClassicIncrementBlock(double _blockIndex, double _value, Callback callback) {
|
|
555
|
+
int blockIndex = (int)_blockIndex;
|
|
556
|
+
int value = (int)_value;
|
|
544
557
|
synchronized(this) {
|
|
545
558
|
if (techRequest != null) {
|
|
546
559
|
try {
|
|
@@ -571,7 +584,9 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
571
584
|
}
|
|
572
585
|
|
|
573
586
|
@ReactMethod
|
|
574
|
-
public void mifareClassicDecrementBlock(
|
|
587
|
+
public void mifareClassicDecrementBlock(double _blockIndex, double _value, Callback callback) {
|
|
588
|
+
int blockIndex = (int)_blockIndex;
|
|
589
|
+
int value = (int)_value;
|
|
575
590
|
synchronized(this) {
|
|
576
591
|
if (techRequest != null) {
|
|
577
592
|
try {
|
|
@@ -602,7 +617,8 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
602
617
|
}
|
|
603
618
|
|
|
604
619
|
@ReactMethod
|
|
605
|
-
public void mifareClassicTransferBlock(
|
|
620
|
+
public void mifareClassicTransferBlock(double _blockIndex, Callback callback) {
|
|
621
|
+
int blockIndex = (int)_blockIndex;
|
|
606
622
|
synchronized(this) {
|
|
607
623
|
if (techRequest != null) {
|
|
608
624
|
try {
|
|
@@ -633,12 +649,12 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
633
649
|
}
|
|
634
650
|
|
|
635
651
|
@ReactMethod
|
|
636
|
-
public void mifareUltralightReadPages(
|
|
652
|
+
public void mifareUltralightReadPages(double pageOffset, Callback callback) {
|
|
637
653
|
synchronized(this) {
|
|
638
654
|
if (techRequest != null) {
|
|
639
655
|
try {
|
|
640
656
|
MifareUltralight techHandle = (MifareUltralight)techRequest.getTechHandle();
|
|
641
|
-
byte[] resultBytes = techHandle.readPages(pageOffset);
|
|
657
|
+
byte[] resultBytes = techHandle.readPages((int)pageOffset);
|
|
642
658
|
WritableArray resultRnArray = bytesToRnArray(resultBytes);
|
|
643
659
|
callback.invoke(null, resultRnArray);
|
|
644
660
|
} catch (TagLostException ex) {
|
|
@@ -653,13 +669,13 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
653
669
|
}
|
|
654
670
|
|
|
655
671
|
@ReactMethod
|
|
656
|
-
public void mifareUltralightWritePage(
|
|
672
|
+
public void mifareUltralightWritePage(double pageOffset, ReadableArray rnArray, Callback callback) {
|
|
657
673
|
synchronized(this) {
|
|
658
674
|
if (techRequest != null) {
|
|
659
675
|
try {
|
|
660
676
|
byte[] bytes = rnArrayToBytes(rnArray);
|
|
661
677
|
MifareUltralight techHandle = (MifareUltralight)techRequest.getTechHandle();
|
|
662
|
-
techHandle.writePage(pageOffset, bytes);
|
|
678
|
+
techHandle.writePage((int)pageOffset, bytes);
|
|
663
679
|
callback.invoke();
|
|
664
680
|
} catch (TagLostException ex) {
|
|
665
681
|
callback.invoke("mifareUltralight fail: TAG_LOST");
|
|
@@ -690,8 +706,43 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
690
706
|
}
|
|
691
707
|
}
|
|
692
708
|
|
|
709
|
+
@Override
|
|
710
|
+
public void setAlertMessage(String message, Callback callback) {
|
|
711
|
+
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
@Override
|
|
715
|
+
public void isSessionAvailable(Callback callback) {
|
|
716
|
+
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
@Override
|
|
720
|
+
public void isTagSessionAvailable(Callback callback) {
|
|
721
|
+
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
@Override
|
|
725
|
+
public void sendMifareCommand(ReadableArray bytes, Callback callback) {
|
|
726
|
+
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
@Override
|
|
730
|
+
public void sendCommandAPDU(ReadableMap payload, Callback callback) {
|
|
731
|
+
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
@Override
|
|
735
|
+
public void sendCommandAPDUBytes(ReadableArray bytes, Callback callback) {
|
|
736
|
+
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
@Override
|
|
740
|
+
public void sendFelicaCommand(ReadableArray bytes, Callback callback) {
|
|
741
|
+
|
|
742
|
+
}
|
|
743
|
+
|
|
693
744
|
@ReactMethod
|
|
694
|
-
public void setTimeout(
|
|
745
|
+
public void setTimeout(double timeout, Callback callback) {
|
|
695
746
|
synchronized (this) {
|
|
696
747
|
if (techRequest != null) {
|
|
697
748
|
try {
|
|
@@ -702,31 +753,31 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
702
753
|
switch (tech) {
|
|
703
754
|
case "NfcA": {
|
|
704
755
|
NfcA techHandle = (NfcA) baseTechHandle;
|
|
705
|
-
techHandle.setTimeout(timeout);
|
|
756
|
+
techHandle.setTimeout((int)timeout);
|
|
706
757
|
callback.invoke();
|
|
707
758
|
return;
|
|
708
759
|
}
|
|
709
760
|
case "NfcF": {
|
|
710
761
|
NfcF techHandle = (NfcF) baseTechHandle;
|
|
711
|
-
techHandle.setTimeout(timeout);
|
|
762
|
+
techHandle.setTimeout((int)timeout);
|
|
712
763
|
callback.invoke();
|
|
713
764
|
return;
|
|
714
765
|
}
|
|
715
766
|
case "IsoDep": {
|
|
716
767
|
IsoDep techHandle = (IsoDep) baseTechHandle;
|
|
717
|
-
techHandle.setTimeout(timeout);
|
|
768
|
+
techHandle.setTimeout((int)timeout);
|
|
718
769
|
callback.invoke();
|
|
719
770
|
return;
|
|
720
771
|
}
|
|
721
772
|
case "MifareClassic": {
|
|
722
773
|
MifareClassic techHandle = (MifareClassic) baseTechHandle;
|
|
723
|
-
techHandle.setTimeout(timeout);
|
|
774
|
+
techHandle.setTimeout((int)timeout);
|
|
724
775
|
callback.invoke();
|
|
725
776
|
return;
|
|
726
777
|
}
|
|
727
778
|
case "MifareUltralight": {
|
|
728
779
|
MifareUltralight techHandle = (MifareUltralight) baseTechHandle;
|
|
729
|
-
techHandle.setTimeout(timeout);
|
|
780
|
+
techHandle.setTimeout((int)timeout);
|
|
730
781
|
callback.invoke();
|
|
731
782
|
return;
|
|
732
783
|
}
|
|
@@ -747,7 +798,7 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
747
798
|
public void connect(ReadableArray techs, Callback callback){
|
|
748
799
|
synchronized(this) {
|
|
749
800
|
try {
|
|
750
|
-
techRequest = new TagTechnologyRequest(techs.toArrayList(),
|
|
801
|
+
techRequest = new TagTechnologyRequest(techs.toArrayList(), callback);
|
|
751
802
|
techRequest.connect(this.tag);
|
|
752
803
|
callback.invoke(null, null);
|
|
753
804
|
} catch (Exception ex) {
|
|
@@ -1058,8 +1109,23 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
1058
1109
|
callback.invoke();
|
|
1059
1110
|
}
|
|
1060
1111
|
|
|
1112
|
+
@Override
|
|
1113
|
+
public void restartTechnologyRequest(Callback callback) {
|
|
1114
|
+
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
@Override
|
|
1118
|
+
public void invalidateSession(Callback callback) {
|
|
1119
|
+
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
@Override
|
|
1123
|
+
public void invalidateSessionWithError(String message, Callback callback) {
|
|
1124
|
+
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1061
1127
|
@ReactMethod
|
|
1062
|
-
|
|
1128
|
+
public void registerTagEvent(ReadableMap options, Callback callback) {
|
|
1063
1129
|
isReaderModeEnabled = options.getBoolean("isReaderModeEnabled");
|
|
1064
1130
|
readerModeFlags = options.getInt("readerModeFlags");
|
|
1065
1131
|
readerModeDelay = options.getInt("readerModeDelay");
|
|
@@ -1090,7 +1156,7 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
1090
1156
|
}
|
|
1091
1157
|
|
|
1092
1158
|
@ReactMethod
|
|
1093
|
-
|
|
1159
|
+
public void unregisterTagEvent(Callback callback) {
|
|
1094
1160
|
Log.d(LOG_TAG, "unregisterTagEvent");
|
|
1095
1161
|
if (isResumed) {
|
|
1096
1162
|
enableDisableForegroundDispatch(false);
|
|
@@ -1106,7 +1172,7 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
1106
1172
|
}
|
|
1107
1173
|
|
|
1108
1174
|
@ReactMethod
|
|
1109
|
-
|
|
1175
|
+
public void hasTagEventRegistration(Callback callback) {
|
|
1110
1176
|
Log.d(LOG_TAG, "isSessionAvailable: " + isForegroundEnabled);
|
|
1111
1177
|
callback.invoke(null, isForegroundEnabled);
|
|
1112
1178
|
}
|
|
@@ -1117,10 +1183,102 @@ class NfcManager extends ReactContextBaseJavaModule implements ActivityEventList
|
|
|
1117
1183
|
}
|
|
1118
1184
|
|
|
1119
1185
|
@ReactMethod
|
|
1120
|
-
public void removeListeners(
|
|
1186
|
+
public void removeListeners(double count) {
|
|
1121
1187
|
// Keep: Required for RN built in Event Emitter Calls.
|
|
1122
1188
|
}
|
|
1123
1189
|
|
|
1190
|
+
@Override
|
|
1191
|
+
public void iso15693_getSystemInfo(double requestFlag, Callback callback) {
|
|
1192
|
+
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
@Override
|
|
1196
|
+
public void iso15693_readSingleBlock(ReadableMap options, Callback callback) {
|
|
1197
|
+
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
@Override
|
|
1201
|
+
public void iso15693_readMultipleBlocks(ReadableMap options, Callback callback) {
|
|
1202
|
+
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
@Override
|
|
1206
|
+
public void iso15693_writeSingleBlock(ReadableMap options, Callback callback) {
|
|
1207
|
+
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
@Override
|
|
1211
|
+
public void iso15693_lockBlock(ReadableMap options, Callback callback) {
|
|
1212
|
+
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
@Override
|
|
1216
|
+
public void iso15693_writeAFI(ReadableMap options, Callback callback) {
|
|
1217
|
+
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
@Override
|
|
1221
|
+
public void iso15693_lockAFI(ReadableMap options, Callback callback) {
|
|
1222
|
+
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
@Override
|
|
1226
|
+
public void iso15693_writeDSFID(ReadableMap options, Callback callback) {
|
|
1227
|
+
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
@Override
|
|
1231
|
+
public void iso15693_lockDSFID(ReadableMap options, Callback callback) {
|
|
1232
|
+
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
@Override
|
|
1236
|
+
public void iso15693_resetToReady(ReadableMap options, Callback callback) {
|
|
1237
|
+
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
@Override
|
|
1241
|
+
public void iso15693_select(ReadableMap options, Callback callback) {
|
|
1242
|
+
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
@Override
|
|
1246
|
+
public void iso15693_stayQuiet(ReadableMap options, Callback callback) {
|
|
1247
|
+
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
@Override
|
|
1251
|
+
public void iso15693_customCommand(ReadableMap options, Callback callback) {
|
|
1252
|
+
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
@Override
|
|
1256
|
+
public void iso15693_sendRequest(ReadableMap options, Callback callback) {
|
|
1257
|
+
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
@Override
|
|
1261
|
+
public void iso15693_extendedReadSingleBlock(ReadableMap options, Callback callback) {
|
|
1262
|
+
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
@Override
|
|
1266
|
+
public void iso15693_extendedReadMultipleBlocks(ReadableMap options, Callback callback) {
|
|
1267
|
+
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
@Override
|
|
1271
|
+
public void iso15693_extendedWriteSingleBlock(ReadableMap options, Callback callback) {
|
|
1272
|
+
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
@Override
|
|
1276
|
+
public void iso15693_extendedLockBlock(ReadableMap options, Callback callback) {
|
|
1277
|
+
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
|
|
1124
1282
|
@Override
|
|
1125
1283
|
public void onHostResume() {
|
|
1126
1284
|
Log.d(LOG_TAG, "onResume");
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
@implementation NfcManager (Felica)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
- (void)sendFelicaCommand:(NSArray *)bytes callback: (nonnull RCTResponseSenderBlock)callback
|
|
13
13
|
{
|
|
14
14
|
if (@available(iOS 13.0, *)) {
|
|
15
15
|
if ([self tagSession] != nil) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
@implementation NfcManager (IsoDep)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
- (void)sendCommandAPDUBytes:(NSArray *)bytes callback: (nonnull RCTResponseSenderBlock)callback
|
|
13
13
|
{
|
|
14
14
|
if (@available(iOS 13.0, *)) {
|
|
15
15
|
if ([self tagSession] != nil) {
|
|
@@ -39,7 +39,7 @@ RCT_EXPORT_METHOD(sendCommandAPDUBytes:(NSArray *)bytes callback: (nonnull RCTRe
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
- (void)sendCommandAPDU:(NSDictionary *)apduData callback: (nonnull RCTResponseSenderBlock)callback
|
|
43
43
|
{
|
|
44
44
|
if (@available(iOS 13.0, *)) {
|
|
45
45
|
if ([self tagSession] != nil) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
@implementation NfcManager (Mifare)
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
- (void)sendMifareCommand:(NSArray *)bytes callback: (nonnull RCTResponseSenderBlock)callback
|
|
13
13
|
{
|
|
14
14
|
if (@available(iOS 13.0, *)) {
|
|
15
15
|
if ([self tagSession] != nil) {
|
package/ios/NfcManager.h
CHANGED
|
@@ -13,9 +13,17 @@
|
|
|
13
13
|
#import <UIKit/UIUserActivity.h>
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
17
|
+
#import <NativeNfcManagerSpec/NativeNfcManagerSpec.h>
|
|
18
|
+
// @interface NfcManager : NSObject <NativeNfcManagerSpec, NFCNDEFReaderSessionDelegate, NFCTagReaderSessionDelegate> {
|
|
19
|
+
@interface NfcManager : RCTEventEmitter <NativeNfcManagerSpec, RCTBridgeModule, NFCNDEFReaderSessionDelegate, NFCTagReaderSessionDelegate> {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
#else
|
|
16
23
|
@interface NfcManager : RCTEventEmitter <RCTBridgeModule, NFCNDEFReaderSessionDelegate, NFCTagReaderSessionDelegate> {
|
|
17
24
|
|
|
18
25
|
}
|
|
26
|
+
#endif
|
|
19
27
|
|
|
20
28
|
@property (strong, nonatomic) NFCNDEFReaderSession * _Nullable session;
|
|
21
29
|
@property (strong, nonatomic) NFCTagReaderSession * _Nullable tagSession;
|
|
@@ -238,22 +238,23 @@ continueUserActivity:(NSUserActivity *)userActivity
|
|
|
238
238
|
return YES;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
|
|
241
|
+
- (void)getBackgroundTag: (nonnull RCTResponseSenderBlock)callback
|
|
242
242
|
{
|
|
243
243
|
if (bgNdefRecords != nil) {
|
|
244
|
-
|
|
244
|
+
// iOS doesn't report the full tag, only the ndefMessage part
|
|
245
|
+
callback(@[[NSNull null], @{@"ndefMessage": bgNdefRecords}]);
|
|
245
246
|
} else {
|
|
246
247
|
callback(@[[NSNull null], [NSNull null]]);
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
250
|
|
|
250
|
-
|
|
251
|
+
- (void)clearBackgroundTag: (nonnull RCTResponseSenderBlock)callback
|
|
251
252
|
{
|
|
252
253
|
bgNdefRecords = nil;
|
|
253
254
|
callback(@[[NSNull null]]);
|
|
254
255
|
}
|
|
255
256
|
|
|
256
|
-
|
|
257
|
+
- (void)isSupported: (NSString *)tech callback:(nonnull RCTResponseSenderBlock)callback
|
|
257
258
|
{
|
|
258
259
|
if ([tech isEqualToString:@""] || [tech isEqualToString:@"Ndef"]) {
|
|
259
260
|
if (@available(iOS 11.0, *)) {
|
|
@@ -270,7 +271,7 @@ RCT_EXPORT_METHOD(isSupported: (NSString *)tech callback:(nonnull RCTResponseSen
|
|
|
270
271
|
callback(@[[NSNull null], @NO]);
|
|
271
272
|
}
|
|
272
273
|
|
|
273
|
-
|
|
274
|
+
- (void)start: (nonnull RCTResponseSenderBlock)callback
|
|
274
275
|
{
|
|
275
276
|
if (@available(iOS 11.0, *)) {
|
|
276
277
|
if (NFCNDEFReaderSession.readingAvailable) {
|
|
@@ -284,7 +285,7 @@ RCT_EXPORT_METHOD(start: (nonnull RCTResponseSenderBlock)callback)
|
|
|
284
285
|
callback(@[@"Not support in this device", [NSNull null]]);
|
|
285
286
|
}
|
|
286
287
|
|
|
287
|
-
|
|
288
|
+
-(void)requestTechnology: (NSArray *)techs options: (NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback
|
|
288
289
|
{
|
|
289
290
|
if (@available(iOS 13.0, *)) {
|
|
290
291
|
if (tagSession == nil && session == nil) {
|
|
@@ -306,7 +307,7 @@ RCT_EXPORT_METHOD(requestTechnology: (NSArray *)techs options: (NSDictionary *)o
|
|
|
306
307
|
}
|
|
307
308
|
}
|
|
308
309
|
|
|
309
|
-
|
|
310
|
+
- (void)restartTechnologyRequest:(nonnull RCTResponseSenderBlock)callback
|
|
310
311
|
{
|
|
311
312
|
if (@available(iOS 13.0, *)) {
|
|
312
313
|
if (tagSession != nil) {
|
|
@@ -321,7 +322,7 @@ RCT_EXPORT_METHOD(restartTechnologyRequest:(nonnull RCTResponseSenderBlock)callb
|
|
|
321
322
|
}
|
|
322
323
|
}
|
|
323
324
|
|
|
324
|
-
|
|
325
|
+
- (void)cancelTechnologyRequest:(nonnull RCTResponseSenderBlock)callback
|
|
325
326
|
{
|
|
326
327
|
if (@available(iOS 13.0, *)) {
|
|
327
328
|
if (tagSession != nil) {
|
|
@@ -336,7 +337,7 @@ RCT_EXPORT_METHOD(cancelTechnologyRequest:(nonnull RCTResponseSenderBlock)callba
|
|
|
336
337
|
}
|
|
337
338
|
}
|
|
338
339
|
|
|
339
|
-
|
|
340
|
+
- (void)registerTagEvent:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback
|
|
340
341
|
{
|
|
341
342
|
if (@available(iOS 11.0, *)) {
|
|
342
343
|
if (session == nil && tagSession == nil) {
|
|
@@ -353,7 +354,7 @@ RCT_EXPORT_METHOD(registerTagEvent:(NSDictionary *)options callback:(nonnull RCT
|
|
|
353
354
|
}
|
|
354
355
|
}
|
|
355
356
|
|
|
356
|
-
|
|
357
|
+
- (void)unregisterTagEvent:(nonnull RCTResponseSenderBlock)callback
|
|
357
358
|
{
|
|
358
359
|
if (@available(iOS 11.0, *)) {
|
|
359
360
|
if (session != nil) {
|
|
@@ -368,7 +369,7 @@ RCT_EXPORT_METHOD(unregisterTagEvent:(nonnull RCTResponseSenderBlock)callback)
|
|
|
368
369
|
}
|
|
369
370
|
}
|
|
370
371
|
|
|
371
|
-
|
|
372
|
+
- (void)invalidateSession:(nonnull RCTResponseSenderBlock)callback
|
|
372
373
|
{
|
|
373
374
|
if (@available(iOS 13.0, *)) {
|
|
374
375
|
if (session != nil) {
|
|
@@ -385,7 +386,7 @@ RCT_EXPORT_METHOD(invalidateSession:(nonnull RCTResponseSenderBlock)callback)
|
|
|
385
386
|
}
|
|
386
387
|
}
|
|
387
388
|
|
|
388
|
-
|
|
389
|
+
- (void)invalidateSessionWithError:(NSString *)errorMessage callback:(nonnull RCTResponseSenderBlock)callback
|
|
389
390
|
{
|
|
390
391
|
if (@available(iOS 13.0, *)) {
|
|
391
392
|
if (session != nil) {
|
|
@@ -402,7 +403,7 @@ RCT_EXPORT_METHOD(invalidateSessionWithError:(NSString *)errorMessage callback:(
|
|
|
402
403
|
}
|
|
403
404
|
}
|
|
404
405
|
|
|
405
|
-
|
|
406
|
+
- (void)getTag: (nonnull RCTResponseSenderBlock)callback
|
|
406
407
|
{
|
|
407
408
|
if (@available(iOS 13.0, *)) {
|
|
408
409
|
NSMutableDictionary* rnTag = @{}.mutableCopy;
|
|
@@ -433,7 +434,7 @@ RCT_EXPORT_METHOD(getTag: (nonnull RCTResponseSenderBlock)callback)
|
|
|
433
434
|
}
|
|
434
435
|
}
|
|
435
436
|
|
|
436
|
-
|
|
437
|
+
- (void)getNdefMessage: (nonnull RCTResponseSenderBlock)callback
|
|
437
438
|
{
|
|
438
439
|
if (@available(iOS 13.0, *)) {
|
|
439
440
|
id<NFCNDEFTag> ndefTag = nil;
|
|
@@ -461,7 +462,7 @@ RCT_EXPORT_METHOD(getNdefMessage: (nonnull RCTResponseSenderBlock)callback)
|
|
|
461
462
|
}
|
|
462
463
|
}
|
|
463
464
|
|
|
464
|
-
|
|
465
|
+
- (void)writeNdefMessage:(NSArray*)bytes options:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback
|
|
465
466
|
{
|
|
466
467
|
if (@available(iOS 13.0, *)) {
|
|
467
468
|
id<NFCNDEFTag> ndefTag = nil;
|
|
@@ -496,7 +497,7 @@ RCT_EXPORT_METHOD(writeNdefMessage:(NSArray*)bytes options:(NSDictionary *)optio
|
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
|
|
499
|
-
|
|
500
|
+
- (void)makeReadOnly:(nonnull RCTResponseSenderBlock)callback
|
|
500
501
|
{
|
|
501
502
|
if (@available(iOS 13.0, *)) {
|
|
502
503
|
id<NFCNDEFTag> ndefTag = nil;
|
|
@@ -524,7 +525,7 @@ RCT_EXPORT_METHOD(makeReadOnly:(nonnull RCTResponseSenderBlock)callback)
|
|
|
524
525
|
}
|
|
525
526
|
}
|
|
526
527
|
|
|
527
|
-
|
|
528
|
+
- (void)queryNdefStatus:(nonnull RCTResponseSenderBlock)callback
|
|
528
529
|
{
|
|
529
530
|
if (@available(iOS 13.0, *)) {
|
|
530
531
|
id<NFCNDEFTag> ndefTag = nil;
|
|
@@ -557,7 +558,7 @@ RCT_EXPORT_METHOD(queryNDEFStatus:(nonnull RCTResponseSenderBlock)callback)
|
|
|
557
558
|
}
|
|
558
559
|
}
|
|
559
560
|
|
|
560
|
-
|
|
561
|
+
- (void)setAlertMessage: (NSString *)alertMessage callback:(nonnull RCTResponseSenderBlock)callback
|
|
561
562
|
{
|
|
562
563
|
if (@available(iOS 11.0, *)) {
|
|
563
564
|
if (session != nil) {
|
|
@@ -574,7 +575,7 @@ RCT_EXPORT_METHOD(setAlertMessage: (NSString *)alertMessage callback:(nonnull RC
|
|
|
574
575
|
}
|
|
575
576
|
}
|
|
576
577
|
|
|
577
|
-
|
|
578
|
+
- (void)isSessionAvailable:(nonnull RCTResponseSenderBlock)callback
|
|
578
579
|
{
|
|
579
580
|
if (@available(iOS 11.0, *)) {
|
|
580
581
|
callback(@[[NSNull null], session != nil ? @YES : @NO]);
|
|
@@ -583,7 +584,7 @@ RCT_EXPORT_METHOD(isSessionAvailable:(nonnull RCTResponseSenderBlock)callback)
|
|
|
583
584
|
}
|
|
584
585
|
}
|
|
585
586
|
|
|
586
|
-
|
|
587
|
+
- (void)isTagSessionAvailable:(nonnull RCTResponseSenderBlock)callback
|
|
587
588
|
{
|
|
588
589
|
if (@available(iOS 11.0, *)) {
|
|
589
590
|
callback(@[[NSNull null], tagSession != nil ? @YES : @NO]);
|
|
@@ -591,6 +592,24 @@ RCT_EXPORT_METHOD(isTagSessionAvailable:(nonnull RCTResponseSenderBlock)callback
|
|
|
591
592
|
callback(@[@"Not support in this device", [NSNull null]]);
|
|
592
593
|
}
|
|
593
594
|
}
|
|
595
|
+
|
|
596
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
597
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
598
|
+
return std::make_shared<facebook::react::NativeNfcManagerSpecJSI>(params);
|
|
599
|
+
}
|
|
600
|
+
#endif
|
|
594
601
|
|
|
602
|
+
- (void)echo:(NSString *)value callback:(RCTResponseSenderBlock)callback {
|
|
603
|
+
callback(@[[NSNull null], value]);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
- (void)hasTagEventRegistration:(RCTResponseSenderBlock)callback {
|
|
607
|
+
// bypass, Android's interface
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
- (void)isEnabled:(RCTResponseSenderBlock)callback {
|
|
611
|
+
// bypass, Android's interface
|
|
612
|
+
}
|
|
613
|
+
|
|
595
614
|
@end
|
|
596
615
|
|
package/ios/{Util.m → Util.mm}
RENAMED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
NSString* getHexString(NSData *data) {
|
|
11
11
|
NSUInteger capacity = data.length * 2;
|
|
12
12
|
NSMutableString *sbuf = [NSMutableString stringWithCapacity:capacity];
|
|
13
|
-
const unsigned char *buf = data.bytes;
|
|
13
|
+
const unsigned char *buf = (const unsigned char *)data.bytes;
|
|
14
14
|
NSInteger i;
|
|
15
15
|
for (i=0; i<data.length; ++i) {
|
|
16
16
|
[sbuf appendFormat:@"%02lX", (unsigned long)buf[i]];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nfc-manager",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "A NFC module for react native.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"@babel/plugin-transform-runtime": "^7.12.10",
|
|
50
50
|
"@babel/preset-env": "^7.12.11",
|
|
51
51
|
"@babel/preset-react": "^7.12.10",
|
|
52
|
-
"@expo/config-plugins": "~10.0.0",
|
|
53
52
|
"@react-native-community/eslint-config": "^3.2.0",
|
|
54
53
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
55
54
|
"dotenv-cli": "^7.4.2",
|
|
@@ -60,10 +59,11 @@
|
|
|
60
59
|
"react": "^16.13.1",
|
|
61
60
|
"react-native": "^0.63.0",
|
|
62
61
|
"release-it": "^17.5.0",
|
|
63
|
-
"typescript": "^4.1.3"
|
|
62
|
+
"typescript": "^4.1.3",
|
|
63
|
+
"@expo/config-plugins": "~9.0.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@expo/config-plugins": "
|
|
66
|
+
"@expo/config-plugins": "8 || 9"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"@expo/config-plugins": {
|
|
@@ -75,5 +75,13 @@
|
|
|
75
75
|
"lint:fix": "eslint --fix .",
|
|
76
76
|
"test": "jest -i",
|
|
77
77
|
"release": "dotenv -- release-it --"
|
|
78
|
+
},
|
|
79
|
+
"codegenConfig": {
|
|
80
|
+
"name": "NativeNfcManagerSpec",
|
|
81
|
+
"type": "modules",
|
|
82
|
+
"jsSrcsDir": "specs",
|
|
83
|
+
"android": {
|
|
84
|
+
"javaPackageName": "community.revteltech.nfc"
|
|
85
|
+
}
|
|
78
86
|
}
|
|
79
87
|
}
|
|
@@ -11,12 +11,15 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.authors = package[:author]
|
|
12
12
|
s.summary = package[:description]
|
|
13
13
|
s.source = { git: package[:repository][:url] }
|
|
14
|
-
s.source_files = "ios/**/*.{h,m}"
|
|
14
|
+
# s.source_files = "ios/**/*.{h,m}"
|
|
15
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
15
16
|
s.platform = :ios, "8.0"
|
|
16
17
|
|
|
17
|
-
s.dependency "React-Core"
|
|
18
|
+
# s.dependency "React-Core"
|
|
18
19
|
|
|
19
20
|
s.xcconfig = {
|
|
20
21
|
'OTHER_LDFLAGS': '-weak_framework CoreNFC',
|
|
21
22
|
}
|
|
23
|
+
|
|
24
|
+
install_modules_dependencies(s)
|
|
22
25
|
end
|
package/src/NativeNfcManager.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import {NativeModules, NativeEventEmitter} from 'react-native';
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const isTurboModuleEnabled = global?.__turboModuleProxy != null;
|
|
5
|
+
const NativeNfcManager = isTurboModuleEnabled
|
|
6
|
+
? require('../specs/NativeNfcManager').default
|
|
7
|
+
: NativeModules.NfcManager;
|
|
8
|
+
|
|
5
9
|
const NfcManagerEmitter = new NativeEventEmitter(NativeNfcManager);
|
|
6
10
|
|
|
7
11
|
function callNative(name, params = []) {
|
package/src/NfcManager.js
CHANGED
|
@@ -58,6 +58,14 @@ class NfcManagerBase {
|
|
|
58
58
|
this._subscribeNativeEvents();
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
hello(str) {
|
|
62
|
+
return NativeNfcManager.hello(str);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async echo(msg) {
|
|
66
|
+
return handleNativeException(callNative('echo', [msg]));
|
|
67
|
+
}
|
|
68
|
+
|
|
61
69
|
async start() {
|
|
62
70
|
return handleNativeException(callNative('start'));
|
|
63
71
|
}
|
package/src/NfcManagerAndroid.js
CHANGED
|
@@ -37,7 +37,7 @@ class NfcManagerAndroid extends NfcManagerBase {
|
|
|
37
37
|
this.cleanUpTagRegistration = true;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return await callNative('requestTechnology', [tech]);
|
|
40
|
+
return await callNative('requestTechnology', [tech, options]);
|
|
41
41
|
} catch (ex) {
|
|
42
42
|
throw buildNfcExceptionAndroid(ex);
|
|
43
43
|
}
|
package/src/NfcManagerIOS.js
CHANGED
|
@@ -63,13 +63,10 @@ class NfcManagerIOS extends NfcManagerBase {
|
|
|
63
63
|
);
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
getBackgroundTag =
|
|
67
|
-
|
|
68
|
-
const ndefMessage = await handleNativeException(callNative('getBackgroundNdef'));
|
|
69
|
-
return ndefMessage ? { ndefMessage } : null;
|
|
70
|
-
};
|
|
66
|
+
getBackgroundTag = () =>
|
|
67
|
+
handleNativeException(callNative('getBackgroundTag'));
|
|
71
68
|
|
|
72
|
-
clearBackgroundTag = async () => callNative('
|
|
69
|
+
clearBackgroundTag = async () => callNative('clearBackgroundTag');
|
|
73
70
|
|
|
74
71
|
// -------------------------------------
|
|
75
72
|
// public only for iOS
|
|
@@ -31,10 +31,10 @@ class NdefHandler {
|
|
|
31
31
|
|
|
32
32
|
async getNdefStatus() {
|
|
33
33
|
if (Platform.OS === 'ios') {
|
|
34
|
-
return handleNativeException(callNative('
|
|
34
|
+
return handleNativeException(callNative('queryNdefStatus'));
|
|
35
35
|
} else {
|
|
36
36
|
try {
|
|
37
|
-
const result = await handleNativeException(callNative('
|
|
37
|
+
const result = await handleNativeException(callNative('queryNdefStatus'));
|
|
38
38
|
return {
|
|
39
39
|
status: result.isWritable
|
|
40
40
|
? NdefStatus.ReadWrite
|
|
File without changes
|