@icedevml/react-native-host-card-emulation 0.6.4 → 0.7.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/README.md CHANGED
@@ -200,6 +200,11 @@ This function will throw an exception if:
200
200
  * you are in the cooldown period where you are not allowed to acquire the presentment intent assertion (cooldown is 15 seconds after the previous assertion had expired);
201
201
  * the feature is not supported or the device is not eligible for whatever reason;
202
202
 
203
+ Whenever you don't need the exclusive NFC access anymore, call the following function to release the `NFCPresentmentIntentAssertion` object:
204
+ ```typescript
205
+ await NativeHCEModule.releaseExclusiveNFC();
206
+ ```
207
+
203
208
  Call `NativeHCEModule.isExclusiveNFC()` to check if exclusive NFC access is still active.
204
209
 
205
210
  ### Android: Handle HCE calls when the app is not running
@@ -119,6 +119,12 @@ public class RTNHCEAndroidModule extends NativeHCEModuleSpec {
119
119
  promise.reject("err_platform_unsupported", "acquireExclusiveNFC() is not supported on Android.");
120
120
  }
121
121
 
122
+ @Override
123
+ public void releaseExclusiveNFC() {
124
+ Log.d(TAG, "RTNHCEAndroidModule:releaseExclusiveNFC");
125
+ // unsupported on Android, no-op
126
+ }
127
+
122
128
  @Override
123
129
  public boolean isExclusiveNFC() {
124
130
  Log.d(TAG, "RTNHCEAndroidModule:isExclusiveNFC");
@@ -50,6 +50,12 @@
50
50
  }
51
51
  }
52
52
 
53
+ - (void)releaseExclusiveNFC {
54
+ if (@available(iOS 17.4, *)) {
55
+ [hcemoduleios releaseExclusiveNFC];
56
+ }
57
+ }
58
+
53
59
  - (nonnull NSNumber *)isExclusiveNFC {
54
60
  if (@available(iOS 17.4, *)) {
55
61
  return [hcemoduleios isExclusiveNFC] ? @1 : @0;
@@ -90,6 +96,10 @@
90
96
  return @0;
91
97
  }
92
98
 
99
+ - (nonnull NSNumber *)finishBackgroundHCE:(nonnull NSString *)handle {
100
+ return @0;
101
+ }
102
+
93
103
  - (void)startHCE:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
94
104
  if (@available(iOS 17.4, *)) {
95
105
  return [hcemoduleios startHCEWithResolve:resolve reject:reject];
@@ -38,7 +38,7 @@ extension Data {
38
38
  reject("err_nfc_reader_not_available", "Preflight check failed: NFCReaderSession.readingAvailable is false", nil)
39
39
  return
40
40
  }
41
-
41
+
42
42
  guard CardSession.isSupported else {
43
43
  reject("err_card_session_unsupported", "Preflight check failed: CardSession.isSupported is false", nil)
44
44
  return
@@ -67,6 +67,10 @@ extension Data {
67
67
  }
68
68
  }
69
69
 
70
+ @objc public func releaseExclusiveNFC() {
71
+ self.presentmentIntent = nil
72
+ }
73
+
70
74
  @objc public func isExclusiveNFC() -> Bool {
71
75
  return self.presentmentIntent != nil && self.presentmentIntent!.isValid
72
76
  }
@@ -166,7 +170,7 @@ extension Data {
166
170
  reject("err_illegal_state", "The provided handle is invalid.", nil)
167
171
  return
168
172
  }
169
-
173
+
170
174
  guard let capdu = self.receivedCardAPDU else {
171
175
  reject("err_no_apdu_received", "There is no received APDU to respond to.", nil)
172
176
  return
@@ -47,6 +47,11 @@ export interface Spec extends TurboModule {
47
47
  * Android: Not supported (throws an exception).
48
48
  */
49
49
  acquireExclusiveNFC(): Promise<void>;
50
+ /**
51
+ * iOS: Release NFCPresentmentIntentAssertion object.
52
+ * Android: Not supported (no-op).
53
+ */
54
+ releaseExclusiveNFC(): void;
50
55
  /**
51
56
  * iOS: Whether the NFCPresentmentIntentAssertion is acquired and still valid.
52
57
  * Android: Always false.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icedevml/react-native-host-card-emulation",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "description": "Host Card Emulation (HCE) React Native Turbo Module for iOS and Android platforms.",
5
5
  "react-native": "js/index",
6
6
  "source": "js/index",