@saltware/fidbek-react-native 0.1.0 → 0.1.2
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
|
@@ -2,17 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Fidbek SDK bridge for React Native with TurboModule (New Architecture / JSI).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Architecture Support
|
|
6
|
+
|
|
7
|
+
- Supported: React Native New Architecture (`newArchEnabled=true`)
|
|
8
|
+
- Not supported: Old Architecture (legacy bridge)
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
- Expo support (development builds via `expo prebuild` / `expo run`)
|
|
9
|
-
- New Architecture only (TurboModule/JSI)
|
|
10
|
-
- API parity with native and Flutter wrappers:
|
|
11
|
-
- `configure({ token, shakeToOpenEnabled })`
|
|
12
|
-
- `open()`
|
|
13
|
-
- `shutdown()`
|
|
10
|
+
## React Native CLI Setup
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
1. Install package:
|
|
16
13
|
|
|
17
14
|
```bash
|
|
18
15
|
npm install @saltware/fidbek-react-native
|
|
@@ -20,136 +17,25 @@ npm install @saltware/fidbek-react-native
|
|
|
20
17
|
yarn add @saltware/fidbek-react-native
|
|
21
18
|
```
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
If your app uses a local package path (for example `file:../fidbek-react-native`), keep the import as:
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import Fidbek from '@saltware/fidbek-react-native';
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Do not import by file-system path in app code.
|
|
32
|
-
|
|
33
|
-
### React Native CLI local setup
|
|
34
|
-
|
|
35
|
-
1. Install from local path in your app `package.json`:
|
|
36
|
-
|
|
37
|
-
```json
|
|
38
|
-
{
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@saltware/fidbek-react-native": "file:../fidbek-react-native"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
2. Add Metro config (`metro.config.js`) so symlinked package resolution works:
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
const path = require('path');
|
|
49
|
-
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
|
|
50
|
-
|
|
51
|
-
const projectRoot = __dirname;
|
|
52
|
-
const packageRoot = path.resolve(projectRoot, '../fidbek-react-native');
|
|
53
|
-
|
|
54
|
-
const config = {
|
|
55
|
-
watchFolders: [packageRoot],
|
|
56
|
-
resolver: {
|
|
57
|
-
unstable_enableSymlinks: true,
|
|
58
|
-
nodeModulesPaths: [path.resolve(projectRoot, 'node_modules')],
|
|
59
|
-
extraNodeModules: {
|
|
60
|
-
'@saltware/fidbek-react-native': packageRoot,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
module.exports = mergeConfig(getDefaultConfig(projectRoot), config);
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
3. If iOS build fails on `[CP] Embed Pods Frameworks` with symlink/codesign errors, patch your `ios/Podfile` `post_install` to replace `--links` with `--copy-links` in `Pods-<App>-frameworks.sh`:
|
|
69
|
-
|
|
70
|
-
```rb
|
|
71
|
-
post_install do |installer|
|
|
72
|
-
react_native_post_install(installer, config[:reactNativePath], :mac_catalyst_enabled => false)
|
|
73
|
-
|
|
74
|
-
frameworks_script_path = File.join(
|
|
75
|
-
installer.sandbox.root,
|
|
76
|
-
'Target Support Files',
|
|
77
|
-
'Pods-YourAppName',
|
|
78
|
-
'Pods-YourAppName-frameworks.sh'
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
if File.exist?(frameworks_script_path)
|
|
82
|
-
content = File.read(frameworks_script_path)
|
|
83
|
-
patched = content.gsub('--links --filter "- CVS/"', '--copy-links --filter "- CVS/"')
|
|
84
|
-
File.write(frameworks_script_path, patched) if patched != content
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Expo local setup
|
|
90
|
-
|
|
91
|
-
1. Install from local path in your Expo app:
|
|
92
|
-
|
|
93
|
-
```json
|
|
94
|
-
{
|
|
95
|
-
"dependencies": {
|
|
96
|
-
"@saltware/fidbek-react-native": "file:../fidbek-react-native"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
2. Add Metro config (`metro.config.js`) for local package resolution:
|
|
102
|
-
|
|
103
|
-
```js
|
|
104
|
-
const path = require('path');
|
|
105
|
-
const { getDefaultConfig } = require('expo/metro-config');
|
|
106
|
-
|
|
107
|
-
const projectRoot = __dirname;
|
|
108
|
-
const packageRoot = path.resolve(projectRoot, '../fidbek-react-native');
|
|
109
|
-
|
|
110
|
-
const config = getDefaultConfig(projectRoot);
|
|
111
|
-
|
|
112
|
-
config.watchFolders = [packageRoot];
|
|
113
|
-
config.resolver.unstable_enableSymlinks = true;
|
|
114
|
-
config.resolver.nodeModulesPaths = [path.resolve(projectRoot, 'node_modules')];
|
|
115
|
-
config.resolver.extraNodeModules = {
|
|
116
|
-
...(config.resolver.extraNodeModules || {}),
|
|
117
|
-
'@saltware/fidbek-react-native': packageRoot,
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
module.exports = config;
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Architecture Support
|
|
124
|
-
|
|
125
|
-
- Supported: React Native New Architecture (`newArchEnabled=true`)
|
|
126
|
-
- Not supported: Old Architecture (legacy bridge)
|
|
127
|
-
|
|
128
|
-
## React Native CLI
|
|
129
|
-
|
|
130
|
-
### iOS
|
|
20
|
+
2. Install iOS pods:
|
|
131
21
|
|
|
132
22
|
```bash
|
|
133
23
|
cd ios && pod install
|
|
134
24
|
```
|
|
135
25
|
|
|
136
|
-
|
|
26
|
+
3. Android has no extra manual step after autolinking.
|
|
137
27
|
|
|
138
|
-
|
|
28
|
+
## Expo Setup
|
|
139
29
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
This package contains custom native code. Use an Expo development build:
|
|
30
|
+
1. Install package:
|
|
143
31
|
|
|
144
32
|
```bash
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
33
|
+
npm install @saltware/fidbek-react-native
|
|
34
|
+
# or
|
|
35
|
+
yarn add @saltware/fidbek-react-native
|
|
148
36
|
```
|
|
149
37
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
Optional `app.json` plugin entry:
|
|
38
|
+
2. (Optional) Add plugin in `app.json`:
|
|
153
39
|
|
|
154
40
|
```json
|
|
155
41
|
{
|
|
@@ -159,23 +45,13 @@ Optional `app.json` plugin entry:
|
|
|
159
45
|
}
|
|
160
46
|
```
|
|
161
47
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
import Fidbek from '@saltware/fidbek-react-native';
|
|
48
|
+
3. Create a development build:
|
|
166
49
|
|
|
167
|
-
await Fidbek.configure({
|
|
168
|
-
token: 'YOUR_PUBLIC_TOKEN',
|
|
169
|
-
shakeToOpenEnabled: true,
|
|
170
|
-
});
|
|
171
50
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
51
|
+
```bash
|
|
52
|
+
npx expo prebuild
|
|
53
|
+
npx expo run:ios
|
|
54
|
+
npx expo run:android
|
|
175
55
|
```
|
|
176
56
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
- iOS 13+
|
|
180
|
-
- Android minSdk 24+
|
|
181
|
-
- React Native 0.75+ with New Architecture enabled
|
|
57
|
+
`Expo Go` is not supported because the module includes native binaries.
|
package/android/build.gradle
CHANGED
|
@@ -64,6 +64,7 @@ dependencies {
|
|
|
64
64
|
implementation "com.facebook.react:react-android"
|
|
65
65
|
implementation "androidx.core:core-ktx:1.13.1"
|
|
66
66
|
implementation "androidx.appcompat:appcompat:1.7.0"
|
|
67
|
+
implementation "androidx.databinding:viewbinding:8.5.2"
|
|
67
68
|
implementation "com.google.android.material:material:1.12.0"
|
|
68
69
|
implementation "com.squareup.okhttp3:okhttp:4.12.0"
|
|
69
70
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.fidbek.reactnative
|
|
2
2
|
|
|
3
|
+
import android.app.Activity
|
|
3
4
|
import android.app.Application
|
|
4
5
|
import com.facebook.react.bridge.Promise
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -24,10 +25,18 @@ internal object FidbekBridge {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
Fidbek.initialize(application, token, shakeToOpenEnabled)
|
|
28
|
+
primeSdkActivityTracker(reactContext.currentActivity)
|
|
27
29
|
promise.resolve(null)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
fun open(promise: Promise) {
|
|
32
|
+
fun open(reactContext: ReactApplicationContext, promise: Promise) {
|
|
33
|
+
val currentActivity = reactContext.currentActivity
|
|
34
|
+
if (currentActivity == null) {
|
|
35
|
+
promise.reject("ERR_NO_CURRENT_ACTIVITY", "Current activity is unavailable")
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
primeSdkActivityTracker(currentActivity)
|
|
31
40
|
Fidbek.open()
|
|
32
41
|
promise.resolve(null)
|
|
33
42
|
}
|
|
@@ -36,4 +45,21 @@ internal object FidbekBridge {
|
|
|
36
45
|
Fidbek.shutdown()
|
|
37
46
|
promise.resolve(null)
|
|
38
47
|
}
|
|
48
|
+
|
|
49
|
+
private fun primeSdkActivityTracker(activity: Activity?) {
|
|
50
|
+
if (activity == null) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
val trackerField = Fidbek::class.java.getDeclaredField("activityTracker")
|
|
56
|
+
trackerField.isAccessible = true
|
|
57
|
+
val tracker = trackerField.get(null) ?: return
|
|
58
|
+
|
|
59
|
+
val onResumed = tracker.javaClass.getMethod("onActivityResumed", Activity::class.java)
|
|
60
|
+
onResumed.invoke(tracker, activity)
|
|
61
|
+
} catch (_: Throwable) {
|
|
62
|
+
// Best-effort priming only.
|
|
63
|
+
}
|
|
64
|
+
}
|
|
39
65
|
}
|
package/package.json
CHANGED