zixflow-reactnative 1.1.2 → 1.1.4
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 +2224 -322
- package/android/build.gradle +18 -1
- package/android/consumer-rules.pro +3 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/zixflow/reactnative/sdk/NativeZixflowModule.kt +69 -24
- package/android/src/main/java/com/zixflow/reactnative/sdk/ZixflowReactNativePackage.kt +25 -1
- package/android/src/main/java/com/zixflow/reactnative/sdk/constant/Keys.kt +19 -3
- package/android/src/main/java/com/zixflow/reactnative/sdk/geofence/NativeGeofenceModule.kt +65 -0
- package/android/src/main/java/com/zixflow/reactnative/sdk/liveactivities/NativeLiveActivitiesModule.kt +310 -0
- package/android/src/main/java/com/zixflow/reactnative/sdk/logging/NativeZixflowLoggingModule.kt +2 -2
- package/android/src/main/java/com/zixflow/reactnative/sdk/messaginginapp/NativeMessagingInAppModule.kt +149 -10
- package/android/src/main/java/com/zixflow/reactnative/sdk/messaginginapp/ReactInboxEventListener.kt +99 -0
- package/android/src/main/java/com/zixflow/reactnative/sdk/messaginginbox/NotificationInboxBellViewManager.kt +38 -0
- package/android/src/main/java/com/zixflow/reactnative/sdk/messaginginbox/NotificationInboxViewManager.kt +30 -0
- package/android/src/main/java/com/zixflow/reactnative/sdk/messaginginbox/ReactComposeHostView.kt +96 -0
- package/android/src/main/java/com/zixflow/reactnative/sdk/messaginginbox/ReactNotificationInboxBellView.kt +48 -0
- package/android/src/main/java/com/zixflow/reactnative/sdk/messaginginbox/ReactNotificationInboxView.kt +17 -0
- package/android/src/main/java/com/zixflow/reactnative/sdk/messagingpush/NativeMessagingPushModule.kt +11 -1
- package/android/src/main/res/values/zixflow_config.xml +1 -1
- package/android/zixflow-core.gradle +17 -7
- package/docs/cocoapods-deployment-target-normalization.md +139 -0
- package/ios/cocoapods_deployment_target.rb +432 -0
- package/ios/wrappers/NativeZixflow.mm +37 -0
- package/ios/wrappers/NativeZixflow.swift +135 -1
- package/ios/wrappers/ZixflowReactNativeDeepLinkRequestStore.swift +123 -0
- package/ios/wrappers/ZixflowReactNativeDeepLinkRouter.swift +312 -0
- package/ios/wrappers/geofence/NativeGeofence.mm +46 -0
- package/ios/wrappers/geofence/NativeGeofence.swift +27 -0
- package/ios/wrappers/inapp/NativeMessagingInApp.mm +22 -0
- package/ios/wrappers/inapp/NativeMessagingInApp.swift +90 -0
- package/ios/wrappers/inbox/InboxHostContainment.swift +40 -0
- package/ios/wrappers/inbox/RCTNotificationInboxBellNative.h +12 -0
- package/ios/wrappers/inbox/RCTNotificationInboxBellNative.mm +98 -0
- package/ios/wrappers/inbox/RCTNotificationInboxViewNative.h +12 -0
- package/ios/wrappers/inbox/RCTNotificationInboxViewNative.mm +78 -0
- package/ios/wrappers/inbox/ReactInboxEventListener.swift +76 -0
- package/ios/wrappers/inbox/ReactNotificationInboxBellView.h +22 -0
- package/ios/wrappers/inbox/ReactNotificationInboxBellView.swift +109 -0
- package/ios/wrappers/inbox/ReactNotificationInboxView.h +22 -0
- package/ios/wrappers/inbox/ReactNotificationInboxView.swift +69 -0
- package/ios/wrappers/liveactivities/NativeLiveActivities.mm +83 -0
- package/ios/wrappers/liveactivities/NativeLiveActivities.swift +390 -0
- package/ios/wrappers/location/NativeLocation.swift +7 -5
- package/ios/wrappers/utils/ZixflowConfigUtils.swift +5 -9
- package/ios/wrappers/utils/ZixflowConstants.swift +4 -0
- package/ios/wrappers/zixflow_reactnative.h +6 -0
- package/lib/commonjs/components/NotificationInboxBellView.js +49 -0
- package/lib/commonjs/components/NotificationInboxBellView.js.map +1 -0
- package/lib/commonjs/components/NotificationInboxView.js +36 -0
- package/lib/commonjs/components/NotificationInboxView.js.map +1 -0
- package/lib/commonjs/components/index.js +14 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/index.js +81 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/notification-inbox.js +1 -0
- package/lib/commonjs/notification-inbox.js.map +1 -1
- package/lib/commonjs/specs/components/NotificationInboxBellNativeComponent.ts +24 -0
- package/lib/commonjs/specs/components/NotificationInboxViewNativeComponent.ts +22 -0
- package/lib/commonjs/specs/modules/NativeZixflow.js.map +1 -1
- package/lib/commonjs/specs/modules/NativeZixflowGeofence.js +15 -0
- package/lib/commonjs/specs/modules/NativeZixflowGeofence.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeZixflowLiveActivities.js +23 -0
- package/lib/commonjs/specs/modules/NativeZixflowLiveActivities.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeZixflowMessagingInApp.js +3 -1
- package/lib/commonjs/specs/modules/NativeZixflowMessagingInApp.js.map +1 -1
- package/lib/commonjs/specs/modules/NativeZixflowMessagingPush.js +3 -1
- package/lib/commonjs/specs/modules/NativeZixflowMessagingPush.js.map +1 -1
- package/lib/commonjs/types/data-pipelines.js +15 -15
- package/lib/commonjs/types/data-pipelines.js.map +1 -1
- package/lib/commonjs/types/in-app.js +24 -1
- package/lib/commonjs/types/in-app.js.map +1 -1
- package/lib/commonjs/types/inbox.js +79 -0
- package/lib/commonjs/types/inbox.js.map +1 -0
- package/lib/commonjs/types/index.js +22 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/live-activities.js +85 -0
- package/lib/commonjs/types/live-activities.js.map +1 -0
- package/lib/commonjs/utils/param-validation.js +77 -2
- package/lib/commonjs/utils/param-validation.js.map +1 -1
- package/lib/commonjs/zixflow-cdp.js +101 -11
- package/lib/commonjs/zixflow-cdp.js.map +1 -1
- package/lib/commonjs/zixflow-geofence.js +55 -0
- package/lib/commonjs/zixflow-geofence.js.map +1 -0
- package/lib/commonjs/zixflow-inapp.js +120 -0
- package/lib/commonjs/zixflow-inapp.js.map +1 -1
- package/lib/commonjs/zixflow-liveactivities.js +85 -0
- package/lib/commonjs/zixflow-liveactivities.js.map +1 -0
- package/lib/commonjs/zixflow.js.map +1 -1
- package/lib/module/components/NotificationInboxBellView.js +44 -0
- package/lib/module/components/NotificationInboxBellView.js.map +1 -0
- package/lib/module/components/NotificationInboxView.js +31 -0
- package/lib/module/components/NotificationInboxView.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/index.js +8 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/notification-inbox.js +1 -1
- package/lib/module/notification-inbox.js.map +1 -1
- package/lib/module/specs/components/NotificationInboxBellNativeComponent.ts +24 -0
- package/lib/module/specs/components/NotificationInboxViewNativeComponent.ts +22 -0
- package/lib/module/specs/modules/NativeZixflow.js.map +1 -1
- package/lib/module/specs/modules/NativeZixflowGeofence.js +13 -0
- package/lib/module/specs/modules/NativeZixflowGeofence.js.map +1 -0
- package/lib/module/specs/modules/NativeZixflowLiveActivities.js +21 -0
- package/lib/module/specs/modules/NativeZixflowLiveActivities.js.map +1 -0
- package/lib/module/specs/modules/NativeZixflowMessagingInApp.js +3 -1
- package/lib/module/specs/modules/NativeZixflowMessagingInApp.js.map +1 -1
- package/lib/module/specs/modules/NativeZixflowMessagingPush.js +3 -1
- package/lib/module/specs/modules/NativeZixflowMessagingPush.js.map +1 -1
- package/lib/module/types/data-pipelines.js +15 -15
- package/lib/module/types/data-pipelines.js.map +1 -1
- package/lib/module/types/in-app.js +24 -0
- package/lib/module/types/in-app.js.map +1 -1
- package/lib/module/types/inbox.js +75 -0
- package/lib/module/types/inbox.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/live-activities.js +88 -0
- package/lib/module/types/live-activities.js.map +1 -0
- package/lib/module/utils/param-validation.js +77 -2
- package/lib/module/utils/param-validation.js.map +1 -1
- package/lib/module/zixflow-cdp.js +101 -11
- package/lib/module/zixflow-cdp.js.map +1 -1
- package/lib/module/zixflow-geofence.js +50 -0
- package/lib/module/zixflow-geofence.js.map +1 -0
- package/lib/module/zixflow-inapp.js +99 -1
- package/lib/module/zixflow-inapp.js.map +1 -1
- package/lib/module/zixflow-liveactivities.js +80 -0
- package/lib/module/zixflow-liveactivities.js.map +1 -0
- package/lib/module/zixflow.js +0 -6
- package/lib/module/zixflow.js.map +1 -1
- package/lib/typescript/commonjs/components/NotificationInboxBellView.d.ts +39 -0
- package/lib/typescript/commonjs/components/NotificationInboxBellView.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/NotificationInboxView.d.ts +25 -0
- package/lib/typescript/commonjs/components/NotificationInboxView.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +8 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/notification-inbox.d.ts +5 -0
- package/lib/typescript/commonjs/notification-inbox.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/components/NotificationInboxBellNativeComponent.d.ts +13 -0
- package/lib/typescript/commonjs/specs/components/NotificationInboxBellNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/components/NotificationInboxViewNativeComponent.d.ts +12 -0
- package/lib/typescript/commonjs/specs/components/NotificationInboxViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/modules/NativeZixflow.d.ts +6 -1
- package/lib/typescript/commonjs/specs/modules/NativeZixflow.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/modules/NativeZixflowGeofence.d.ts +13 -0
- package/lib/typescript/commonjs/specs/modules/NativeZixflowGeofence.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/modules/NativeZixflowLiveActivities.d.ts +31 -0
- package/lib/typescript/commonjs/specs/modules/NativeZixflowLiveActivities.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/modules/NativeZixflowMessagingInApp.d.ts +5 -1
- package/lib/typescript/commonjs/specs/modules/NativeZixflowMessagingInApp.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/modules/NativeZixflowMessagingPush.d.ts +1 -1
- package/lib/typescript/commonjs/specs/modules/NativeZixflowMessagingPush.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/data-pipelines.d.ts +54 -18
- package/lib/typescript/commonjs/types/data-pipelines.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/in-app.d.ts +22 -0
- package/lib/typescript/commonjs/types/in-app.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/inbox.d.ts +97 -0
- package/lib/typescript/commonjs/types/inbox.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/index.d.ts +2 -0
- package/lib/typescript/commonjs/types/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/live-activities.d.ts +161 -0
- package/lib/typescript/commonjs/types/live-activities.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/param-validation.d.ts +7 -0
- package/lib/typescript/commonjs/utils/param-validation.d.ts.map +1 -1
- package/lib/typescript/commonjs/zixflow-cdp.d.ts +38 -0
- package/lib/typescript/commonjs/zixflow-cdp.d.ts.map +1 -1
- package/lib/typescript/commonjs/zixflow-geofence.d.ts +36 -0
- package/lib/typescript/commonjs/zixflow-geofence.d.ts.map +1 -0
- package/lib/typescript/commonjs/zixflow-inapp.d.ts +36 -2
- package/lib/typescript/commonjs/zixflow-inapp.d.ts.map +1 -1
- package/lib/typescript/commonjs/zixflow-liveactivities.d.ts +66 -0
- package/lib/typescript/commonjs/zixflow-liveactivities.d.ts.map +1 -0
- package/lib/typescript/commonjs/zixflow.d.ts +0 -5
- package/lib/typescript/commonjs/zixflow.d.ts.map +1 -1
- package/lib/typescript/module/components/NotificationInboxBellView.d.ts +39 -0
- package/lib/typescript/module/components/NotificationInboxBellView.d.ts.map +1 -0
- package/lib/typescript/module/components/NotificationInboxView.d.ts +25 -0
- package/lib/typescript/module/components/NotificationInboxView.d.ts.map +1 -0
- package/lib/typescript/module/components/index.d.ts +4 -0
- package/lib/typescript/module/components/index.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +8 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/notification-inbox.d.ts +5 -0
- package/lib/typescript/module/notification-inbox.d.ts.map +1 -1
- package/lib/typescript/module/specs/components/NotificationInboxBellNativeComponent.d.ts +13 -0
- package/lib/typescript/module/specs/components/NotificationInboxBellNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/specs/components/NotificationInboxViewNativeComponent.d.ts +12 -0
- package/lib/typescript/module/specs/components/NotificationInboxViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/specs/modules/NativeZixflow.d.ts +6 -1
- package/lib/typescript/module/specs/modules/NativeZixflow.d.ts.map +1 -1
- package/lib/typescript/module/specs/modules/NativeZixflowGeofence.d.ts +13 -0
- package/lib/typescript/module/specs/modules/NativeZixflowGeofence.d.ts.map +1 -0
- package/lib/typescript/module/specs/modules/NativeZixflowLiveActivities.d.ts +31 -0
- package/lib/typescript/module/specs/modules/NativeZixflowLiveActivities.d.ts.map +1 -0
- package/lib/typescript/module/specs/modules/NativeZixflowMessagingInApp.d.ts +5 -1
- package/lib/typescript/module/specs/modules/NativeZixflowMessagingInApp.d.ts.map +1 -1
- package/lib/typescript/module/specs/modules/NativeZixflowMessagingPush.d.ts +1 -1
- package/lib/typescript/module/specs/modules/NativeZixflowMessagingPush.d.ts.map +1 -1
- package/lib/typescript/module/types/data-pipelines.d.ts +54 -18
- package/lib/typescript/module/types/data-pipelines.d.ts.map +1 -1
- package/lib/typescript/module/types/in-app.d.ts +22 -0
- package/lib/typescript/module/types/in-app.d.ts.map +1 -1
- package/lib/typescript/module/types/inbox.d.ts +97 -0
- package/lib/typescript/module/types/inbox.d.ts.map +1 -0
- package/lib/typescript/module/types/index.d.ts +2 -0
- package/lib/typescript/module/types/index.d.ts.map +1 -1
- package/lib/typescript/module/types/live-activities.d.ts +161 -0
- package/lib/typescript/module/types/live-activities.d.ts.map +1 -0
- package/lib/typescript/module/utils/param-validation.d.ts +7 -0
- package/lib/typescript/module/utils/param-validation.d.ts.map +1 -1
- package/lib/typescript/module/zixflow-cdp.d.ts +38 -0
- package/lib/typescript/module/zixflow-cdp.d.ts.map +1 -1
- package/lib/typescript/module/zixflow-geofence.d.ts +36 -0
- package/lib/typescript/module/zixflow-geofence.d.ts.map +1 -0
- package/lib/typescript/module/zixflow-inapp.d.ts +36 -2
- package/lib/typescript/module/zixflow-inapp.d.ts.map +1 -1
- package/lib/typescript/module/zixflow-liveactivities.d.ts +66 -0
- package/lib/typescript/module/zixflow-liveactivities.d.ts.map +1 -0
- package/lib/typescript/module/zixflow.d.ts +0 -5
- package/lib/typescript/module/zixflow.d.ts.map +1 -1
- package/package.json +14 -5
- package/src/components/NotificationInboxBellView.tsx +55 -0
- package/src/components/NotificationInboxView.tsx +30 -0
- package/src/components/index.ts +6 -0
- package/src/index.ts +8 -3
- package/src/notification-inbox.ts +1 -1
- package/src/specs/components/NotificationInboxBellNativeComponent.ts +24 -0
- package/src/specs/components/NotificationInboxViewNativeComponent.ts +22 -0
- package/src/specs/modules/NativeZixflow.ts +9 -1
- package/src/specs/modules/NativeZixflowGeofence.ts +14 -0
- package/src/specs/modules/NativeZixflowLiveActivities.ts +39 -0
- package/src/specs/modules/NativeZixflowMessagingInApp.ts +12 -1
- package/src/specs/modules/NativeZixflowMessagingPush.ts +3 -1
- package/src/types/data-pipelines.ts +55 -19
- package/src/types/in-app.ts +23 -0
- package/src/types/inbox.ts +110 -0
- package/src/types/index.ts +2 -0
- package/src/types/live-activities.ts +170 -0
- package/src/utils/param-validation.ts +104 -1
- package/src/zixflow-cdp.ts +119 -13
- package/src/zixflow-geofence.ts +56 -0
- package/src/zixflow-inapp.ts +125 -2
- package/src/zixflow-liveactivities.ts +86 -0
- package/src/zixflow.ts +0 -6
- package/zixflow-reactnative-richpush.podspec +6 -3
- package/zixflow-reactnative.podspec +28 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Argument validation utilities for SDK internal use
|
|
2
2
|
// Ensures input safety and throws clear errors when validation fails
|
|
3
3
|
|
|
4
|
+
import { ZixflowColorScheme } from '../types';
|
|
4
5
|
import type { ZixflowConfig, CustomAttributes } from '../types';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -32,6 +33,16 @@ function failIf(condition: boolean, message: () => string): void {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Logs a warning if the condition is true.
|
|
38
|
+
* Use this for misconfigurations that degrade behavior but must not fail initialization.
|
|
39
|
+
*/
|
|
40
|
+
function warnIf(condition: boolean, message: () => string): void {
|
|
41
|
+
if (__DEV__ && condition) {
|
|
42
|
+
console.warn(`[Zixflow] ${message()}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
/**
|
|
36
47
|
* Validates that a value is defined (not undefined or null).
|
|
37
48
|
* Useful for checking required fields.
|
|
@@ -137,6 +148,92 @@ function validateAttributes(
|
|
|
137
148
|
return attributes as CustomAttributes;
|
|
138
149
|
}
|
|
139
150
|
|
|
151
|
+
/**
|
|
152
|
+
* The placeholder the SDK substitutes with the unread count when rendering
|
|
153
|
+
* `bellWithUnreadCount`.
|
|
154
|
+
*/
|
|
155
|
+
const COUNT_PLACEHOLDER = '{count}';
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Warns when `bellWithUnreadCount` is missing its `{count}` placeholder.
|
|
159
|
+
*
|
|
160
|
+
* The label is a template, not a finished string. A misspelled placeholder (`{COUNT}`,
|
|
161
|
+
* `{{count}}`, `%d`) matches nothing, so the template is announced verbatim — braces and all —
|
|
162
|
+
* and the count is never spoken. The check lives here rather than in either native layer
|
|
163
|
+
* because neither can report it usefully: Android logs at `debug`, which the default `ERROR`
|
|
164
|
+
* level discards, and iOS does not check at all. Warning from JavaScript reaches the
|
|
165
|
+
* developer's console on both platforms, whatever the SDK log level.
|
|
166
|
+
*/
|
|
167
|
+
function validateInboxAccessibilityLabels(value: unknown): void {
|
|
168
|
+
if (isUndefined(value) || typeof value !== 'object') {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const template = (value as { bellWithUnreadCount?: unknown })
|
|
173
|
+
.bellWithUnreadCount;
|
|
174
|
+
warnIf(
|
|
175
|
+
typeof template === 'string' && !template.includes(COUNT_PLACEHOLDER),
|
|
176
|
+
() =>
|
|
177
|
+
`"inApp.notificationInboxAccessibilityLabels.bellWithUnreadCount" has no ` +
|
|
178
|
+
`"${COUNT_PLACEHOLDER}" placeholder, so the unread count will not be announced.`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Warns when a value is not one of the `ZixflowColorScheme` values.
|
|
184
|
+
*
|
|
185
|
+
* TypeScript rejects a bad value already, but JavaScript callers reach both entry points
|
|
186
|
+
* untyped, and neither native layer reports the mistake at the default log level. The
|
|
187
|
+
* failure mode is a message rendered in the wrong theme with no error attached, so
|
|
188
|
+
* JavaScript is the only place the developer reliably sees it.
|
|
189
|
+
*
|
|
190
|
+
* `consequence` differs per entry point because the native fallback does: an unrecognized
|
|
191
|
+
* value at initialization resolves to `auto`, while the runtime setter leaves whatever
|
|
192
|
+
* scheme the app already chose in place.
|
|
193
|
+
*/
|
|
194
|
+
function warnIfNotColorScheme(
|
|
195
|
+
value: unknown,
|
|
196
|
+
fieldName: string,
|
|
197
|
+
consequence: string
|
|
198
|
+
): void {
|
|
199
|
+
const allowed: string[] = Object.values(ZixflowColorScheme);
|
|
200
|
+
warnIf(
|
|
201
|
+
!(typeof value === 'string' && allowed.includes(value)),
|
|
202
|
+
() =>
|
|
203
|
+
`"${fieldName}" is not a valid ZixflowColorScheme (expected one of ` +
|
|
204
|
+
`${allowed.join(', ')}), so ${consequence}.`
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Validates `inApp.colorScheme`. An absent value is legitimate here — the native SDKs
|
|
210
|
+
* already default to `auto` — so only a value the host actually set is checked.
|
|
211
|
+
*/
|
|
212
|
+
function validateConfigColorScheme(value: unknown): void {
|
|
213
|
+
if (isUndefined(value)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
warnIfNotColorScheme(
|
|
218
|
+
value,
|
|
219
|
+
'inApp.colorScheme',
|
|
220
|
+
'in-app messages will follow the device appearance'
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Validates the argument to `setColorScheme`. Unlike the config field, an absent value is
|
|
226
|
+
* itself the mistake: the caller asked for a scheme change and named none, and there is no
|
|
227
|
+
* default to fall back to, so null and undefined are reported rather than skipped.
|
|
228
|
+
*/
|
|
229
|
+
function validateColorSchemeArgument(value: unknown): void {
|
|
230
|
+
warnIfNotColorScheme(
|
|
231
|
+
value,
|
|
232
|
+
'colorScheme',
|
|
233
|
+
'the color scheme will be left unchanged'
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
140
237
|
/**
|
|
141
238
|
* Validates that the given value is a valid ZixflowConfig object.
|
|
142
239
|
* Throws if required fields are missing or incorrectly typed.
|
|
@@ -151,10 +248,14 @@ function validateConfig(value: unknown): asserts value is ZixflowConfig {
|
|
|
151
248
|
});
|
|
152
249
|
|
|
153
250
|
const obj = value as ZixflowConfig;
|
|
154
|
-
validateString(obj.
|
|
251
|
+
validateString(obj.apiKey, `${fieldName}.apiKey`, {
|
|
155
252
|
allowEmpty: false,
|
|
156
253
|
usage: usage,
|
|
157
254
|
});
|
|
255
|
+
validateConfigColorScheme(obj.inApp?.colorScheme);
|
|
256
|
+
validateInboxAccessibilityLabels(
|
|
257
|
+
obj.inApp?.notificationInboxAccessibilityLabels
|
|
258
|
+
);
|
|
158
259
|
}
|
|
159
260
|
|
|
160
261
|
// For type safety, we define a ConfigValidator type that asserts the value is a ZixflowConfig
|
|
@@ -166,11 +267,13 @@ export const assert: {
|
|
|
166
267
|
record: typeof validateRecord;
|
|
167
268
|
attributes: typeof validateAttributes;
|
|
168
269
|
config: ConfigValidator;
|
|
270
|
+
colorScheme: typeof validateColorSchemeArgument;
|
|
169
271
|
} = {
|
|
170
272
|
string: validateString,
|
|
171
273
|
record: validateRecord,
|
|
172
274
|
attributes: validateAttributes,
|
|
173
275
|
config: validateConfig,
|
|
276
|
+
colorScheme: validateColorSchemeArgument,
|
|
174
277
|
};
|
|
175
278
|
|
|
176
279
|
export const validate = {
|
package/src/zixflow-cdp.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ZixflowGeofence } from './zixflow-geofence';
|
|
1
2
|
import { ZixflowInAppMessaging } from './zixflow-inapp';
|
|
3
|
+
import { ZixflowLiveActivities } from './zixflow-liveactivities';
|
|
2
4
|
import { ZixflowLocation } from './zixflow-location';
|
|
3
5
|
import { ZixflowPushMessaging } from './zixflow-push';
|
|
4
6
|
import { NativeLoggerListener } from './native-logger-listener';
|
|
@@ -17,10 +19,26 @@ import type { NativeSDKArgs } from './types/internal';
|
|
|
17
19
|
import { callNativeModule, ensureNativeModule } from './utils/native-bridge';
|
|
18
20
|
import { assert, validate } from './utils/param-validation';
|
|
19
21
|
|
|
20
|
-
const packageJson = require('
|
|
22
|
+
const packageJson = require('../package.json');
|
|
21
23
|
|
|
22
24
|
// Track whether Zixflow SDK has been initialized to prevent usage before setup
|
|
23
25
|
let _initialized = false;
|
|
26
|
+
let deepLinkHandlerSubscription: DeepLinkHandlerSubscription | undefined;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Handles a Zixflow deep-link destination delivered from iOS.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export type DeepLinkHandler = (url: string) => boolean | Promise<boolean>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Removes a Zixflow deep-link handler.
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export interface DeepLinkHandlerSubscription {
|
|
39
|
+
/** Stop routing Zixflow deep links through this handler. */
|
|
40
|
+
remove(): void;
|
|
41
|
+
}
|
|
24
42
|
|
|
25
43
|
// Reference to the native Zixflow Data Pipelines module for SDK operations
|
|
26
44
|
const nativeModule = ensureNativeModule(NativeModule);
|
|
@@ -36,18 +54,8 @@ export class Zixflow {
|
|
|
36
54
|
static readonly initialize = async (config: ZixflowConfig) => {
|
|
37
55
|
assert.config(config);
|
|
38
56
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
config.inApp.siteId = config.cdpApiKey;
|
|
42
|
-
console.log('[Zixflow] Auto-derived inApp.siteId from cdpApiKey');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Warn if siteId doesn't match cdpApiKey (Customer.io legacy issue)
|
|
46
|
-
if (config.inApp && config.inApp.siteId && config.inApp.siteId !== config.cdpApiKey) {
|
|
47
|
-
console.warn(
|
|
48
|
-
'[Zixflow] Warning: inApp.siteId should equal cdpApiKey for Zixflow. ' +
|
|
49
|
-
'Using different values may cause in-app messaging to fail.'
|
|
50
|
-
);
|
|
57
|
+
if (config.inApp) {
|
|
58
|
+
(config.inApp as any).siteId = config.apiKey;
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
if (config.logLevel && config.logLevel !== ZixflowLogLevel.None) {
|
|
@@ -68,6 +76,102 @@ export class Zixflow {
|
|
|
68
76
|
});
|
|
69
77
|
};
|
|
70
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Signal that the app's React Native Linking listener is ready to receive Zixflow URLs.
|
|
81
|
+
*
|
|
82
|
+
* This is only needed by UIScene hosts that initialize Zixflow natively, such as Expo
|
|
83
|
+
* config-plugin auto-initialization. Call it after registering the Linking listener.
|
|
84
|
+
*/
|
|
85
|
+
static readonly setDeepLinkRoutingReady = () => {
|
|
86
|
+
return withNativeModule<void>((native) => native.setDeepLinkRoutingReady());
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Register an acknowledged deep-link handler for an iOS UIScene host.
|
|
91
|
+
*
|
|
92
|
+
* This API only handles Zixflow destinations delivered through an iOS UIScene lifecycle.
|
|
93
|
+
* In a native React Native scene host, pair this with
|
|
94
|
+
* `NativeZixflow.configureAcknowledgedSceneDeepLinkRouting()` in the SceneDelegate. Register
|
|
95
|
+
* this before `initialize` when possible. Return `true` after routing a URL. Returning `false`,
|
|
96
|
+
* throwing, or rejecting lets the native SDK try the host AppDelegate, then React Native Linking
|
|
97
|
+
* for a host-owned custom scheme or the system for other URLs. Cold URLs are buffered until this
|
|
98
|
+
* handler is registered, subject to the native timeout. After delivery, the handler has ten
|
|
99
|
+
* seconds to settle. Once that timeout runs the native fallback, a late handler cannot cancel it
|
|
100
|
+
* and may cause a second navigation if it also routes the URL.
|
|
101
|
+
*/
|
|
102
|
+
static readonly setDeepLinkHandler = (
|
|
103
|
+
handler: DeepLinkHandler
|
|
104
|
+
): DeepLinkHandlerSubscription => {
|
|
105
|
+
if (typeof handler !== 'function') {
|
|
106
|
+
throw new Error('[Zixflow] "handler" must be a function.');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Native unregister is tokenless and removes the current native handler. Remove the old
|
|
110
|
+
// subscription first so its cleanup cannot unregister the replacement.
|
|
111
|
+
deepLinkHandlerSubscription?.remove();
|
|
112
|
+
|
|
113
|
+
return withNativeModule<DeepLinkHandlerSubscription>((native) => {
|
|
114
|
+
const nativeSubscription = native.onDeepLinkReceived(async (data) => {
|
|
115
|
+
const event = data as { id?: unknown; url?: unknown };
|
|
116
|
+
if (typeof event.id !== 'string' || typeof event.url !== 'string') {
|
|
117
|
+
NativeLoggerListener.warn(
|
|
118
|
+
'Received an invalid native deep-link event.'
|
|
119
|
+
);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let handled = false;
|
|
124
|
+
try {
|
|
125
|
+
handled = (await handler(event.url)) === true;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
NativeLoggerListener.warn('Deep-link handler failed:', error);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
native.acknowledgeDeepLink(event.id, handled);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
NativeLoggerListener.warn(
|
|
134
|
+
'Failed to acknowledge a deep-link result:',
|
|
135
|
+
error
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
let removed = false;
|
|
141
|
+
const subscription: DeepLinkHandlerSubscription = {
|
|
142
|
+
remove: () => {
|
|
143
|
+
if (removed) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
removed = true;
|
|
147
|
+
try {
|
|
148
|
+
native.unregisterDeepLinkHandler();
|
|
149
|
+
} finally {
|
|
150
|
+
nativeSubscription.remove();
|
|
151
|
+
if (deepLinkHandlerSubscription === subscription) {
|
|
152
|
+
deepLinkHandlerSubscription = undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
native.registerDeepLinkHandler();
|
|
160
|
+
} catch (error) {
|
|
161
|
+
try {
|
|
162
|
+
native.unregisterDeepLinkHandler();
|
|
163
|
+
} catch {
|
|
164
|
+
// Preserve the registration error; the native timeout still owns pending URLs.
|
|
165
|
+
}
|
|
166
|
+
nativeSubscription.remove();
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
deepLinkHandlerSubscription = subscription;
|
|
171
|
+
return subscription;
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
71
175
|
/** Identify a user to start tracking their activity. Requires userId, traits, or both. */
|
|
72
176
|
static readonly identify = async ({
|
|
73
177
|
userId,
|
|
@@ -192,7 +296,9 @@ export class Zixflow {
|
|
|
192
296
|
*/
|
|
193
297
|
static readonly isInitialized = () => _initialized;
|
|
194
298
|
|
|
299
|
+
static readonly geofence = new ZixflowGeofence();
|
|
195
300
|
static readonly inAppMessaging = new ZixflowInAppMessaging();
|
|
301
|
+
static readonly liveActivities = new ZixflowLiveActivities();
|
|
196
302
|
static readonly location = new ZixflowLocation();
|
|
197
303
|
static readonly pushMessaging = new ZixflowPushMessaging();
|
|
198
304
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type TurboModule } from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
default as NativeModule,
|
|
4
|
+
type Spec as CodegenSpec,
|
|
5
|
+
} from './specs/modules/NativeZixflowGeofence';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Ensures all methods defined in codegen spec are implemented by the public module
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
interface NativeGeofenceSpec extends Omit<CodegenSpec, keyof TurboModule> {}
|
|
13
|
+
|
|
14
|
+
// Geofence is an optional module — NativeModule may be null when geofence is not enabled.
|
|
15
|
+
// Methods silently no-op when the native module is unavailable, with a one-time dev warning.
|
|
16
|
+
let hasWarnedNotEnabled = false;
|
|
17
|
+
const withNativeModule = (fn: (native: CodegenSpec) => void): void => {
|
|
18
|
+
if (NativeModule) {
|
|
19
|
+
fn(NativeModule);
|
|
20
|
+
} else if (__DEV__ && !hasWarnedNotEnabled) {
|
|
21
|
+
hasWarnedNotEnabled = true;
|
|
22
|
+
console.warn(
|
|
23
|
+
'Zixflow: Geofence module is not enabled. ' +
|
|
24
|
+
'To use geofence features, set zixflow_geofence_enabled=true in ' +
|
|
25
|
+
'gradle.properties (Android) or add the geofence subspec to your Podfile (iOS).'
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Public entry point for the optional Geofence module.
|
|
32
|
+
*
|
|
33
|
+
* Geofence runs automatically once enabled. Apps opt in by passing a `geofence` config to
|
|
34
|
+
* `initialize` and enabling the module at build time: set `zixflow_geofence_enabled=true`
|
|
35
|
+
* in `gradle.properties` (Android) or add the `geofence` subspec to your Podfile (iOS).
|
|
36
|
+
* Enabling geofence also enables the Location module, which geofence depends on.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export class ZixflowGeofence implements NativeGeofenceSpec {
|
|
41
|
+
/**
|
|
42
|
+
* Requests a one-shot location fix and refreshes the nearby geofence set from it,
|
|
43
|
+
* without sending a location analytics event (unlike
|
|
44
|
+
* `Zixflow.location.requestLocationUpdate()`) and without caching the fix.
|
|
45
|
+
*
|
|
46
|
+
* Call this after the host app has been granted location permission — the SDK never
|
|
47
|
+
* requests permission itself. It is the primary way to drive geofencing when the module
|
|
48
|
+
* is configured with `MANUAL` location mode; with the default `AUTOMATIC` the SDK acquires
|
|
49
|
+
* location on its own and this only forces an immediate refresh.
|
|
50
|
+
*
|
|
51
|
+
* No-ops if the geofence module is not enabled or a user has not been identified.
|
|
52
|
+
*/
|
|
53
|
+
refreshFromCurrentLocation(): void {
|
|
54
|
+
return withNativeModule((native) => native.refreshFromCurrentLocation());
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/zixflow-inapp.ts
CHANGED
|
@@ -3,13 +3,16 @@ import { InlineInAppMessageView } from './components';
|
|
|
3
3
|
import { NativeLoggerListener } from './native-logger-listener';
|
|
4
4
|
import {
|
|
5
5
|
NotificationInbox,
|
|
6
|
+
parseInboxMessage,
|
|
6
7
|
type NotificationInboxSpec,
|
|
7
8
|
} from './notification-inbox';
|
|
8
9
|
import NativeZixflowMessagingInApp, {
|
|
9
10
|
type Spec as CodegenSpec,
|
|
10
11
|
} from './specs/modules/NativeZixflowMessagingInApp';
|
|
11
|
-
import type { InAppMessageEventType } from './types';
|
|
12
|
+
import type { ZixflowColorScheme, InAppMessageEventType } from './types';
|
|
13
|
+
import { InboxEventType, InboxMessageEvent } from './types';
|
|
12
14
|
import { callNativeModule, ensureNativeModule } from './utils/native-bridge';
|
|
15
|
+
import { assert } from './utils/param-validation';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Ensures all methods defined in codegen spec are implemented by the public module
|
|
@@ -18,7 +21,12 @@ import { callNativeModule, ensureNativeModule } from './utils/native-bridge';
|
|
|
18
21
|
*/
|
|
19
22
|
interface NativeInAppSpec extends Omit<
|
|
20
23
|
CodegenSpec,
|
|
21
|
-
keyof TurboModule
|
|
24
|
+
| keyof TurboModule
|
|
25
|
+
| NotificationInboxSpec
|
|
26
|
+
| 'onInAppEventReceived'
|
|
27
|
+
| 'registerInboxEventListener'
|
|
28
|
+
| 'unregisterInboxEventListener'
|
|
29
|
+
| 'onInboxEventReceived'
|
|
22
30
|
> {}
|
|
23
31
|
|
|
24
32
|
// Reference to the native Zixflow Data Pipelines module for SDK operations
|
|
@@ -37,6 +45,13 @@ const withNativeModule = <R>(fn: (native: CodegenSpec) => R): R => {
|
|
|
37
45
|
class ZixflowInAppMessaging implements NativeInAppSpec {
|
|
38
46
|
private _notificationInbox?: NotificationInbox;
|
|
39
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Live inbox subscriptions. The SDK's inbox forwarder is a SINGLE global listener, so it is
|
|
50
|
+
* registered when the first subscription is created and unregistered when the last one goes away —
|
|
51
|
+
* never per subscription, or one `remove()` would tear it out from under the others.
|
|
52
|
+
*/
|
|
53
|
+
private _inboxListenerCount = 0;
|
|
54
|
+
|
|
40
55
|
registerEventsListener(
|
|
41
56
|
listener: (event: InAppMessageEvent) => void
|
|
42
57
|
): EventSubscription {
|
|
@@ -74,6 +89,91 @@ class ZixflowInAppMessaging implements NativeInAppSpec {
|
|
|
74
89
|
});
|
|
75
90
|
}
|
|
76
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Registers a listener for Visual Notification Inbox events (action taken,
|
|
94
|
+
* shown, opened, dismissed).
|
|
95
|
+
*
|
|
96
|
+
* While a listener is registered the host owns action navigation: the native
|
|
97
|
+
* SDK suppresses its default action handling and forwards the event here.
|
|
98
|
+
* Call `.remove()` on the returned subscription to unregister and restore the
|
|
99
|
+
* SDK's default behavior.
|
|
100
|
+
*
|
|
101
|
+
* @param listener - callback invoked with an {@link InboxMessageEvent}
|
|
102
|
+
* @returns an EventSubscription; call `.remove()` to stop listening
|
|
103
|
+
*/
|
|
104
|
+
registerInboxEventListener(
|
|
105
|
+
listener: (event: InboxMessageEvent) => void
|
|
106
|
+
): EventSubscription {
|
|
107
|
+
const emitter = (data: any) => {
|
|
108
|
+
// Convert raw native payload to InboxMessageEvent with a parsed message
|
|
109
|
+
const event = new InboxMessageEvent(
|
|
110
|
+
data.eventType as InboxEventType,
|
|
111
|
+
parseInboxMessage(data.message),
|
|
112
|
+
data.actionName,
|
|
113
|
+
data.actionValue
|
|
114
|
+
);
|
|
115
|
+
listener(event);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return withNativeModule((native) => {
|
|
119
|
+
let registeredNativeForwarder = false;
|
|
120
|
+
try {
|
|
121
|
+
// Register the native forwarder with the SDK, then subscribe to the
|
|
122
|
+
// codegen-generated event emitter.
|
|
123
|
+
// Wrapped in try-catch due to previous reports of crashes on certain Android architectures.
|
|
124
|
+
if (this._inboxListenerCount === 0) {
|
|
125
|
+
native.registerInboxEventListener();
|
|
126
|
+
registeredNativeForwarder = true;
|
|
127
|
+
}
|
|
128
|
+
const subscription = native.onInboxEventReceived(emitter);
|
|
129
|
+
this._inboxListenerCount += 1;
|
|
130
|
+
|
|
131
|
+
// Wrap remove() so unregistering the LAST JS listener also unregisters the native forwarder
|
|
132
|
+
// (restoring the SDK's default action handling). Guarded so a double remove() cannot
|
|
133
|
+
// unbalance the count and drop the forwarder while other subscriptions are still live.
|
|
134
|
+
const originalRemove = subscription.remove.bind(subscription);
|
|
135
|
+
let removed = false;
|
|
136
|
+
subscription.remove = () => {
|
|
137
|
+
if (removed) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
removed = true;
|
|
141
|
+
originalRemove();
|
|
142
|
+
this._inboxListenerCount -= 1;
|
|
143
|
+
if (this._inboxListenerCount === 0) {
|
|
144
|
+
withNativeModule((n) => n.unregisterInboxEventListener());
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return subscription;
|
|
148
|
+
} catch (error) {
|
|
149
|
+
// If the forwarder was registered and subscribing then failed, roll it back. Otherwise the
|
|
150
|
+
// SDK keeps suppressing its own action handling while nothing in JS is listening, so inbox
|
|
151
|
+
// actions are reported as handled and silently go nowhere.
|
|
152
|
+
if (registeredNativeForwarder) {
|
|
153
|
+
try {
|
|
154
|
+
native.unregisterInboxEventListener();
|
|
155
|
+
} catch (rollbackError) {
|
|
156
|
+
NativeLoggerListener.warn(
|
|
157
|
+
'Failed to roll back inbox listener registration:',
|
|
158
|
+
rollbackError
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
NativeLoggerListener.warn(
|
|
163
|
+
'Failed to attach inbox event listener:',
|
|
164
|
+
error
|
|
165
|
+
);
|
|
166
|
+
// Return a no-op subscription to maintain backwards compatibility
|
|
167
|
+
return {
|
|
168
|
+
remove: () => {},
|
|
169
|
+
eventType: '',
|
|
170
|
+
key: 0,
|
|
171
|
+
subscriber: null as any,
|
|
172
|
+
} as EventSubscription;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
77
177
|
/**
|
|
78
178
|
* Dismisses any currently displayed in-app message
|
|
79
179
|
*/
|
|
@@ -81,6 +181,23 @@ class ZixflowInAppMessaging implements NativeInAppSpec {
|
|
|
81
181
|
withNativeModule((native) => native.dismissMessage());
|
|
82
182
|
}
|
|
83
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Overrides the color scheme used to render in-app messages.
|
|
186
|
+
*
|
|
187
|
+
* Takes effect immediately: messages already on screen — inline views included — are
|
|
188
|
+
* re-themed in place, so this can be called whenever the app's appearance setting
|
|
189
|
+
* changes rather than only before a message is shown.
|
|
190
|
+
*
|
|
191
|
+
* @param colorScheme - scheme to render with; `ZixflowColorScheme.Auto` returns to following
|
|
192
|
+
* the device appearance
|
|
193
|
+
*/
|
|
194
|
+
setColorScheme(colorScheme: ZixflowColorScheme) {
|
|
195
|
+
// Validated here as well as in `initialize`: this is a public method reachable from
|
|
196
|
+
// untyped JavaScript, and without it a bad value reaches the native fallback silently.
|
|
197
|
+
assert.colorScheme(colorScheme);
|
|
198
|
+
withNativeModule((native) => native.setColorScheme(colorScheme));
|
|
199
|
+
}
|
|
200
|
+
|
|
84
201
|
/**
|
|
85
202
|
* Gets the message inbox instance for managing inbox messages
|
|
86
203
|
*
|
|
@@ -122,6 +239,12 @@ class InAppMessageEvent {
|
|
|
122
239
|
|
|
123
240
|
// Export in-app messaging types and components for simplified imports
|
|
124
241
|
export type { InlineInAppMessageViewProps } from './components';
|
|
242
|
+
export type {
|
|
243
|
+
NotificationInboxBellViewProps,
|
|
244
|
+
NotificationInboxViewProps,
|
|
245
|
+
} from './components';
|
|
246
|
+
export { NotificationInboxBellView, NotificationInboxView } from './components';
|
|
125
247
|
export { NotificationInbox } from './notification-inbox';
|
|
126
248
|
export type { InboxMessage, NotificationInboxChangeListener } from './types';
|
|
249
|
+
export { InboxEventType, InboxMessageEvent } from './types';
|
|
127
250
|
export { ZixflowInAppMessaging, InAppMessageEvent, InlineInAppMessageView };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type TurboModule } from 'react-native';
|
|
2
|
+
import {
|
|
3
|
+
default as NativeModule,
|
|
4
|
+
type Spec as CodegenSpec,
|
|
5
|
+
} from './specs/modules/NativeZixflowLiveActivities';
|
|
6
|
+
import type { LiveActivityPayload } from './types/live-activities';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Ensures all methods defined in codegen spec are implemented by the public module
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
interface NativeLiveActivitiesSpec extends Omit<
|
|
14
|
+
CodegenSpec,
|
|
15
|
+
keyof TurboModule
|
|
16
|
+
> {}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Live Activities (iOS) / Live Notifications (Android).
|
|
20
|
+
*
|
|
21
|
+
* Start, update, and end live, updating notifications from built-in templates
|
|
22
|
+
* (Segments, Countdown Timer). Enable the activity types via the `liveNotifications`
|
|
23
|
+
* key of the SDK config passed to {@link Zixflow.initialize}.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export class ZixflowLiveActivities implements NativeLiveActivitiesSpec {
|
|
28
|
+
/**
|
|
29
|
+
* Report an opened Live Activity and return the URL the app should route.
|
|
30
|
+
*
|
|
31
|
+
* Zixflow tracking URLs are unwrapped to their destination after attribution is recorded.
|
|
32
|
+
* A tracking URL without a destination returns `null`; any other URL is returned unchanged.
|
|
33
|
+
* This method never rejects, so it can safely compose with Expo Router's
|
|
34
|
+
* `redirectSystemPath` hook. On Android it is a pass-through.
|
|
35
|
+
*
|
|
36
|
+
* Use this in exactly one URL-routing layer. Calling it more than once for the same Zixflow
|
|
37
|
+
* tracking URL reports more than one opened event.
|
|
38
|
+
*
|
|
39
|
+
* @param url - The incoming URL from the host's linking lifecycle.
|
|
40
|
+
* @returns The URL to route, or `null` when the Zixflow URL has no destination.
|
|
41
|
+
*/
|
|
42
|
+
async handleWidgetUrl(url: string): Promise<string | null> {
|
|
43
|
+
try {
|
|
44
|
+
return await NativeModule.handleWidgetUrl(url);
|
|
45
|
+
} catch {
|
|
46
|
+
return url;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Start a built-in-template activity.
|
|
52
|
+
*
|
|
53
|
+
* @param payload - Template payload; `payload.type` selects the template.
|
|
54
|
+
* @returns The SDK-minted activity id, used for later `update`/`end`.
|
|
55
|
+
*/
|
|
56
|
+
start(payload: LiveActivityPayload): Promise<string> {
|
|
57
|
+
return NativeModule.start(payload);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Replace the whole content-state of a running activity.
|
|
62
|
+
*
|
|
63
|
+
* ActivityKit (iOS) replaces content-state wholesale, so pass the **full** desired
|
|
64
|
+
* state — not just the changed fields. Static attributes (e.g. `header`) cannot
|
|
65
|
+
* change after start and are ignored on iOS.
|
|
66
|
+
*
|
|
67
|
+
* @param activityId - Id returned by {@link ZixflowLiveActivities.start}.
|
|
68
|
+
* @param payload - The complete desired state.
|
|
69
|
+
*/
|
|
70
|
+
update(activityId: string, payload: LiveActivityPayload): Promise<void> {
|
|
71
|
+
return NativeModule.update(activityId, payload);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* End a running activity, optionally rendering a final content-state.
|
|
76
|
+
*
|
|
77
|
+
* @param activityId - Id returned by {@link ZixflowLiveActivities.start}.
|
|
78
|
+
* @param payload - **iOS only.** The final content-state to render as the activity ends.
|
|
79
|
+
* ActivityKit keeps the last content-state on screen when none is given, so pass one to show
|
|
80
|
+
* a terminal state (e.g. all segments complete). Android renders its own terminal state and
|
|
81
|
+
* ignores this.
|
|
82
|
+
*/
|
|
83
|
+
end(activityId: string, payload?: LiveActivityPayload): Promise<void> {
|
|
84
|
+
return NativeModule.end(activityId, payload);
|
|
85
|
+
}
|
|
86
|
+
}
|
package/src/zixflow.ts
CHANGED
|
@@ -2,7 +2,7 @@ require "json"
|
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
4
|
|
|
5
|
-
# Used
|
|
5
|
+
# Used to install native iOS dependencies inside the Notification Service Extension (NSE) target to setup rich push.
|
|
6
6
|
# Note: We need a unique podspec for rich push because the other podspecs in this project install too many dependencies that should not be installed inside of a NSE target. We need this podspec which installs minimal dependencies that are only included in the NSE target.
|
|
7
7
|
Pod::Spec.new do |s|
|
|
8
8
|
s.name = "zixflow-reactnative-richpush"
|
|
@@ -15,7 +15,10 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
|
|
16
16
|
s.source = { :git => "https://github.com/zixflow/zixflow-reactnative.git", :tag => "#{s.version}" }
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
# Dependency-only pod: installed into the NSE target, whose job is purely to pull in the minimal
|
|
19
|
+
# CIO push dependency below. It must NOT compile any sources — everything under ios/ is the React
|
|
20
|
+
# Native bridge (React + DataPipelines + InApp + Inbox), none of which the NSE target has or should
|
|
21
|
+
# have. Globbing them here made the NSE compile the whole bridge and fail on React headers.
|
|
19
22
|
|
|
20
23
|
# Note: Zixflow iOS SDK dependencies need to be added to NSE target via CocoaPods
|
|
21
24
|
# Add these pods to your NotificationServiceExtension target in your Podfile:
|
|
@@ -24,7 +27,7 @@ Pod::Spec.new do |s|
|
|
|
24
27
|
# pod "ZixflowDataPipelines", "= 1.0.0"
|
|
25
28
|
# pod "ZixflowCommon", "= 1.0.0"
|
|
26
29
|
|
|
27
|
-
# Subspecs allow
|
|
30
|
+
# Subspecs allow choosing between APN or FCM for rich push notifications.
|
|
28
31
|
# Set default subspec to 'apn' to prevent both APN and FCM dependencies from being installed by default.
|
|
29
32
|
#
|
|
30
33
|
# To override the default subspec, specify the desired subspec in your Podfile. For example:
|