@dashx/react-native 1.1.1 → 1.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 +62 -7
- package/android/.gitignore +10 -0
- package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/DashXReactNativeFirebaseMessagingService.dex +0 -0
- package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/DashXReactNativeModule.dex +0 -0
- package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/MessageReceivedEventHolder.dex +0 -0
- package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/Utils$WhenMappings.dex +0 -0
- package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/dashx/rn/sdk/util/Utils.dex +0 -0
- package/android/build/.transforms/9dceace6c3787533d2dbb1a387e9284c/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/f3c6049e7ab4bb564c79f3a246b8575e/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +16 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +31 -5
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +16 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/DashXReactNativeFirebaseMessagingService.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/DashXReactNativeModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/MessageReceivedEventHolder.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/util/Utils$WhenMappings.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/dashx/rn/sdk/util/Utils.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +25 -3
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/DashXReactNativeFirebaseMessagingService.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/DashXReactNativeModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/MessageReceivedEventHolder.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/util/Utils$WhenMappings.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/util/Utils.class +0 -0
- package/android/build.gradle +4 -1
- package/android/src/main/AndroidManifest.xml +15 -3
- package/android/src/main/java/com/dashx/rn/sdk/DashXReactNativeFirebaseMessagingService.kt +72 -0
- package/android/src/main/java/com/dashx/rn/sdk/DashXReactNativeModule.kt +84 -15
- package/android/src/main/java/com/dashx/rn/sdk/MessageReceivedEventHolder.kt +14 -0
- package/android/src/main/java/com/dashx/rn/sdk/util/Utils.kt +14 -0
- package/index.d.ts +37 -0
- package/index.js +20 -0
- package/ios/DashXEventEmitter.swift +3 -2
- package/ios/DashXRCTAppDelegate.swift +38 -0
- package/ios/DashXReactNative.mm +4 -0
- package/ios/DashXReactNative.swift +15 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -161,16 +161,25 @@ import DashX from '@dashx/react-native';
|
|
|
161
161
|
|
|
162
162
|
### Configure
|
|
163
163
|
|
|
164
|
-
Initialize the SDK
|
|
164
|
+
Initialize the SDK once at app startup. Call `configure` at the top level of your entry file (e.g. `App.js`) so it runs before any component mounts:
|
|
165
165
|
|
|
166
166
|
```js
|
|
167
|
+
// App.js — call at module level, before the component
|
|
168
|
+
import DashX from '@dashx/react-native';
|
|
169
|
+
|
|
167
170
|
DashX.configure({
|
|
168
171
|
publicKey: 'your-public-key',
|
|
169
172
|
// baseURI: 'https://api.dashx.com', // optional, custom API endpoint
|
|
170
173
|
// targetEnvironment: 'production', // optional
|
|
171
174
|
});
|
|
175
|
+
|
|
176
|
+
export default function App() {
|
|
177
|
+
// ...
|
|
178
|
+
}
|
|
172
179
|
```
|
|
173
180
|
|
|
181
|
+
Calling from `useEffect` in your root component also works, but module-level init is preferred so the SDK is ready as early as possible.
|
|
182
|
+
|
|
174
183
|
| Option | Type | Required | Description |
|
|
175
184
|
|--------|------|----------|-------------|
|
|
176
185
|
| `publicKey` | `string` | Yes | Your DashX public key |
|
|
@@ -218,6 +227,51 @@ DashX.screen('HomeScreen', {
|
|
|
218
227
|
});
|
|
219
228
|
```
|
|
220
229
|
|
|
230
|
+
### Fetch a record
|
|
231
|
+
|
|
232
|
+
Fetch a single record by URN (e.g. `"article/123"`) with optional options (matches [dashx-android](https://github.com/dashxhq/dashx-android) `fetchRecord`). **Android only**; on iOS the promise rejects until the native SDK supports it.
|
|
233
|
+
|
|
234
|
+
```js
|
|
235
|
+
const record = await DashX.fetchRecord('article/123', {
|
|
236
|
+
preview: false,
|
|
237
|
+
language: 'en',
|
|
238
|
+
// fields, include, exclude as arrays of objects if needed
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
| Option | Type | Description |
|
|
243
|
+
|--------|------|-------------|
|
|
244
|
+
| `preview` | `boolean` | Include draft/preview content |
|
|
245
|
+
| `language` | `string` | Content language |
|
|
246
|
+
| `fields` | `object[]` | Fields to return |
|
|
247
|
+
| `include` | `object[]` | Related data to include |
|
|
248
|
+
| `exclude` | `object[]` | Fields to exclude |
|
|
249
|
+
|
|
250
|
+
### Search records
|
|
251
|
+
|
|
252
|
+
Search records by resource with optional filter, order, limit, and other options (matches [dashx-android](https://github.com/dashxhq/dashx-android) `searchRecords`). **Android only**; on iOS the promise rejects until the native SDK supports it.
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
const records = await DashX.searchRecords('article', {
|
|
256
|
+
filter: { status: 'published' },
|
|
257
|
+
order: [{ field: 'createdAt', direction: 'desc' }],
|
|
258
|
+
limit: 10,
|
|
259
|
+
preview: false,
|
|
260
|
+
language: 'en',
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
| Option | Type | Description |
|
|
265
|
+
|--------|------|-------------|
|
|
266
|
+
| `filter` | `object` | Filter criteria |
|
|
267
|
+
| `order` | `object[]` | Sort order (e.g. `[{ field, direction }]`) |
|
|
268
|
+
| `limit` | `number` | Max records to return |
|
|
269
|
+
| `preview` | `boolean` | Preview/draft content |
|
|
270
|
+
| `language` | `string` | Content language |
|
|
271
|
+
| `fields` | `object[]` | Fields to return |
|
|
272
|
+
| `include` | `object[]` | Related data to include |
|
|
273
|
+
| `exclude` | `object[]` | Fields to exclude |
|
|
274
|
+
|
|
221
275
|
### Push notifications
|
|
222
276
|
|
|
223
277
|
Subscribe the current device to push notifications:
|
|
@@ -280,16 +334,15 @@ Below is a full example of integrating DashX in a React Native Android app:
|
|
|
280
334
|
|
|
281
335
|
```js
|
|
282
336
|
// App.js
|
|
283
|
-
import React
|
|
337
|
+
import React from 'react';
|
|
284
338
|
import { View, Text, Button, StyleSheet } from 'react-native';
|
|
285
339
|
import DashX from '@dashx/react-native';
|
|
286
340
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
DashX.subscribe();
|
|
291
|
-
}, []);
|
|
341
|
+
// Initialize once at app load
|
|
342
|
+
DashX.configure({ publicKey: 'your-public-key' });
|
|
343
|
+
DashX.subscribe();
|
|
292
344
|
|
|
345
|
+
export default function App() {
|
|
293
346
|
const handleLogin = () => {
|
|
294
347
|
DashX.setIdentity('user-123', 'auth-token');
|
|
295
348
|
DashX.identify({
|
|
@@ -334,6 +387,8 @@ const styles = StyleSheet.create({
|
|
|
334
387
|
| `reset` | `()` | `void` | Clear the current user identity |
|
|
335
388
|
| `track` | `(event: string, data?: object)` | `void` | Track a named event with optional data |
|
|
336
389
|
| `screen` | `(screenName: string, data?: object)` | `void` | Track a screen view with optional data |
|
|
390
|
+
| `fetchRecord` | `(urn: string, options?: object)` | `Promise<object>` | Fetch a single record by URN (e.g. `"article/123"`). Options: preview, language, fields, include, exclude. Android only; iOS rejects until implemented. |
|
|
391
|
+
| `searchRecords` | `(resource: string, options?: object)` | `Promise<object[]>` | Search records (filter, order, limit, preview, language, fields, include, exclude). Android only; iOS rejects until implemented. |
|
|
337
392
|
| `subscribe` | `()` | `void` | Subscribe device for push notifications |
|
|
338
393
|
| `unsubscribe` | `()` | `void` | Unsubscribe device from push notifications |
|
|
339
394
|
| `fetchStoredPreferences` | `()` | `Promise<object>` | Fetch stored notification preferences |
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
3
4
|
package="com.dashx.rn.sdk" >
|
|
4
5
|
|
|
5
6
|
<uses-sdk android:minSdkVersion="26" />
|
|
6
7
|
|
|
8
|
+
<application>
|
|
9
|
+
|
|
10
|
+
<!-- Replace dashx-android's FCM service with our subclass that also emits to JS. -->
|
|
11
|
+
<service
|
|
12
|
+
android:name="com.dashx.android.DashXFirebaseMessagingService"
|
|
13
|
+
tools:node="remove" />
|
|
14
|
+
<service
|
|
15
|
+
android:name="com.dashx.rn.sdk.DashXReactNativeFirebaseMessagingService"
|
|
16
|
+
android:exported="false" >
|
|
17
|
+
<intent-filter>
|
|
18
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
19
|
+
</intent-filter>
|
|
20
|
+
</service>
|
|
21
|
+
</application>
|
|
22
|
+
|
|
7
23
|
</manifest>
|
|
Binary file
|
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
1<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
3
|
|
4
|
-
4
|
|
5
|
-
5
|
|
6
|
-
6
|
|
7
|
-
7
|
|
3
|
+
3 xmlns:tools="http://schemas.android.com/tools"
|
|
4
|
+
4 package="com.dashx.rn.sdk" >
|
|
5
|
+
5
|
|
6
|
+
6 <uses-sdk android:minSdkVersion="26" />
|
|
7
|
+
7
|
|
8
|
+
8 <application>
|
|
9
|
+
8-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:3:5-15:19
|
|
10
|
+
9
|
|
11
|
+
10 <!-- Replace dashx-android's FCM service with our subclass that also emits to JS. -->
|
|
12
|
+
11 <service
|
|
13
|
+
11-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:5:9-7:35
|
|
14
|
+
12 android:name="com.dashx.android.DashXFirebaseMessagingService"
|
|
15
|
+
12-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:6:13-75
|
|
16
|
+
13 tools:node="remove" />
|
|
17
|
+
13-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:7:13-32
|
|
18
|
+
14 <service
|
|
19
|
+
14-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:8:9-14:19
|
|
20
|
+
15 android:name="com.dashx.rn.sdk.DashXReactNativeFirebaseMessagingService"
|
|
21
|
+
15-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:9:13-85
|
|
22
|
+
16 android:exported="false" >
|
|
23
|
+
16-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:10:13-37
|
|
24
|
+
17 <intent-filter>
|
|
25
|
+
17-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:11:13-13:29
|
|
26
|
+
18 <action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
27
|
+
18-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:12:17-78
|
|
28
|
+
18-->/Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:12:25-75
|
|
29
|
+
19 </intent-filter>
|
|
30
|
+
20 </service>
|
|
31
|
+
21 </application>
|
|
32
|
+
22
|
|
33
|
+
23</manifest>
|
package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
3
4
|
package="com.dashx.rn.sdk" >
|
|
4
5
|
|
|
5
6
|
<uses-sdk android:minSdkVersion="26" />
|
|
6
7
|
|
|
8
|
+
<application>
|
|
9
|
+
|
|
10
|
+
<!-- Replace dashx-android's FCM service with our subclass that also emits to JS. -->
|
|
11
|
+
<service
|
|
12
|
+
android:name="com.dashx.android.DashXFirebaseMessagingService"
|
|
13
|
+
tools:node="remove" />
|
|
14
|
+
<service
|
|
15
|
+
android:name="com.dashx.rn.sdk.DashXReactNativeFirebaseMessagingService"
|
|
16
|
+
android:exported="false" >
|
|
17
|
+
<intent-filter>
|
|
18
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
19
|
+
</intent-filter>
|
|
20
|
+
</service>
|
|
21
|
+
</application>
|
|
22
|
+
|
|
7
23
|
</manifest>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i
CHANGED
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len
CHANGED
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i
CHANGED
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i
CHANGED
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
9
|
|
2
2
|
0
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len
CHANGED
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
-- Merging decision tree log ---
|
|
2
2
|
manifest
|
|
3
|
-
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:
|
|
4
|
-
INJECTED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:
|
|
3
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:1:1-16:12
|
|
4
|
+
INJECTED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:1:1-16:12
|
|
5
5
|
package
|
|
6
6
|
INJECTED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml
|
|
7
|
+
xmlns:tools
|
|
8
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:2:5-51
|
|
7
9
|
xmlns:android
|
|
8
|
-
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:
|
|
10
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:1:11-69
|
|
11
|
+
application
|
|
12
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:3:5-15:19
|
|
13
|
+
service#com.dashx.android.DashXFirebaseMessagingService
|
|
14
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:5:9-7:35
|
|
15
|
+
tools:node
|
|
16
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:7:13-32
|
|
17
|
+
android:name
|
|
18
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:6:13-75
|
|
19
|
+
service#com.dashx.rn.sdk.DashXReactNativeFirebaseMessagingService
|
|
20
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:8:9-14:19
|
|
21
|
+
android:exported
|
|
22
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:10:13-37
|
|
23
|
+
android:name
|
|
24
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:9:13-85
|
|
25
|
+
intent-filter#action:name:com.google.firebase.MESSAGING_EVENT
|
|
26
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:11:13-13:29
|
|
27
|
+
action#com.google.firebase.MESSAGING_EVENT
|
|
28
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:12:17-78
|
|
29
|
+
android:name
|
|
30
|
+
ADDED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml:12:25-75
|
|
9
31
|
uses-sdk
|
|
10
32
|
INJECTED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml reason: use-sdk injection requested
|
|
11
33
|
INJECTED from /Users/gulshan/Work/dashx-demo-rn/node_modules/@dashx/react-native/android/src/main/AndroidManifest.xml
|
|
Binary file
|
|
Binary file
|
package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/DashXReactNativeModule.class
CHANGED
|
Binary file
|
package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/MessageReceivedEventHolder.class
ADDED
|
Binary file
|
package/android/build/tmp/kotlin-classes/debug/com/dashx/rn/sdk/util/Utils$WhenMappings.class
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -52,5 +52,8 @@ dependencies {
|
|
|
52
52
|
implementation 'com.google.code.gson:gson:2.9.0'
|
|
53
53
|
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0'
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
// Ensure Firebase Messaging types are available for FCM service subclass
|
|
56
|
+
implementation 'com.google.firebase:firebase-messaging-ktx:23.1.2'
|
|
57
|
+
|
|
58
|
+
implementation "com.dashx:dashx-android:1.1.4"
|
|
56
59
|
}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
xmlns:tools="http://schemas.android.com/tools">
|
|
3
|
+
<application>
|
|
4
|
+
<!-- Replace dashx-android's FCM service with our subclass that also emits to JS. -->
|
|
5
|
+
<service
|
|
6
|
+
android:name="com.dashx.android.DashXFirebaseMessagingService"
|
|
7
|
+
tools:node="remove" />
|
|
8
|
+
<service
|
|
9
|
+
android:name="com.dashx.rn.sdk.DashXReactNativeFirebaseMessagingService"
|
|
10
|
+
android:exported="false">
|
|
11
|
+
<intent-filter>
|
|
12
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
13
|
+
</intent-filter>
|
|
14
|
+
</service>
|
|
15
|
+
</application>
|
|
4
16
|
</manifest>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package com.dashx.rn.sdk
|
|
2
|
+
|
|
3
|
+
import com.dashx.android.DashXFirebaseMessagingService
|
|
4
|
+
import com.dashx.android.DashXLog
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.bridge.WritableMap
|
|
8
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
9
|
+
import com.google.firebase.messaging.RemoteMessage
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Extends dashx-android's FCM service to also emit "messageReceived" to the React Native JS layer
|
|
13
|
+
* so that DashX.onMessageReceived() callbacks receive push notifications.
|
|
14
|
+
*/
|
|
15
|
+
class DashXReactNativeFirebaseMessagingService : DashXFirebaseMessagingService() {
|
|
16
|
+
|
|
17
|
+
private val tag = DashXReactNativeFirebaseMessagingService::class.java.simpleName
|
|
18
|
+
|
|
19
|
+
override fun onMessageReceived(remoteMessage: RemoteMessage) {
|
|
20
|
+
// Preserve dashx-android behavior (notification display + tracking)
|
|
21
|
+
super.onMessageReceived(remoteMessage)
|
|
22
|
+
|
|
23
|
+
val context = MessageReceivedEventHolder.reactContext ?: run {
|
|
24
|
+
DashXLog.d(tag, "React context not available, skipping JS emit")
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!context.hasActiveReactInstance()) {
|
|
29
|
+
DashXLog.d(tag, "No active React instance, skipping JS emit")
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
val payload = remoteMessageToWritableMap(remoteMessage)
|
|
34
|
+
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
35
|
+
.emit("messageReceived", payload)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private fun remoteMessageToWritableMap(remoteMessage: RemoteMessage): WritableMap {
|
|
39
|
+
val map = Arguments.createMap()
|
|
40
|
+
|
|
41
|
+
// Data payload (always present as Map<String, String>)
|
|
42
|
+
remoteMessage.data.let { data ->
|
|
43
|
+
if (!data.isNullOrEmpty()) {
|
|
44
|
+
val dataMap = Arguments.createMap()
|
|
45
|
+
for ((key, value) in data) {
|
|
46
|
+
dataMap.putString(key, value)
|
|
47
|
+
}
|
|
48
|
+
map.putMap("data", dataMap)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Notification payload (if present)
|
|
53
|
+
remoteMessage.notification?.let { notification ->
|
|
54
|
+
val notifMap = Arguments.createMap()
|
|
55
|
+
notification.title?.let { notifMap.putString("title", it) }
|
|
56
|
+
notification.body?.let { notifMap.putString("body", it) }
|
|
57
|
+
notification.bodyLocalizationKey?.let { notifMap.putString("bodyLocalizationKey", it) }
|
|
58
|
+
notification.titleLocalizationKey?.let { notifMap.putString("titleLocalizationKey", it) }
|
|
59
|
+
notification.channelId?.let { notifMap.putString("channelId", it) }
|
|
60
|
+
notification.clickAction?.let { notifMap.putString("clickAction", it) }
|
|
61
|
+
notification.tag?.let { notifMap.putString("tag", it) }
|
|
62
|
+
notification.imageUrl?.toString()?.let { notifMap.putString("imageUrl", it) }
|
|
63
|
+
map.putMap("notification", notifMap)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
remoteMessage.messageId?.let { map.putString("messageId", it) }
|
|
67
|
+
remoteMessage.senderId?.let { map.putString("senderId", it) }
|
|
68
|
+
remoteMessage.from?.let { map.putString("from", it) }
|
|
69
|
+
|
|
70
|
+
return map
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -13,6 +13,16 @@ import kotlinx.serialization.json.JsonObject
|
|
|
13
13
|
class DashXReactNativeModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
14
14
|
private val tag = DashXReactNativeModule::class.java.simpleName
|
|
15
15
|
|
|
16
|
+
override fun initialize() {
|
|
17
|
+
super.initialize()
|
|
18
|
+
MessageReceivedEventHolder.reactContext = reactContext
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun invalidate() {
|
|
22
|
+
MessageReceivedEventHolder.reactContext = null
|
|
23
|
+
super.invalidate()
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
override fun getName(): String {
|
|
17
27
|
return "DashXReactNative"
|
|
18
28
|
}
|
|
@@ -77,11 +87,38 @@ class DashXReactNativeModule(private val reactContext: ReactApplicationContext)
|
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
@ReactMethod
|
|
80
|
-
fun
|
|
90
|
+
fun fetchRecord(urn: String, options: ReadableMap?, promise: Promise) {
|
|
91
|
+
val preview = options?.getBooleanIfPresent("preview")
|
|
92
|
+
val language = options?.getStringIfPresent("language")
|
|
93
|
+
val fields = try {
|
|
94
|
+
convertReadableArrayToKJsonList(options?.getArray("fields"))
|
|
95
|
+
} catch (e: Exception) {
|
|
96
|
+
DashXLog.d(tag, e.message)
|
|
97
|
+
promise.reject("EUNSPECIFIED", "Error parsing fields: ${e.message}")
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
val include = try {
|
|
101
|
+
convertReadableArrayToKJsonList(options?.getArray("include"))
|
|
102
|
+
} catch (e: Exception) {
|
|
103
|
+
DashXLog.d(tag, e.message)
|
|
104
|
+
promise.reject("EUNSPECIFIED", "Error parsing include: ${e.message}")
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
val exclude = try {
|
|
108
|
+
convertReadableArrayToKJsonList(options?.getArray("exclude"))
|
|
109
|
+
} catch (e: Exception) {
|
|
110
|
+
DashXLog.d(tag, e.message)
|
|
111
|
+
promise.reject("EUNSPECIFIED", "Error parsing exclude: ${e.message}")
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
81
115
|
DashX.fetchRecord(
|
|
82
|
-
urn,
|
|
83
|
-
|
|
84
|
-
|
|
116
|
+
urn = urn,
|
|
117
|
+
preview = preview,
|
|
118
|
+
language = language,
|
|
119
|
+
fields = fields,
|
|
120
|
+
include = include,
|
|
121
|
+
exclude = exclude,
|
|
85
122
|
onError = {
|
|
86
123
|
promise.reject("EUNSPECIFIED", it.message)
|
|
87
124
|
},
|
|
@@ -92,30 +129,62 @@ class DashXReactNativeModule(private val reactContext: ReactApplicationContext)
|
|
|
92
129
|
}
|
|
93
130
|
|
|
94
131
|
@ReactMethod
|
|
95
|
-
fun
|
|
132
|
+
fun searchRecords(resource: String, options: ReadableMap?, promise: Promise) {
|
|
96
133
|
val jsonFilter = try {
|
|
97
|
-
convertMapToJson(options?.getMap("filter"))
|
|
134
|
+
convertMapToJson(options?.getMap("filter"))?.let { convertJsonToKJson(it) }
|
|
98
135
|
} catch (e: Exception) {
|
|
99
136
|
DashXLog.d(tag, e.message)
|
|
100
|
-
|
|
137
|
+
promise.reject("EUNSPECIFIED", "Error parsing filter: ${e.message}")
|
|
138
|
+
return
|
|
101
139
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
140
|
+
val order = try {
|
|
141
|
+
convertReadableArrayToKJsonList(options?.getArray("order"))
|
|
142
|
+
} catch (e: Exception) {
|
|
143
|
+
DashXLog.d(tag, e.message)
|
|
144
|
+
promise.reject("EUNSPECIFIED", "Error parsing order: ${e.message}")
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
val limit = options?.getIntIfPresent("limit")
|
|
148
|
+
val preview = options?.getBooleanIfPresent("preview")
|
|
149
|
+
val language = options?.getStringIfPresent("language")
|
|
150
|
+
val fields = try {
|
|
151
|
+
convertReadableArrayToKJsonList(options?.getArray("fields"))
|
|
152
|
+
} catch (e: Exception) {
|
|
153
|
+
DashXLog.d(tag, e.message)
|
|
154
|
+
promise.reject("EUNSPECIFIED", "Error parsing fields: ${e.message}")
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
val include = try {
|
|
158
|
+
convertReadableArrayToKJsonList(options?.getArray("include"))
|
|
159
|
+
} catch (e: Exception) {
|
|
160
|
+
DashXLog.d(tag, e.message)
|
|
161
|
+
promise.reject("EUNSPECIFIED", "Error parsing include: ${e.message}")
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
val exclude = try {
|
|
165
|
+
convertReadableArrayToKJsonList(options?.getArray("exclude"))
|
|
105
166
|
} catch (e: Exception) {
|
|
106
167
|
DashXLog.d(tag, e.message)
|
|
107
|
-
|
|
168
|
+
promise.reject("EUNSPECIFIED", "Error parsing exclude: ${e.message}")
|
|
169
|
+
return
|
|
108
170
|
}
|
|
109
171
|
|
|
110
172
|
DashX.searchRecords(
|
|
111
|
-
|
|
112
|
-
|
|
173
|
+
resource = resource,
|
|
174
|
+
filter = jsonFilter,
|
|
175
|
+
order = order,
|
|
176
|
+
limit = limit,
|
|
177
|
+
preview = preview,
|
|
178
|
+
language = language,
|
|
179
|
+
fields = fields,
|
|
180
|
+
include = include,
|
|
181
|
+
exclude = exclude,
|
|
113
182
|
onError = {
|
|
114
183
|
promise.reject("EUNSPECIFIED", it.message)
|
|
115
184
|
},
|
|
116
|
-
onSuccess = {
|
|
185
|
+
onSuccess = { records ->
|
|
117
186
|
val readableArray = Arguments.createArray()
|
|
118
|
-
|
|
187
|
+
records.forEach {
|
|
119
188
|
readableArray.pushMap(convertJsonToMap(convertKJsonToJson(it)))
|
|
120
189
|
}
|
|
121
190
|
promise.resolve(readableArray)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package com.dashx.rn.sdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Holds a reference to the React context so that [DashXReactNativeFirebaseMessagingService]
|
|
7
|
+
* can emit "messageReceived" events to JS when FCM messages arrive.
|
|
8
|
+
* Set by [DashXReactNativeModule], cleared when the module is invalidated.
|
|
9
|
+
*/
|
|
10
|
+
object MessageReceivedEventHolder {
|
|
11
|
+
@Volatile
|
|
12
|
+
var reactContext: ReactApplicationContext? = null
|
|
13
|
+
internal set
|
|
14
|
+
}
|
|
@@ -26,6 +26,20 @@ fun convertJsonToKJson(jsonObject: JsonObject?): KJsonObject? {
|
|
|
26
26
|
return Json.decodeFromString(jsonString)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Converts a ReadableArray of maps to a list of kotlinx JsonObjects for DashX.searchRecords options (order, fields, include, exclude).
|
|
31
|
+
*/
|
|
32
|
+
@Throws(JSONException::class)
|
|
33
|
+
fun convertReadableArrayToKJsonList(readableArray: ReadableArray?): List<KJsonObject>? {
|
|
34
|
+
if (readableArray == null || readableArray.size() == 0) return null
|
|
35
|
+
return (0 until readableArray.size()).mapNotNull { i ->
|
|
36
|
+
when (readableArray.getType(i)) {
|
|
37
|
+
ReadableType.Map -> readableArray.getMap(i)?.let { convertMapToJson(it)?.let { gson -> convertJsonToKJson(gson) } }
|
|
38
|
+
else -> null
|
|
39
|
+
}
|
|
40
|
+
}.ifEmpty { null }
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
@Throws(JSONException::class)
|
|
30
44
|
fun convertMapToJson(readableMap: ReadableMap?): JsonObject? {
|
|
31
45
|
val iterator = readableMap?.keySetIterator() ?: return null
|
package/index.d.ts
CHANGED
|
@@ -16,6 +16,25 @@ export interface IdentifyOptions {
|
|
|
16
16
|
|
|
17
17
|
export type LogLevel = 0 | 1 | 2;
|
|
18
18
|
|
|
19
|
+
export interface FetchRecordOptions {
|
|
20
|
+
preview?: boolean;
|
|
21
|
+
language?: string;
|
|
22
|
+
fields?: Record<string, unknown>[];
|
|
23
|
+
include?: Record<string, unknown>[];
|
|
24
|
+
exclude?: Record<string, unknown>[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SearchRecordsOptions {
|
|
28
|
+
filter?: Record<string, unknown>;
|
|
29
|
+
order?: Record<string, unknown>[];
|
|
30
|
+
limit?: number;
|
|
31
|
+
preview?: boolean;
|
|
32
|
+
language?: string;
|
|
33
|
+
fields?: Record<string, unknown>[];
|
|
34
|
+
include?: Record<string, unknown>[];
|
|
35
|
+
exclude?: Record<string, unknown>[];
|
|
36
|
+
}
|
|
37
|
+
|
|
19
38
|
export interface NotificationMessage {
|
|
20
39
|
[key: string]: unknown;
|
|
21
40
|
}
|
|
@@ -52,6 +71,24 @@ export interface DashXInstance {
|
|
|
52
71
|
*/
|
|
53
72
|
screen(screenName: string, data?: Record<string, unknown>): void;
|
|
54
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Fetch a single record by URN (e.g. "article/123") with optional preview, language, fields, include, exclude.
|
|
76
|
+
* Returns a promise resolving to the record object.
|
|
77
|
+
*/
|
|
78
|
+
fetchRecord(
|
|
79
|
+
urn: string,
|
|
80
|
+
options?: FetchRecordOptions
|
|
81
|
+
): Promise<Record<string, unknown>>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Search records by resource with optional filter, order, limit, preview, language, fields, include, exclude.
|
|
85
|
+
* Returns a promise resolving to an array of record objects.
|
|
86
|
+
*/
|
|
87
|
+
searchRecords(
|
|
88
|
+
resource: string,
|
|
89
|
+
options?: SearchRecordsOptions
|
|
90
|
+
): Promise<Record<string, unknown>[]>;
|
|
91
|
+
|
|
55
92
|
/**
|
|
56
93
|
* Subscribe the current device to push notifications.
|
|
57
94
|
*/
|
package/index.js
CHANGED
|
@@ -80,6 +80,26 @@ const DashX = {
|
|
|
80
80
|
return getNativeDashX().screen(screenName, data || null);
|
|
81
81
|
},
|
|
82
82
|
|
|
83
|
+
fetchRecord(urn, options = {}) {
|
|
84
|
+
if (!urn || typeof urn !== 'string') {
|
|
85
|
+
throw new Error('DashX.fetchRecord: urn is required and must be a string (e.g. "article/123")');
|
|
86
|
+
}
|
|
87
|
+
if (options !== null && typeof options !== 'object') {
|
|
88
|
+
throw new Error('DashX.fetchRecord: options must be an object');
|
|
89
|
+
}
|
|
90
|
+
return getNativeDashX().fetchRecord(urn, options || null);
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
searchRecords(resource, options = {}) {
|
|
94
|
+
if (!resource || typeof resource !== 'string') {
|
|
95
|
+
throw new Error('DashX.searchRecords: resource is required and must be a string');
|
|
96
|
+
}
|
|
97
|
+
if (options !== null && typeof options !== 'object') {
|
|
98
|
+
throw new Error('DashX.searchRecords: options must be an object');
|
|
99
|
+
}
|
|
100
|
+
return getNativeDashX().searchRecords(resource, options || null);
|
|
101
|
+
},
|
|
102
|
+
|
|
83
103
|
fetchStoredPreferences() {
|
|
84
104
|
return getNativeDashX().fetchStoredPreferences();
|
|
85
105
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class DashXEventEmitter {
|
|
2
2
|
static let instance = DashXEventEmitter()
|
|
3
|
-
private static var eventEmitter: DashXReactNative
|
|
3
|
+
private static var eventEmitter: DashXReactNative?
|
|
4
4
|
|
|
5
5
|
private init() {}
|
|
6
6
|
|
|
@@ -9,6 +9,7 @@ class DashXEventEmitter {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
func dispatch(name: String, body: Any?) {
|
|
12
|
-
DashXEventEmitter.eventEmitter
|
|
12
|
+
guard let emitter = DashXEventEmitter.eventEmitter else { return }
|
|
13
|
+
emitter.sendEvent(withName: name, body: body)
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -70,6 +70,8 @@ open class DashXRCTAppDelegate: RCTAppDelegate, MessagingDelegate, UNUserNotific
|
|
|
70
70
|
|
|
71
71
|
DashX.trackNotification(message: message, event: .delivered)
|
|
72
72
|
|
|
73
|
+
DashXEventEmitter.instance.dispatch(name: "messageReceived", body: bridgeSafePayload(from: message))
|
|
74
|
+
|
|
73
75
|
let presentationOptions = notificationDeliveredInForeground(message: message)
|
|
74
76
|
|
|
75
77
|
completionHandler(presentationOptions)
|
|
@@ -81,6 +83,8 @@ open class DashXRCTAppDelegate: RCTAppDelegate, MessagingDelegate, UNUserNotific
|
|
|
81
83
|
// Pass notification reciept information to Firebase
|
|
82
84
|
Messaging.messaging().appDidReceiveMessage(message)
|
|
83
85
|
|
|
86
|
+
DashXEventEmitter.instance.dispatch(name: "messageReceived", body: bridgeSafePayload(from: message))
|
|
87
|
+
|
|
84
88
|
if response.actionIdentifier == UNNotificationDismissActionIdentifier {
|
|
85
89
|
DashX.trackNotification(message: message, event: .dismissed)
|
|
86
90
|
} else {
|
|
@@ -100,6 +104,8 @@ open class DashXRCTAppDelegate: RCTAppDelegate, MessagingDelegate, UNUserNotific
|
|
|
100
104
|
// Pass notification reciept information to Firebase
|
|
101
105
|
Messaging.messaging().appDidReceiveMessage(userInfo)
|
|
102
106
|
|
|
107
|
+
DashXEventEmitter.instance.dispatch(name: "messageReceived", body: bridgeSafePayload(from: userInfo))
|
|
108
|
+
|
|
103
109
|
guard let dashxData = userInfo.dashxNotificationData() else {
|
|
104
110
|
DashXLog.d(tag: #function, "Unable to parse DashX notification data")
|
|
105
111
|
completionHandler(.failed)
|
|
@@ -154,6 +160,38 @@ open class DashXRCTAppDelegate: RCTAppDelegate, MessagingDelegate, UNUserNotific
|
|
|
154
160
|
open func notificationClicked(message: [AnyHashable: Any], actionIdentifier: String) {}
|
|
155
161
|
|
|
156
162
|
open func handleLink(url: URL) {}
|
|
163
|
+
|
|
164
|
+
/// Converts notification userInfo to a dictionary safe for the React Native bridge (string keys, JSON-serializable values).
|
|
165
|
+
private func bridgeSafePayload(from userInfo: [AnyHashable: Any]) -> [String: Any] {
|
|
166
|
+
userInfo.reduce(into: [String: Any]()) { result, pair in
|
|
167
|
+
let key = String(describing: pair.key)
|
|
168
|
+
let value = pair.value
|
|
169
|
+
if let str = value as? String {
|
|
170
|
+
result[key] = str
|
|
171
|
+
} else if let num = value as? NSNumber {
|
|
172
|
+
result[key] = num
|
|
173
|
+
} else if let dict = value as? [AnyHashable: Any] {
|
|
174
|
+
result[key] = bridgeSafePayload(from: dict)
|
|
175
|
+
} else if let arr = value as? [Any] {
|
|
176
|
+
result[key] = arr.map { item -> Any in
|
|
177
|
+
if let str = item as? String { return str }
|
|
178
|
+
if let num = item as? NSNumber { return num }
|
|
179
|
+
if let d = item as? [AnyHashable: Any] { return bridgeSafePayload(from: d) }
|
|
180
|
+
if let a = item as? [Any] {
|
|
181
|
+
return a.map { sub in
|
|
182
|
+
if let s = sub as? String { return s }
|
|
183
|
+
if let n = sub as? NSNumber { return n }
|
|
184
|
+
if let sd = sub as? [AnyHashable: Any] { return bridgeSafePayload(from: sd) }
|
|
185
|
+
return "\(sub)"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return "\(item)"
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
result[key] = "\(value)"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
157
195
|
}
|
|
158
196
|
|
|
159
197
|
extension DashXRCTAppDelegate {
|
package/ios/DashXReactNative.mm
CHANGED
|
@@ -13,6 +13,10 @@ RCT_EXTERN_METHOD(track:(NSString *)event data:(NSDictionary * _Nullable)data);
|
|
|
13
13
|
|
|
14
14
|
RCT_EXTERN_METHOD(screen:(NSString *)screenName data:(NSDictionary * _Nullable)data);
|
|
15
15
|
|
|
16
|
+
RCT_EXTERN_METHOD(fetchRecord:(NSString *)urn options:(NSDictionary * _Nullable)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject);
|
|
17
|
+
|
|
18
|
+
RCT_EXTERN_METHOD(searchRecords:(NSString *)resource options:(NSDictionary * _Nullable)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject);
|
|
19
|
+
|
|
16
20
|
RCT_EXTERN_METHOD(fetchStoredPreferences:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject);
|
|
17
21
|
|
|
18
22
|
RCT_EXTERN_METHOD(saveStoredPreferences:(NSDictionary *)preferenceData resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject);
|
|
@@ -20,9 +20,11 @@ class DashXReactNative: RCTEventEmitter {
|
|
|
20
20
|
|
|
21
21
|
@objc(configure:)
|
|
22
22
|
func configure(_ options: NSDictionary) {
|
|
23
|
-
let publicKey = options["publicKey"] as
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
guard let publicKey = options["publicKey"] as? String, !publicKey.isEmpty else {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
let baseURI = options["baseURI"] as? String
|
|
27
|
+
let targetEnvironment = options["targetEnvironment"] as? String
|
|
26
28
|
|
|
27
29
|
DashX.configure(
|
|
28
30
|
withPublicKey: publicKey,
|
|
@@ -56,6 +58,16 @@ class DashXReactNative: RCTEventEmitter {
|
|
|
56
58
|
DashX.screen(screenName, withData: data)
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
@objc(fetchRecord:options:resolver:rejecter:)
|
|
62
|
+
func fetchRecord(_ urn: String, options: NSDictionary?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
63
|
+
reject("EUNIMPLEMENTED", "fetchRecord is not yet implemented on iOS", nil)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@objc(searchRecords:options:resolver:rejecter:)
|
|
67
|
+
func searchRecords(_ resource: String, options: NSDictionary?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
68
|
+
reject("EUNIMPLEMENTED", "searchRecords is not yet implemented on iOS", nil)
|
|
69
|
+
}
|
|
70
|
+
|
|
59
71
|
@objc(fetchStoredPreferences:rejecter:)
|
|
60
72
|
func fetchStoredPreferences(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
61
73
|
DashX.fetchStoredPreferences(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashx/react-native",
|
|
3
3
|
"title": "DashX React Native",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "DashX SDK for React Native",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"registry": "https://registry.npmjs.org/"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"react": "
|
|
51
|
-
"react-native": "
|
|
50
|
+
"react": ">=17.0.0",
|
|
51
|
+
"react-native": ">=0.71.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@commitlint/config-conventional": "^17.0.2",
|