@icedevml/react-native-host-card-emulation 0.6.2 → 0.6.4
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.
|
@@ -34,6 +34,21 @@ extension Data {
|
|
|
34
34
|
|
|
35
35
|
@objc public func acquireExclusiveNFC(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
36
36
|
Task.init {
|
|
37
|
+
guard NFCReaderSession.readingAvailable else {
|
|
38
|
+
reject("err_nfc_reader_not_available", "Preflight check failed: NFCReaderSession.readingAvailable is false", nil)
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
guard CardSession.isSupported else {
|
|
43
|
+
reject("err_card_session_unsupported", "Preflight check failed: CardSession.isSupported is false", nil)
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
guard await CardSession.isEligible else {
|
|
48
|
+
reject("err_card_session_not_eligible", "Preflight check failed: CardSession.isEligible is false", nil)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
37
52
|
if self.presentmentIntent != nil && self.presentmentIntent!.isValid {
|
|
38
53
|
reject("err_already_exists", "NFCPresentmentIntentAssertion already exists and is valid.", nil)
|
|
39
54
|
return
|
|
@@ -44,8 +59,7 @@ extension Data {
|
|
|
44
59
|
do {
|
|
45
60
|
self.presentmentIntent = try await NFCPresentmentIntentAssertion.acquire()
|
|
46
61
|
} catch (let error) {
|
|
47
|
-
|
|
48
|
-
reject("err_create_presentment", "Failed to create NFCPresentmentIntentAssertion: \(error)", nil)
|
|
62
|
+
reject("err_create_presentment_\(error)", "Failed to acquire NFCPresentmentIntentAssertion: \(error)", nil)
|
|
49
63
|
return
|
|
50
64
|
}
|
|
51
65
|
|
|
@@ -82,10 +96,11 @@ extension Data {
|
|
|
82
96
|
do {
|
|
83
97
|
self.cardSession = try await CardSession()
|
|
84
98
|
} catch (let error) {
|
|
85
|
-
reject("
|
|
99
|
+
reject("err_create_card_session_\(error)", "Failed to create CardSession: \(error)", nil)
|
|
86
100
|
return
|
|
87
101
|
}
|
|
88
102
|
|
|
103
|
+
self.cardSessionInvalidated = false
|
|
89
104
|
resolve(nil)
|
|
90
105
|
|
|
91
106
|
do {
|
package/js/NativeHCEModule.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {TurboModule
|
|
1
|
+
import type {TurboModule} from 'react-native';
|
|
2
|
+
import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes';
|
|
2
3
|
import {TurboModuleRegistry} from 'react-native';
|
|
3
4
|
|
|
4
5
|
export type HCEModuleEventType =
|
|
@@ -112,14 +113,14 @@ export interface Spec extends TurboModule {
|
|
|
112
113
|
/**
|
|
113
114
|
* Event handler for foreground HCE interactions.
|
|
114
115
|
*/
|
|
115
|
-
readonly onEvent:
|
|
116
|
+
readonly onEvent: EventEmitter<HCEModuleEvent>;
|
|
116
117
|
|
|
117
118
|
/**
|
|
118
119
|
* Event handler for background HCE interactions.
|
|
119
120
|
* NOTE: Don't subscribe to that handler directly, use wrapper hceBackground.ts:createBackgroundHCE.
|
|
120
121
|
* See demo app or README.md for example wrapper usage.
|
|
121
122
|
*/
|
|
122
|
-
readonly onBackgroundEvent:
|
|
123
|
+
readonly onBackgroundEvent: EventEmitter<HCEModuleBackgroundEvent>;
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
export default TurboModuleRegistry.getEnforcing<Spec>(
|
package/package.json
CHANGED