halo-sdk-react-native 1.0.2 → 1.0.3
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 +61 -38
- package/android/src/main/AndroidManifest.xml +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -131,9 +131,21 @@ if (localPropertiesFile.exists()) {
|
|
|
131
131
|
}
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
**4.** Add the following `packagingOptions` block inside the `android { }` closure in `android/app/build.gradle`. This prevents a duplicate-file error caused by OSGI metadata bundled in the SDK's transitive dependencies:
|
|
135
|
+
|
|
136
|
+
```gradle
|
|
137
|
+
android {
|
|
138
|
+
// ... your existing config ...
|
|
139
|
+
|
|
140
|
+
packagingOptions {
|
|
141
|
+
resources.excludes.add("META-INF/versions/9/OSGI-INF/MANIFEST.MF")
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
134
146
|
### Native Module Setup
|
|
135
147
|
|
|
136
|
-
**
|
|
148
|
+
**5.** Open `android/app/src/main/kotlin/.../MainActivity.kt` and extend `HaloReactActivity` instead of `ReactActivity`:
|
|
137
149
|
|
|
138
150
|
```kotlin
|
|
139
151
|
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
|
@@ -151,40 +163,6 @@ class MainActivity : HaloReactActivity() {
|
|
|
151
163
|
|
|
152
164
|
This replaces `ReactActivity` so that NFC foreground dispatch and the Halo SDK lifecycle are managed automatically.
|
|
153
165
|
|
|
154
|
-
**5.** Open `android/app/src/main/kotlin/.../MainApplication.kt` and register `HaloSdkPackage`:
|
|
155
|
-
|
|
156
|
-
```kotlin
|
|
157
|
-
import android.app.Application
|
|
158
|
-
import com.facebook.react.PackageList
|
|
159
|
-
import com.facebook.react.ReactApplication
|
|
160
|
-
import com.facebook.react.ReactNativeHost
|
|
161
|
-
import com.facebook.react.ReactPackage
|
|
162
|
-
import com.facebook.react.defaults.DefaultReactNativeHost
|
|
163
|
-
import com.facebook.soloader.SoLoader
|
|
164
|
-
import za.co.synthesis.halo.sdkreactnativeplugin.HaloSdkPackage // <-- add this import
|
|
165
|
-
|
|
166
|
-
class MainApplication : Application(), ReactApplication {
|
|
167
|
-
|
|
168
|
-
override val reactNativeHost: ReactNativeHost =
|
|
169
|
-
object : DefaultReactNativeHost(this) {
|
|
170
|
-
override fun getPackages(): List<ReactPackage> =
|
|
171
|
-
PackageList(this).packages.apply {
|
|
172
|
-
add(HaloSdkPackage()) // <-- add this line
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
override fun getJSMainModuleName(): String = "index"
|
|
176
|
-
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
|
177
|
-
override val isNewArchEnabled: Boolean = false
|
|
178
|
-
override val isHermesEnabled: Boolean = true
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
override fun onCreate() {
|
|
182
|
-
super.onCreate()
|
|
183
|
-
SoLoader.init(this, false)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
166
|
### AndroidManifest Permissions
|
|
189
167
|
|
|
190
168
|
**6.** Add the required permissions to `android/app/src/main/AndroidManifest.xml`:
|
|
@@ -218,7 +196,14 @@ class MainApplication : Application(), ReactApplication {
|
|
|
218
196
|
|
|
219
197
|
<uses-feature android:name="android.hardware.nfc" android:required="true" />
|
|
220
198
|
|
|
221
|
-
|
|
199
|
+
<!--
|
|
200
|
+
tools:replace is required because the Halo SDK (and its bundled Visa library)
|
|
201
|
+
declare android:label and android:allowBackup in their own manifests.
|
|
202
|
+
Without these overrides the manifest merger will refuse to build.
|
|
203
|
+
-->
|
|
204
|
+
<application
|
|
205
|
+
...
|
|
206
|
+
tools:replace="android:label,android:allowBackup">
|
|
222
207
|
<activity
|
|
223
208
|
android:name=".MainActivity"
|
|
224
209
|
...>
|
|
@@ -440,7 +425,7 @@ Below is a minimal but complete payment screen taken directly from the example a
|
|
|
440
425
|
|
|
441
426
|
```tsx
|
|
442
427
|
// App.tsx
|
|
443
|
-
import
|
|
428
|
+
import { useEffect, useState } from 'react';
|
|
444
429
|
import {
|
|
445
430
|
ActivityIndicator,
|
|
446
431
|
Text,
|
|
@@ -682,7 +667,6 @@ compileSdkVersion localProperties.getProperty('compileSdkVersion').toInteger()
|
|
|
682
667
|
**Q: I get a build error about `HaloReactActivity` or `HaloSdkPackage` not found.**
|
|
683
668
|
|
|
684
669
|
- Confirm the npm package is installed: `npm install halo-sdk-react-native`
|
|
685
|
-
- Confirm `HaloSdkPackage()` is added in `MainApplication.kt`
|
|
686
670
|
- Confirm `MainActivity` extends `HaloReactActivity` (not `ReactActivity`)
|
|
687
671
|
- Run a Gradle sync in Android Studio
|
|
688
672
|
|
|
@@ -703,6 +687,45 @@ A JWT must be generated using your RSA private key and the credentials from the
|
|
|
703
687
|
|
|
704
688
|
---
|
|
705
689
|
|
|
690
|
+
**Q: Manifest merger fails with an attribute conflict (e.g. `android:label`, `android:allowBackup`).**
|
|
691
|
+
|
|
692
|
+
The Halo SDK bundles several sub-libraries (Visa Sensory Branding, etc.), each with their own `AndroidManifest.xml`. Any `processDebugMainManifest` failure caused by an attribute clash is fixed by adding the conflicting attribute name to `tools:replace` on your `<application>` element:
|
|
693
|
+
|
|
694
|
+
```xml
|
|
695
|
+
<application
|
|
696
|
+
...
|
|
697
|
+
tools:replace="android:label,android:allowBackup">
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
If you add a new attribute to `tools:replace` and the **same error persists on the very next build**, Gradle may have cached the previously failed manifest merge. Run a clean build and try again:
|
|
701
|
+
|
|
702
|
+
```bash
|
|
703
|
+
cd android && ./gradlew clean
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
Then re run your normal build (`npx react-native run-android` or Android Studio).
|
|
707
|
+
|
|
708
|
+
---
|
|
709
|
+
|
|
710
|
+
**Q: TypeScript build errors about `customConditions` or `moduleResolution` after editing `tsconfig.json`.**
|
|
711
|
+
|
|
712
|
+
Do not override `moduleResolution` in your project's `tsconfig.json`. The base `@react-native/typescript-config` sets `"moduleResolution": "bundler"`, which is the only value compatible with its `customConditions` setting. Overriding it to `"node"` causes a TypeScript error.
|
|
713
|
+
|
|
714
|
+
Instead, extend the base config and only add project specific overrides:
|
|
715
|
+
|
|
716
|
+
```json
|
|
717
|
+
{
|
|
718
|
+
"extends": "@react-native/typescript-config/tsconfig.json",
|
|
719
|
+
"compilerOptions": {
|
|
720
|
+
"skipLibCheck": true
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
`skipLibCheck: true` suppresses spurious type errors that originate inside `node_modules` (e.g. phantom `@types/react` v19 conflicts) without changing how your own code is compiled.
|
|
726
|
+
|
|
727
|
+
---
|
|
728
|
+
|
|
706
729
|
**Q: `onInitializationResult` fires with `resultType: 'RemoteAttestationFailure'` and `errorCode: 'JWTExpired'`.**
|
|
707
730
|
|
|
708
731
|
Your temp JWT has expired. Developer-portal tokens are short-lived (typically 15 minutes). This is expected behaviour — the SDK fires a failure callback with the cached/expired token, then automatically requests a new JWT via `onRequestJWT` and retries. If `onInitializationResult` fires a **second time** shortly after with `resultType: 'Initialized'`, everything is working correctly.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
2
3
|
package="za.co.synthesis.halo.sdkreactnativeplugin">
|
|
3
|
-
<application
|
|
4
|
+
<application
|
|
5
|
+
tools:replace="android:label,android:allowBackup">
|
|
4
6
|
<activity
|
|
5
7
|
android:name=".AnimationActivity"
|
|
6
8
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|