@icedevml/react-native-host-card-emulation 0.9.2 → 1.0.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/Package.swift +87 -0
- package/README.md +216 -152
- package/RTNHCEModuleIOS.podspec +1 -1
- package/android/build.gradle +5 -17
- package/android/src/main/java/com/itsecrnd/rtnhceandroid/BinaryUtils.java +11 -5
- package/android/src/main/java/com/itsecrnd/rtnhceandroid/HCEManager.java +558 -0
- package/android/src/main/java/com/itsecrnd/rtnhceandroid/HCEService.java +22 -299
- package/android/src/main/java/com/itsecrnd/rtnhceandroid/RTNHCEAndroidModule.java +232 -166
- package/android/src/main/java/com/itsecrnd/rtnhceandroid/RTNHCEAndroidPackage.java +5 -4
- package/ios/RTNHCEModuleIOS.mm +69 -48
- package/ios/RTNHCEModuleIOSImpl.swift +429 -100
- package/js/NativeHCEModule.ts +48 -130
- package/js/background.ts +168 -0
- package/js/index.ts +49 -0
- package/js/internal.ts +218 -0
- package/js/session.ts +192 -0
- package/js/types.ts +179 -0
- package/package.json +19 -3
- package/react-native-spm-prefix.h +10 -0
- package/android/src/main/AndroidMainfest.xml +0 -3
- package/android/src/main/java/com/itsecrnd/rtnhceandroid/HCEServiceCallback.java +0 -7
- package/js/hceBackground.ts +0 -68
package/ios/RTNHCEModuleIOS.mm
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
#import "RTNHCEModuleIOS.h"
|
|
2
|
+
|
|
3
|
+
#if __has_include("RCTDefaultReactNativeFactoryDelegate.h")
|
|
2
4
|
#import "RCTDefaultReactNativeFactoryDelegate.h"
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
// the header generated from the Swift sources is named after the module:
|
|
8
|
+
// "RTNHCEModuleIOS" (CocoaPods) or "ReactNativeHostCardEmulationSwift" (SwiftPM)
|
|
9
|
+
#if __has_include("RTNHCEModuleIOS-Swift.h")
|
|
3
10
|
#import "RTNHCEModuleIOS-Swift.h"
|
|
11
|
+
#elif __has_include(<RTNHCEModuleIOS/RTNHCEModuleIOS-Swift.h>)
|
|
12
|
+
#import <RTNHCEModuleIOS/RTNHCEModuleIOS-Swift.h>
|
|
13
|
+
#else
|
|
14
|
+
#import "ReactNativeHostCardEmulationSwift-Swift.h"
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
static NSString *const kUnsupportedCode = @"err_platform_unsupported";
|
|
18
|
+
static NSString *const kUnsupportedMessage = @"This iOS version does not support HCE.";
|
|
4
19
|
|
|
5
20
|
@implementation RTNHCEModuleIOS {
|
|
6
21
|
API_AVAILABLE(ios(17.4))
|
|
@@ -14,39 +29,51 @@
|
|
|
14
29
|
__weak RTNHCEModuleIOS *weakSelf = self;
|
|
15
30
|
|
|
16
31
|
hcemoduleios = [RTNHCEModuleIOSImpl new];
|
|
17
|
-
[hcemoduleios setEmitOnEventWithEmitOnEvent:^(
|
|
18
|
-
[weakSelf emitOnEvent
|
|
32
|
+
[hcemoduleios setEmitOnEventWithEmitOnEvent:^(NSDictionary *value){
|
|
33
|
+
[weakSelf emitOnEvent:value];
|
|
19
34
|
}];
|
|
20
|
-
} else {
|
|
21
|
-
// ignore
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
return(self);
|
|
25
38
|
}
|
|
26
39
|
|
|
40
|
+
// called by React Native when the module is torn down (e.g. JS reload)
|
|
41
|
+
- (void)invalidate {
|
|
42
|
+
if (@available(iOS 17.4, *)) {
|
|
43
|
+
[hcemoduleios invalidateAll];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
27
47
|
- (void)dealloc {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
48
|
+
if (@available(iOS 17.4, *)) {
|
|
49
|
+
[hcemoduleios invalidateAll];
|
|
50
|
+
}
|
|
31
51
|
}
|
|
32
52
|
|
|
33
53
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
34
54
|
return std::make_shared<facebook::react::NativeHCEModuleSpecJSI>(params);
|
|
35
55
|
}
|
|
36
56
|
|
|
37
|
-
- (nonnull
|
|
57
|
+
- (void)getCapabilities:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
38
58
|
if (@available(iOS 17.4, *)) {
|
|
39
|
-
|
|
59
|
+
[hcemoduleios getCapabilitiesWithResolve:resolve reject:reject];
|
|
60
|
+
} else {
|
|
61
|
+
resolve(@{
|
|
62
|
+
@"platform": @"ios",
|
|
63
|
+
@"hceSupported": @NO,
|
|
64
|
+
@"nfcEnabled": @NO,
|
|
65
|
+
@"eligible": @NO,
|
|
66
|
+
@"backgroundSupported": @NO,
|
|
67
|
+
@"presentmentSupported": @NO,
|
|
68
|
+
});
|
|
40
69
|
}
|
|
41
|
-
|
|
42
|
-
return @0;
|
|
43
70
|
}
|
|
44
71
|
|
|
45
72
|
- (void)acquireExclusiveNFC:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
46
73
|
if (@available(iOS 17.4, *)) {
|
|
47
|
-
|
|
74
|
+
[hcemoduleios acquireExclusiveNFCWithResolve:resolve reject:reject];
|
|
48
75
|
} else {
|
|
49
|
-
reject(
|
|
76
|
+
reject(kUnsupportedCode, kUnsupportedMessage, nil);
|
|
50
77
|
}
|
|
51
78
|
}
|
|
52
79
|
|
|
@@ -58,78 +85,72 @@
|
|
|
58
85
|
|
|
59
86
|
- (nonnull NSNumber *)isExclusiveNFC {
|
|
60
87
|
if (@available(iOS 17.4, *)) {
|
|
61
|
-
return [hcemoduleios isExclusiveNFC] ? @
|
|
88
|
+
return [hcemoduleios isExclusiveNFC] ? @YES : @NO;
|
|
62
89
|
}
|
|
63
90
|
|
|
64
|
-
return @
|
|
91
|
+
return @NO;
|
|
65
92
|
}
|
|
66
93
|
|
|
67
|
-
|
|
94
|
+
// allowWhenLocked is ignored, it's impossible to communicate over HCE while the device is locked
|
|
95
|
+
- (void)beginSession:(nonnull NSString *)sessionId allowWhenLocked:(BOOL)allowWhenLocked resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
68
96
|
if (@available(iOS 17.4, *)) {
|
|
69
|
-
|
|
97
|
+
[hcemoduleios beginSessionWithSessionId:sessionId resolve:resolve reject:reject];
|
|
70
98
|
} else {
|
|
71
|
-
reject(
|
|
99
|
+
reject(kUnsupportedCode, kUnsupportedMessage, nil);
|
|
72
100
|
}
|
|
73
101
|
}
|
|
74
102
|
|
|
75
|
-
- (void)
|
|
103
|
+
- (void)invalidateSession:(nonnull NSString *)sessionId {
|
|
76
104
|
if (@available(iOS 17.4, *)) {
|
|
77
|
-
|
|
105
|
+
[hcemoduleios invalidateSessionWithSessionId:sessionId];
|
|
78
106
|
}
|
|
79
107
|
}
|
|
80
108
|
|
|
81
|
-
- (void)
|
|
109
|
+
- (void)setSessionAlertMessage:(nonnull NSString *)sessionId message:(nonnull NSString *)message {
|
|
82
110
|
if (@available(iOS 17.4, *)) {
|
|
83
|
-
[hcemoduleios
|
|
111
|
+
[hcemoduleios setSessionAlertMessageWithSessionId:sessionId message:message];
|
|
84
112
|
}
|
|
85
113
|
}
|
|
86
114
|
|
|
87
|
-
- (nonnull
|
|
115
|
+
- (void)startEmulation:(nonnull NSString *)sessionId resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
88
116
|
if (@available(iOS 17.4, *)) {
|
|
89
|
-
|
|
117
|
+
[hcemoduleios startEmulationWithSessionId:sessionId resolve:resolve reject:reject];
|
|
90
118
|
} else {
|
|
91
|
-
|
|
119
|
+
reject(kUnsupportedCode, kUnsupportedMessage, nil);
|
|
92
120
|
}
|
|
93
121
|
}
|
|
94
122
|
|
|
95
|
-
- (nonnull
|
|
96
|
-
return @0;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
- (nonnull NSNumber *)finishBackgroundHCE:(nonnull NSString *)handle {
|
|
100
|
-
return @0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
- (void)startHCE:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
123
|
+
- (void)stopEmulation:(nonnull NSString *)sessionId status:(nonnull NSString *)status resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
104
124
|
if (@available(iOS 17.4, *)) {
|
|
105
|
-
|
|
125
|
+
[hcemoduleios stopEmulationWithSessionId:sessionId status:status resolve:resolve reject:reject];
|
|
106
126
|
} else {
|
|
107
|
-
reject(
|
|
127
|
+
reject(kUnsupportedCode, kUnsupportedMessage, nil);
|
|
108
128
|
}
|
|
109
129
|
}
|
|
110
130
|
|
|
111
|
-
- (void)
|
|
131
|
+
- (void)isEmulationRunning:(nonnull NSString *)sessionId resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
112
132
|
if (@available(iOS 17.4, *)) {
|
|
113
|
-
|
|
133
|
+
[hcemoduleios isEmulationRunningWithSessionId:sessionId resolve:resolve reject:reject];
|
|
114
134
|
} else {
|
|
115
|
-
|
|
135
|
+
resolve(@NO);
|
|
116
136
|
}
|
|
117
137
|
}
|
|
118
138
|
|
|
119
|
-
- (void)
|
|
139
|
+
- (void)respondApdu:(nonnull NSString *)sessionId apduId:(double)apduId rapdu:(nonnull NSString *)rapdu resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
120
140
|
if (@available(iOS 17.4, *)) {
|
|
121
|
-
|
|
141
|
+
[hcemoduleios respondApduWithSessionId:sessionId apduId:apduId rapdu:rapdu resolve:resolve reject:reject];
|
|
122
142
|
} else {
|
|
123
|
-
reject(
|
|
143
|
+
reject(kUnsupportedCode, kUnsupportedMessage, nil);
|
|
124
144
|
}
|
|
125
145
|
}
|
|
126
146
|
|
|
127
|
-
- (void)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
- (void)setBackgroundHandlerRegistered:(BOOL)registered allowWhenLocked:(BOOL)allowWhenLocked {
|
|
148
|
+
// background HCE is not supported on iOS, no-op
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (nonnull NSNumber *)backgroundSessionReady:(nonnull NSString *)sessionId {
|
|
152
|
+
// background HCE is not supported on iOS
|
|
153
|
+
return @NO;
|
|
133
154
|
}
|
|
134
155
|
|
|
135
156
|
+ (NSString *)moduleName {
|