You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/host-card-emulation/README.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ This module provides a uniform low-level HCE API for both mobile platforms.
128
128
1. Subscribe to the event stream. There is a single global event stream, so you can subscribe early and remain subscribed to events for the entire application's lifetime.
@@ -142,45 +142,45 @@ This module provides a uniform low-level HCE API for both mobile platforms.
142
142
```
143
143
2. When user indicates that he/she wants to perform the HCE action, call the following function from the button's onClick routine:
144
144
```typescript
145
-
awaitNativeHCEModule?.beginSession();
145
+
awaitNativeHCEModule.beginSession();
146
146
```
147
147
This will emit `sessionStarted` event right after the function call, on both iOS and Android platforms. After the session is started, you can decide to start HCE emulation right away in the event handler:
* iOS: Your smartphone will start listening for C-APDUs (Command APDUs originating from reader devices) right after that function is called, which will be additionally indicated by the operating system popping out the NFC scanning user interface prompt.
157
157
* Android: HCE commands will be forwarded to your application from that point on. No specific user interface is displayed (you have to implement it on your own, within your app).
158
158
3. Optionally, you can handle `readerDetected` and `readerDeselected` events to enhance user's experience.
NativeHCEModule?.setSessionAlertMessage('Reader detected'); // only for iOS, no-op in Android
162
+
NativeHCEModule.setSessionAlertMessage('Reader detected'); // only for iOS, no-op in Android
163
163
break;
164
164
165
165
case'readerDeselected':
166
-
NativeHCEModule?.setSessionAlertMessage('Lost reader'); // only for iOS, no-op in Android
166
+
NativeHCEModule.setSessionAlertMessage('Lost reader'); // only for iOS, no-op in Android
167
167
break;
168
168
```
169
169
For those events, trigger mechanisms are platform dependent:
170
170
* iOS: The `readerDetected` event will be emitted as soon as the NFC reader's field presence is observed. The `readerDeselected` event will be emitted if the reader is physically disconnected or a non-matching AID is selected by the reader.
171
171
* Android: The `readerDetected` event will be emitted as soon as the first matching SELECT AID command is observed. The `readerDeselected` event will be emitted if the reader is physically disconnected or a non-matching AID is selected by the reader.
You don't have to respond to the APDU right away from within the event handler, but please remember that the reader might time out if you will be lingering with the response for too long.
@@ -189,7 +189,7 @@ This module provides a uniform low-level HCE API for both mobile platforms.
189
189
190
190
If you need to utilize `NFCPresentmentIntentAssertion` for enhanced user experience, call:
191
191
```typescript
192
-
NativeHCEModule?.acquireExclusiveNFC();
192
+
NativeHCEModule.acquireExclusiveNFC();
193
193
```
194
194
This function will acquire an exclusive NFC access for 15 seconds. On system services or other applications will be able to interfere with NFC during that period. For example, the NFC background tag reading will be disabled so it would not generate any distracting notifications.
195
195
@@ -198,7 +198,7 @@ This function will throw an exception if:
198
198
* 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);
199
199
* the feature is not supported or the device is not eligible for whatever reason;
200
200
201
-
Call `NativeHCEModule?.isExclusiveNFC()` to check if exclusive NFC access is still active.
201
+
Call `NativeHCEModule.isExclusiveNFC()` to check if exclusive NFC access is still active.
202
202
203
203
### Android: Handle HCE calls when the app is not running
204
204
@@ -216,7 +216,7 @@ for instance - your app may emulate an NDEF tag even when it's not launched on t
216
216
}
217
217
});
218
218
```
219
-
2. Register onBackgroundEvent listener in your `runBackground()` function and call to `awaitNativeHCEModule?.initBackgroundHCE()` at the very end, after the event listener is fully set up.
219
+
2. Register onBackgroundEvent listener in your `runBackground()` function and call to `awaitNativeHCEModule.initBackgroundHCE()` at the very end, after the event listener is fully set up.
0 commit comments