zixflow-reactnative 1.0.0
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/LICENSE +21 -0
- package/README.md +451 -0
- package/android/build.gradle +155 -0
- package/android/cio-core.gradle +12 -0
- package/android/consumer-rules.pro +3 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +19 -0
- package/android/src/main/java/io/customer/reactnative/sdk/CustomerIOReactNativePackage.kt +85 -0
- package/android/src/main/java/io/customer/reactnative/sdk/NativeCustomerIOModule.kt +201 -0
- package/android/src/main/java/io/customer/reactnative/sdk/constant/Keys.kt +20 -0
- package/android/src/main/java/io/customer/reactnative/sdk/extension/MapExtensions.kt +92 -0
- package/android/src/main/java/io/customer/reactnative/sdk/extension/ReactExtensions.kt +11 -0
- package/android/src/main/java/io/customer/reactnative/sdk/extension/StringExtensions.kt +3 -0
- package/android/src/main/java/io/customer/reactnative/sdk/extension/ViewExtensions.kt +34 -0
- package/android/src/main/java/io/customer/reactnative/sdk/location/NativeLocationModule.kt +66 -0
- package/android/src/main/java/io/customer/reactnative/sdk/logging/NativeCustomerIOLoggingModule.kt +90 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/InlineInAppMessageViewManager.kt +56 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/NativeMessagingInAppModule.kt +215 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/NotificationInboxExtensions.kt +23 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/ReactInAppEventListener.kt +77 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/ReactInAppPlatformDelegate.kt +37 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/ReactInlineInAppMessageView.kt +44 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/ReactNotificationInboxChangeListener.kt +47 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messagingpush/NativeMessagingPushModule.kt +283 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messagingpush/PermissionStatus.kt +9 -0
- package/android/src/main/java/io/customer/reactnative/sdk/messagingpush/PushMessagingExtensions.kt +58 -0
- package/android/src/main/java/io/customer/reactnative/sdk/util/Preconditions.kt +35 -0
- package/android/src/main/res/values/customer_io_config.xml +13 -0
- package/customerio-reactnative.podspec +60 -0
- package/ios/CustomerioReactnative.xcodeproj/project.pbxproj +285 -0
- package/ios/CustomerioReactnative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/CustomerioReactnative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/wrappers/CustomerioReactnative-Bridging-Header.h +2 -0
- package/ios/wrappers/NativeCustomerIO.mm +100 -0
- package/ios/wrappers/NativeCustomerIO.swift +162 -0
- package/ios/wrappers/inapp/InboxMessage+Conversion.swift +22 -0
- package/ios/wrappers/inapp/NativeMessagingInApp.mm +122 -0
- package/ios/wrappers/inapp/NativeMessagingInApp.swift +214 -0
- package/ios/wrappers/inapp/ReactInAppEventListener.swift +74 -0
- package/ios/wrappers/inapp/inline/InlineInAppMessageStateEvent.swift +23 -0
- package/ios/wrappers/inapp/inline/RCTInlineMessageNative.h +18 -0
- package/ios/wrappers/inapp/inline/RCTInlineMessageNative.mm +168 -0
- package/ios/wrappers/inapp/inline/ReactInlineMessageView.h +42 -0
- package/ios/wrappers/inapp/inline/ReactInlineMessageView.swift +124 -0
- package/ios/wrappers/location/NativeLocation.mm +52 -0
- package/ios/wrappers/location/NativeLocation.swift +37 -0
- package/ios/wrappers/logging/NativeCustomerIOLogging.mm +81 -0
- package/ios/wrappers/logging/NativeCustomerIOLogging.swift +62 -0
- package/ios/wrappers/push/NativeMessagingPush.mm +87 -0
- package/ios/wrappers/push/NativeMessagingPush.swift +119 -0
- package/ios/wrappers/utils/CioConfigUtils.swift +63 -0
- package/ios/wrappers/utils/CioConstants.swift +25 -0
- package/ios/wrappers/utils/Preconditions.swift +20 -0
- package/ios/wrappers/utils/RCTCustomerIOUtils.h +19 -0
- package/lib/commonjs/cio-params.js +2 -0
- package/lib/commonjs/cio-params.js.map +1 -0
- package/lib/commonjs/components/InlineInAppMessageView.js +146 -0
- package/lib/commonjs/components/InlineInAppMessageView.js.map +1 -0
- package/lib/commonjs/components/index.js +14 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/customerio-cdp.js +163 -0
- package/lib/commonjs/customerio-cdp.js.map +1 -0
- package/lib/commonjs/customerio-inapp.js +107 -0
- package/lib/commonjs/customerio-inapp.js.map +1 -0
- package/lib/commonjs/customerio-location.js +53 -0
- package/lib/commonjs/customerio-location.js.map +1 -0
- package/lib/commonjs/customerio-push.js +115 -0
- package/lib/commonjs/customerio-push.js.map +1 -0
- package/lib/commonjs/index.js +17 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/native-logger-listener.js +84 -0
- package/lib/commonjs/native-logger-listener.js.map +1 -0
- package/lib/commonjs/notification-inbox.js +132 -0
- package/lib/commonjs/notification-inbox.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/postInstall.js +13 -0
- package/lib/commonjs/postInstall.js.map +1 -0
- package/lib/commonjs/specs/components/InlineMessageNativeComponent.ts +59 -0
- package/lib/commonjs/specs/modules/NativeCustomerIO.js +40 -0
- package/lib/commonjs/specs/modules/NativeCustomerIO.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeCustomerIOLocation.js +15 -0
- package/lib/commonjs/specs/modules/NativeCustomerIOLocation.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeCustomerIOLogging.js +19 -0
- package/lib/commonjs/specs/modules/NativeCustomerIOLogging.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeCustomerIOMessagingInApp.js +16 -0
- package/lib/commonjs/specs/modules/NativeCustomerIOMessagingInApp.js.map +1 -0
- package/lib/commonjs/specs/modules/NativeCustomerIOMessagingPush.js +15 -0
- package/lib/commonjs/specs/modules/NativeCustomerIOMessagingPush.js.map +1 -0
- package/lib/commonjs/types/data-pipelines.js +123 -0
- package/lib/commonjs/types/data-pipelines.js.map +1 -0
- package/lib/commonjs/types/in-app.js +43 -0
- package/lib/commonjs/types/in-app.js.map +1 -0
- package/lib/commonjs/types/index.js +39 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/internal.js +2 -0
- package/lib/commonjs/types/internal.js.map +1 -0
- package/lib/commonjs/types/push.js +49 -0
- package/lib/commonjs/types/push.js.map +1 -0
- package/lib/commonjs/utils/native-bridge.js +31 -0
- package/lib/commonjs/utils/native-bridge.js.map +1 -0
- package/lib/commonjs/utils/param-validation.js +136 -0
- package/lib/commonjs/utils/param-validation.js.map +1 -0
- package/lib/commonjs/zixflow.js +71 -0
- package/lib/commonjs/zixflow.js.map +1 -0
- package/lib/module/cio-params.js +2 -0
- package/lib/module/cio-params.js.map +1 -0
- package/lib/module/components/InlineInAppMessageView.js +141 -0
- package/lib/module/components/InlineInAppMessageView.js.map +1 -0
- package/lib/module/components/index.js +6 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/customerio-cdp.js +157 -0
- package/lib/module/customerio-cdp.js.map +1 -0
- package/lib/module/customerio-inapp.js +92 -0
- package/lib/module/customerio-inapp.js.map +1 -0
- package/lib/module/customerio-location.js +48 -0
- package/lib/module/customerio-location.js.map +1 -0
- package/lib/module/customerio-push.js +111 -0
- package/lib/module/customerio-push.js.map +1 -0
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native-logger-listener.js +79 -0
- package/lib/module/native-logger-listener.js.map +1 -0
- package/lib/module/notification-inbox.js +127 -0
- package/lib/module/notification-inbox.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/postInstall.js +13 -0
- package/lib/module/postInstall.js.map +1 -0
- package/lib/module/specs/components/InlineMessageNativeComponent.ts +59 -0
- package/lib/module/specs/modules/NativeCustomerIO.js +41 -0
- package/lib/module/specs/modules/NativeCustomerIO.js.map +1 -0
- package/lib/module/specs/modules/NativeCustomerIOLocation.js +13 -0
- package/lib/module/specs/modules/NativeCustomerIOLocation.js.map +1 -0
- package/lib/module/specs/modules/NativeCustomerIOLogging.js +18 -0
- package/lib/module/specs/modules/NativeCustomerIOLogging.js.map +1 -0
- package/lib/module/specs/modules/NativeCustomerIOMessagingInApp.js +15 -0
- package/lib/module/specs/modules/NativeCustomerIOMessagingInApp.js.map +1 -0
- package/lib/module/specs/modules/NativeCustomerIOMessagingPush.js +13 -0
- package/lib/module/specs/modules/NativeCustomerIOMessagingPush.js.map +1 -0
- package/lib/module/types/data-pipelines.js +126 -0
- package/lib/module/types/data-pipelines.js.map +1 -0
- package/lib/module/types/in-app.js +42 -0
- package/lib/module/types/in-app.js.map +1 -0
- package/lib/module/types/index.js +6 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/internal.js +2 -0
- package/lib/module/types/internal.js.map +1 -0
- package/lib/module/types/push.js +47 -0
- package/lib/module/types/push.js.map +1 -0
- package/lib/module/utils/native-bridge.js +25 -0
- package/lib/module/utils/native-bridge.js.map +1 -0
- package/lib/module/utils/param-validation.js +132 -0
- package/lib/module/utils/param-validation.js.map +1 -0
- package/lib/module/zixflow.js +23 -0
- package/lib/module/zixflow.js.map +1 -0
- package/lib/typescript/commonjs/cio-params.d.ts +5 -0
- package/lib/typescript/commonjs/cio-params.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/InlineInAppMessageView.d.ts +41 -0
- package/lib/typescript/commonjs/components/InlineInAppMessageView.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/customerio-cdp.d.ts +40 -0
- package/lib/typescript/commonjs/customerio-cdp.d.ts.map +1 -0
- package/lib/typescript/commonjs/customerio-inapp.d.ts +48 -0
- package/lib/typescript/commonjs/customerio-inapp.d.ts.map +1 -0
- package/lib/typescript/commonjs/customerio-location.d.ts +31 -0
- package/lib/typescript/commonjs/customerio-location.d.ts.map +1 -0
- package/lib/typescript/commonjs/customerio-push.d.ts +56 -0
- package/lib/typescript/commonjs/customerio-push.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +8 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/native-logger-listener.d.ts +8 -0
- package/lib/typescript/commonjs/native-logger-listener.d.ts.map +1 -0
- package/lib/typescript/commonjs/notification-inbox.d.ts +57 -0
- package/lib/typescript/commonjs/notification-inbox.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/postInstall.d.ts +2 -0
- package/lib/typescript/commonjs/postInstall.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/components/InlineMessageNativeComponent.d.ts +40 -0
- package/lib/typescript/commonjs/specs/components/InlineMessageNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIO.d.ts +46 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIO.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIOLocation.d.ts +14 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIOLocation.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIOLogging.d.ts +18 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIOLogging.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIOMessagingInApp.d.ts +23 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIOMessagingInApp.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIOMessagingPush.d.ts +20 -0
- package/lib/typescript/commonjs/specs/modules/NativeCustomerIOMessagingPush.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/data-pipelines.d.ts +143 -0
- package/lib/typescript/commonjs/types/data-pipelines.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/in-app.d.ts +67 -0
- package/lib/typescript/commonjs/types/in-app.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/index.d.ts +4 -0
- package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/internal.d.ts +20 -0
- package/lib/typescript/commonjs/types/internal.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/push.d.ts +49 -0
- package/lib/typescript/commonjs/types/push.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/native-bridge.d.ts +9 -0
- package/lib/typescript/commonjs/utils/native-bridge.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/param-validation.d.ts +44 -0
- package/lib/typescript/commonjs/utils/param-validation.d.ts.map +1 -0
- package/lib/typescript/commonjs/zixflow.d.ts +14 -0
- package/lib/typescript/commonjs/zixflow.d.ts.map +1 -0
- package/lib/typescript/module/cio-params.d.ts +5 -0
- package/lib/typescript/module/cio-params.d.ts.map +1 -0
- package/lib/typescript/module/components/InlineInAppMessageView.d.ts +41 -0
- package/lib/typescript/module/components/InlineInAppMessageView.d.ts.map +1 -0
- package/lib/typescript/module/components/index.d.ts +3 -0
- package/lib/typescript/module/components/index.d.ts.map +1 -0
- package/lib/typescript/module/customerio-cdp.d.ts +40 -0
- package/lib/typescript/module/customerio-cdp.d.ts.map +1 -0
- package/lib/typescript/module/customerio-inapp.d.ts +48 -0
- package/lib/typescript/module/customerio-inapp.d.ts.map +1 -0
- package/lib/typescript/module/customerio-location.d.ts +31 -0
- package/lib/typescript/module/customerio-location.d.ts.map +1 -0
- package/lib/typescript/module/customerio-push.d.ts +56 -0
- package/lib/typescript/module/customerio-push.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +8 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/native-logger-listener.d.ts +8 -0
- package/lib/typescript/module/native-logger-listener.d.ts.map +1 -0
- package/lib/typescript/module/notification-inbox.d.ts +57 -0
- package/lib/typescript/module/notification-inbox.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/postInstall.d.ts +2 -0
- package/lib/typescript/module/postInstall.d.ts.map +1 -0
- package/lib/typescript/module/specs/components/InlineMessageNativeComponent.d.ts +40 -0
- package/lib/typescript/module/specs/components/InlineMessageNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIO.d.ts +46 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIO.d.ts.map +1 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIOLocation.d.ts +14 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIOLocation.d.ts.map +1 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIOLogging.d.ts +18 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIOLogging.d.ts.map +1 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIOMessagingInApp.d.ts +23 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIOMessagingInApp.d.ts.map +1 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIOMessagingPush.d.ts +20 -0
- package/lib/typescript/module/specs/modules/NativeCustomerIOMessagingPush.d.ts.map +1 -0
- package/lib/typescript/module/types/data-pipelines.d.ts +143 -0
- package/lib/typescript/module/types/data-pipelines.d.ts.map +1 -0
- package/lib/typescript/module/types/in-app.d.ts +67 -0
- package/lib/typescript/module/types/in-app.d.ts.map +1 -0
- package/lib/typescript/module/types/index.d.ts +4 -0
- package/lib/typescript/module/types/index.d.ts.map +1 -0
- package/lib/typescript/module/types/internal.d.ts +20 -0
- package/lib/typescript/module/types/internal.d.ts.map +1 -0
- package/lib/typescript/module/types/push.d.ts +49 -0
- package/lib/typescript/module/types/push.d.ts.map +1 -0
- package/lib/typescript/module/utils/native-bridge.d.ts +9 -0
- package/lib/typescript/module/utils/native-bridge.d.ts.map +1 -0
- package/lib/typescript/module/utils/param-validation.d.ts +44 -0
- package/lib/typescript/module/utils/param-validation.d.ts.map +1 -0
- package/lib/typescript/module/zixflow.d.ts +14 -0
- package/lib/typescript/module/zixflow.d.ts.map +1 -0
- package/package.json +165 -0
- package/src/cio-params.ts +4 -0
- package/src/components/InlineInAppMessageView.tsx +187 -0
- package/src/components/index.ts +3 -0
- package/src/customerio-cdp.ts +190 -0
- package/src/customerio-inapp.ts +127 -0
- package/src/customerio-location.ts +56 -0
- package/src/customerio-push.ts +127 -0
- package/src/index.ts +9 -0
- package/src/native-logger-listener.ts +84 -0
- package/src/notification-inbox.ts +154 -0
- package/src/postInstall.js +10 -0
- package/src/specs/components/InlineMessageNativeComponent.ts +59 -0
- package/src/specs/modules/NativeCustomerIO.ts +55 -0
- package/src/specs/modules/NativeCustomerIOLocation.ts +15 -0
- package/src/specs/modules/NativeCustomerIOLogging.ts +24 -0
- package/src/specs/modules/NativeCustomerIOMessagingInApp.ts +30 -0
- package/src/specs/modules/NativeCustomerIOMessagingPush.ts +27 -0
- package/src/types/data-pipelines.ts +150 -0
- package/src/types/in-app.ts +69 -0
- package/src/types/index.ts +3 -0
- package/src/types/internal.ts +20 -0
- package/src/types/push.ts +50 -0
- package/src/utils/native-bridge.ts +30 -0
- package/src/utils/param-validation.ts +178 -0
- package/src/zixflow.ts +24 -0
- package/zixflow-reactnative-richpush.podspec +42 -0
- package/zixflow-reactnative.podspec +66 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const LINKING_ERROR =
|
|
4
|
+
`The package 'customerio-reactnative' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
|
+
'- You rebuilt the app after installing the package\n' +
|
|
7
|
+
'- You are not using Expo managed workflow\n';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Ensures the native module is available, otherwise throws a helpful linking error.
|
|
11
|
+
*/
|
|
12
|
+
export function ensureNativeModule<NativeModule>(
|
|
13
|
+
nativeModule: NativeModule | null
|
|
14
|
+
): NativeModule {
|
|
15
|
+
if (!nativeModule) {
|
|
16
|
+
throw new Error(LINKING_ERROR);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return nativeModule;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Calls a method on a native module with type-safe access.
|
|
24
|
+
*/
|
|
25
|
+
export const callNativeModule = <Spec, Result>(
|
|
26
|
+
nativeModule: Spec,
|
|
27
|
+
fn: (native: Spec) => Result
|
|
28
|
+
): Result => {
|
|
29
|
+
return fn(nativeModule);
|
|
30
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Argument validation utilities for SDK internal use
|
|
2
|
+
// Ensures input safety and throws clear errors when validation fails
|
|
3
|
+
|
|
4
|
+
import type { CioConfig, CustomAttributes } from '../types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Builds a standardized error message for validation failures.
|
|
8
|
+
*/
|
|
9
|
+
function buildErrorMessage(
|
|
10
|
+
usage: string | undefined,
|
|
11
|
+
fieldName: string,
|
|
12
|
+
error: string
|
|
13
|
+
): string {
|
|
14
|
+
const prefix = usage ? `${usage} ` : '';
|
|
15
|
+
return `${prefix}"${fieldName}" ${error}.`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if the value is undefined or null.
|
|
20
|
+
*/
|
|
21
|
+
function isUndefined(value: unknown): boolean {
|
|
22
|
+
return value === undefined || value === null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Throws an error if the condition is true.
|
|
27
|
+
* Use this to fail validation checks with cleaner syntax.
|
|
28
|
+
*/
|
|
29
|
+
function failIf(condition: boolean, message: () => string): void {
|
|
30
|
+
if (__DEV__ && condition) {
|
|
31
|
+
throw new Error(`[CustomerIO] ${message()}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Validates that a value is defined (not undefined or null).
|
|
37
|
+
* Useful for checking required fields.
|
|
38
|
+
*/
|
|
39
|
+
function failIfUndefined(
|
|
40
|
+
value: unknown,
|
|
41
|
+
fieldName: string,
|
|
42
|
+
usage?: string
|
|
43
|
+
): void {
|
|
44
|
+
failIf(isUndefined(value), () =>
|
|
45
|
+
buildErrorMessage(usage, fieldName, 'is required')
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Validates that a value is a string.
|
|
51
|
+
* Throws if the value is not a string, or if it's empty (unless allowEmpty is true).
|
|
52
|
+
*/
|
|
53
|
+
function validateString(
|
|
54
|
+
value: unknown,
|
|
55
|
+
fieldName: string,
|
|
56
|
+
options: {
|
|
57
|
+
allowEmpty?: boolean;
|
|
58
|
+
usage?: string;
|
|
59
|
+
optional?: boolean;
|
|
60
|
+
} = { allowEmpty: true }
|
|
61
|
+
) {
|
|
62
|
+
const { allowEmpty, usage, optional } = options;
|
|
63
|
+
if (optional && isUndefined(value)) {
|
|
64
|
+
return; // Skip validation for optional fields
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const prefix = usage ? `${usage} ` : '';
|
|
68
|
+
|
|
69
|
+
failIfUndefined(value, fieldName, usage);
|
|
70
|
+
failIf(
|
|
71
|
+
typeof value !== 'string',
|
|
72
|
+
() => `${prefix}"${fieldName}" must be a string.`
|
|
73
|
+
);
|
|
74
|
+
// Since typeof value is already checked to be a string,
|
|
75
|
+
// we can safely cast it here without additional checks.
|
|
76
|
+
const typedValue = value as string;
|
|
77
|
+
failIf(
|
|
78
|
+
!allowEmpty && typedValue.trim() === '',
|
|
79
|
+
() => `${prefix}"${fieldName}" must be a non-empty string.`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Validates that a value is a plain object (not null or an array).
|
|
85
|
+
*/
|
|
86
|
+
function validateRecord(
|
|
87
|
+
value: unknown,
|
|
88
|
+
fieldName: string,
|
|
89
|
+
options: {
|
|
90
|
+
usage?: string;
|
|
91
|
+
expectedType?: string;
|
|
92
|
+
optional?: boolean;
|
|
93
|
+
} = {}
|
|
94
|
+
) {
|
|
95
|
+
const { usage, expectedType, optional } = options;
|
|
96
|
+
if (optional && isUndefined(value)) {
|
|
97
|
+
return; // Skip validation for optional fields
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const prefix = usage ? `${usage} ` : '';
|
|
101
|
+
const typeName = expectedType ?? 'plain';
|
|
102
|
+
|
|
103
|
+
failIfUndefined(value, fieldName, usage);
|
|
104
|
+
failIf(
|
|
105
|
+
typeof value !== 'object' || Array.isArray(value),
|
|
106
|
+
() => `${prefix}"${fieldName}" must be a valid ${typeName} object.`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Validates that a value is a valid CustomAttributes object.
|
|
112
|
+
* Automatically converts Map objects to plain objects for compatibility.
|
|
113
|
+
* This is a specialized version of validateRecord optimized for attribute validation.
|
|
114
|
+
*/
|
|
115
|
+
function validateAttributes(
|
|
116
|
+
value: unknown,
|
|
117
|
+
fieldName: string,
|
|
118
|
+
options: {
|
|
119
|
+
usage?: string;
|
|
120
|
+
expectedType?: string;
|
|
121
|
+
optional?: boolean;
|
|
122
|
+
} = {}
|
|
123
|
+
): CustomAttributes | undefined {
|
|
124
|
+
const exists = !isUndefined(value);
|
|
125
|
+
if (options.optional && !exists) {
|
|
126
|
+
return; // Skip validation for optional fields
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let attributes: unknown;
|
|
130
|
+
if (exists && value instanceof Map) {
|
|
131
|
+
// Convert Map to plain object for native serialization
|
|
132
|
+
attributes = Object.fromEntries(value);
|
|
133
|
+
} else {
|
|
134
|
+
attributes = value;
|
|
135
|
+
}
|
|
136
|
+
validateRecord(attributes, fieldName, options);
|
|
137
|
+
return attributes as CustomAttributes;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Validates that the given value is a valid CioConfig object.
|
|
142
|
+
* Throws if required fields are missing or incorrectly typed.
|
|
143
|
+
*/
|
|
144
|
+
function validateConfig(value: unknown): asserts value is CioConfig {
|
|
145
|
+
const fieldName = 'config';
|
|
146
|
+
const usage = 'SDK';
|
|
147
|
+
|
|
148
|
+
validateRecord(value, fieldName, {
|
|
149
|
+
expectedType: 'CioConfig',
|
|
150
|
+
usage: usage,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const obj = value as CioConfig;
|
|
154
|
+
validateString(obj.cdpApiKey, `${fieldName}.cdpApiKey`, {
|
|
155
|
+
allowEmpty: false,
|
|
156
|
+
usage: usage,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// For type safety, we define a ConfigValidator type that asserts the value is a CioConfig
|
|
161
|
+
// This allows us to use it in the assert object without needing to redefine the function signature
|
|
162
|
+
type ConfigValidator = (value: unknown) => asserts value is CioConfig;
|
|
163
|
+
|
|
164
|
+
export const assert: {
|
|
165
|
+
string: typeof validateString;
|
|
166
|
+
record: typeof validateRecord;
|
|
167
|
+
attributes: typeof validateAttributes;
|
|
168
|
+
config: ConfigValidator;
|
|
169
|
+
} = {
|
|
170
|
+
string: validateString,
|
|
171
|
+
record: validateRecord,
|
|
172
|
+
attributes: validateAttributes,
|
|
173
|
+
config: validateConfig,
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export const validate = {
|
|
177
|
+
isUndefined: isUndefined,
|
|
178
|
+
};
|
package/src/zixflow.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zixflow SDK - Main entry point
|
|
3
|
+
*
|
|
4
|
+
* This provides the Zixflow-branded API that wraps the underlying Customer.io implementation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { CustomerIO } from './customerio-cdp';
|
|
8
|
+
import { CustomerIOInAppMessaging } from './customerio-inapp';
|
|
9
|
+
import { CustomerIOLocation } from './customerio-location';
|
|
10
|
+
import { CustomerIOPushMessaging } from './customerio-push';
|
|
11
|
+
|
|
12
|
+
// Re-export the CustomerIO class as Zixflow for branding
|
|
13
|
+
export const Zixflow = CustomerIO;
|
|
14
|
+
|
|
15
|
+
// Re-export all types and utilities
|
|
16
|
+
export * from './types';
|
|
17
|
+
export * from './notification-inbox';
|
|
18
|
+
|
|
19
|
+
// Export sub-modules with their original names (they work with the main Zixflow class)
|
|
20
|
+
export {
|
|
21
|
+
CustomerIOInAppMessaging,
|
|
22
|
+
CustomerIOLocation,
|
|
23
|
+
CustomerIOPushMessaging,
|
|
24
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
# Used by customers to install native iOS dependencies inside their Notification Service Extension (NSE) target to setup rich push.
|
|
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
|
+
Pod::Spec.new do |s|
|
|
8
|
+
s.name = "zixflow-reactnative-richpush"
|
|
9
|
+
s.version = package["version"]
|
|
10
|
+
s.summary = package["description"]
|
|
11
|
+
s.homepage = package["homepage"]
|
|
12
|
+
s.license = package["license"]
|
|
13
|
+
s.authors = package["author"]
|
|
14
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
15
|
+
|
|
16
|
+
s.source = { :git => "https://github.com/zixflow/zixflow-reactnative.git", :tag => "#{s.version}" }
|
|
17
|
+
|
|
18
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
19
|
+
|
|
20
|
+
# Note: Zixflow iOS SDK dependencies need to be added to NSE target via CocoaPods
|
|
21
|
+
# Add these pods to your NotificationServiceExtension target in your Podfile:
|
|
22
|
+
# pod "ZixflowMessagingPushAPN", "= 1.0.0" (or ZixflowMessagingPushFCM for FCM)
|
|
23
|
+
# pod "ZixflowMessagingPush", "= 1.0.0"
|
|
24
|
+
# pod "ZixflowDataPipelines", "= 1.0.0"
|
|
25
|
+
# pod "ZixflowCommon", "= 1.0.0"
|
|
26
|
+
|
|
27
|
+
# Subspecs allow customers to choose between multiple options of what type of version of this rich push package they would like to install.
|
|
28
|
+
# Set default subspec to 'apn' to prevent both APN and FCM dependencies from being installed by default.
|
|
29
|
+
#
|
|
30
|
+
# To override the default subspec, specify the desired subspec in your Podfile. For example:
|
|
31
|
+
# pod 'zixflow-reactnative-richpush/fcm'
|
|
32
|
+
|
|
33
|
+
s.default_subspec = 'apn'
|
|
34
|
+
|
|
35
|
+
s.subspec 'apn' do |ss|
|
|
36
|
+
# ZixflowMessagingPushAPN linked via SPM
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
s.subspec 'fcm' do |ss|
|
|
40
|
+
# ZixflowMessagingPushFCM linked via SPM
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
# Zixflow React Native wrapper podspec
|
|
6
|
+
# Uses Zixflow iOS SDK via CocoaPods
|
|
7
|
+
Pod::Spec.new do |s|
|
|
8
|
+
s.name = "zixflow-reactnative"
|
|
9
|
+
s.version = package["version"]
|
|
10
|
+
s.summary = package["description"]
|
|
11
|
+
s.homepage = package["homepage"]
|
|
12
|
+
s.license = package["license"]
|
|
13
|
+
s.authors = package["author"]
|
|
14
|
+
|
|
15
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
16
|
+
s.source = { :git => "https://github.com/zixflow/zixflow-reactnative.git", :tag => "#{s.version}" }
|
|
17
|
+
|
|
18
|
+
s.source_files = "ios/wrappers/**/*.{h,m,mm,swift}"
|
|
19
|
+
|
|
20
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
22
|
+
install_modules_dependencies(s)
|
|
23
|
+
else
|
|
24
|
+
s.dependency "React-Core"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Zixflow iOS SDK dependencies via CocoaPods
|
|
28
|
+
# Using `= X.X.X` for exact version matching
|
|
29
|
+
s.dependency "ZixflowDataPipelines", package["zixflowNativeiOSSdkVersion"]
|
|
30
|
+
s.dependency "ZixflowMessagingInApp", package["zixflowNativeiOSSdkVersion"]
|
|
31
|
+
s.dependency "ZixflowCommon", package["zixflowNativeiOSSdkVersion"]
|
|
32
|
+
s.dependency "ZixflowTrackingMigration", package["zixflowNativeiOSSdkVersion"]
|
|
33
|
+
|
|
34
|
+
# Transitive dependencies (required for explicit module builds)
|
|
35
|
+
s.dependency "AnalyticsSwiftZixflow", "1.7.3+zixflow.1"
|
|
36
|
+
s.dependency "JSONSafeEncoding", "~> 2.0"
|
|
37
|
+
s.dependency "Sovran", "~> 1.1"
|
|
38
|
+
s.dependency "LDSwiftEventSource", "~> 3.3"
|
|
39
|
+
|
|
40
|
+
# If we do not specify a default_subspec, then *all* dependencies inside of *all* the subspecs will be downloaded by cocoapods.
|
|
41
|
+
# We want customers to opt into push dependencies especially because the FCM subspec downloads Firebase dependencies. APN customers should not install Firebase dependencies at all.
|
|
42
|
+
s.default_subspec = "nopush"
|
|
43
|
+
|
|
44
|
+
s.subspec "nopush" do |ss|
|
|
45
|
+
# This is the default subspec designed to not install any push dependencies. Customer should choose APN or FCM.
|
|
46
|
+
# The SDK at runtime currently requires the MessagingPush module so we do include it here.
|
|
47
|
+
ss.dependency "ZixflowMessagingPush", package["zixflowNativeiOSSdkVersion"]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Note: Subspecs inherit all dependencies specified the parent spec (this file).
|
|
51
|
+
s.subspec "apn" do |ss|
|
|
52
|
+
ss.dependency "ZixflowMessagingPushAPN", package["zixflowNativeiOSSdkVersion"]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
s.subspec "fcm" do |ss|
|
|
56
|
+
ss.dependency "ZixflowMessagingPushFCM", package["zixflowNativeiOSSdkVersion"]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Location module is optional - customers must opt in by adding this subspec.
|
|
60
|
+
s.subspec "location" do |ss|
|
|
61
|
+
ss.dependency "ZixflowLocation", package["zixflowNativeiOSSdkVersion"]
|
|
62
|
+
ss.pod_target_xcconfig = {
|
|
63
|
+
'OTHER_SWIFT_FLAGS' => '$(inherited) -DCIO_LOCATION_ENABLED'
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
end
|