@capillarytech/react-native-hydra-lib 1.7.0-beta.1
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/CHANGELOG.md +252 -0
- package/DEPRECATION_POLICY.md +220 -0
- package/LICENSE +20 -0
- package/MIGRATION.md +361 -0
- package/README.md +491 -0
- package/RELEASE_NOTES.md +528 -0
- package/android/build.gradle +565 -0
- package/android/generated/java/com/hydralib/NativeHydraLibSpec.java +185 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNHydraLibSpec-generated.cpp +248 -0
- package/android/generated/jni/RNHydraLibSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/ComponentDescriptors.cpp +24 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/ComponentDescriptors.h +26 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/EventEmitters.cpp +18 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/EventEmitters.h +37 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/Props.cpp +39 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/Props.h +47 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/RNHydraLibSpecJSI-generated.cpp +283 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/RNHydraLibSpecJSI.h +395 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/ShadowNodes.cpp +19 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/ShadowNodes.h +54 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNHydraLibSpec/States.h +53 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/AndroidManifestNew.xml +16 -0
- package/android/src/main/AndroidManifestNoFirebaseIcon.xml +5 -0
- package/android/src/main/java/com/hydralib/delegates/HydraActivityCallbacks.kt +90 -0
- package/android/src/main/java/com/hydralib/delegates/NonHydraNotificationActivity.kt +43 -0
- package/android/src/main/java/com/hydralib/eventemitter/HydraEventEmitter.kt +150 -0
- package/android/src/main/java/com/hydralib/eventemitter/HydraEventType.kt +44 -0
- package/android/src/main/java/com/hydralib/gamification/GamificationBannerViewManager.kt +121 -0
- package/android/src/main/java/com/hydralib/gamification/GamificationEmbedViewManager.kt +153 -0
- package/android/src/main/java/com/hydralib/gamification/GamificationLoyaltyViewManager.kt +95 -0
- package/android/src/main/java/com/hydralib/hydrasdk/HydraCore.kt +860 -0
- package/android/src/main/java/com/hydralib/hydrasdk/HydraExtenstions.kt +331 -0
- package/android/src/main/java/com/hydralib/hydrasdk/HydraInAppMessages.kt +136 -0
- package/android/src/main/java/com/hydralib/hydrasdk/HydraInbox.kt +70 -0
- package/android/src/main/java/com/hydralib/hydrasdk/HydraInboxUI.kt +54 -0
- package/android/src/main/java/com/hydralib/hydrasdk/HydraPushNotification.kt +299 -0
- package/android/src/main/java/com/hydralib/nativeapis/Hydra.kt +28 -0
- package/android/src/main/java/com/hydralib/nativeapis/HydraFirebaseRemoteConfigKeys.kt +76 -0
- package/android/src/main/java/com/hydralib/nativeapis/HydraInitializer.kt +130 -0
- package/android/src/main/java/com/hydralib/nativeapis/HydraNativeMessaging.kt +18 -0
- package/android/src/main/java/com/hydralib/nativeapis/HydraRemoteConfig.kt +59 -0
- package/android/src/main/java/com/hydralib/utils/RNHydraPreferencesManager.kt +154 -0
- package/android/src/main/java/com/hydralib/utils/ResourceUtil.kt +10 -0
- package/android/src/newarch/HydraLibModule.kt +218 -0
- package/android/src/oldarch/HydraLibModule.kt +258 -0
- package/android/src/rn72OrLess/HydraLibPackage.kt +43 -0
- package/android/src/rn73OrMore/HydraLibPackage.kt +53 -0
- package/ios/Delegates/HydraApplicationDelegate.swift +196 -0
- package/ios/Delegates/HydraFirebaseMessagingDelegate.swift +20 -0
- package/ios/Delegates/HydraUNUserNotificationCenterDelegate.swift +26 -0
- package/ios/EventEmitter/HydraEventEmitter.swift +98 -0
- package/ios/EventEmitter/HydraEventType.swift +28 -0
- package/ios/EventEmitter/HydraNativeEmitterBrigde.h +15 -0
- package/ios/EventEmitter/HydraNativeEmitterBrigde.mm +48 -0
- package/ios/GamificationViews/GamificationBannerViewComponentView.h +14 -0
- package/ios/GamificationViews/GamificationBannerViewComponentView.mm +125 -0
- package/ios/GamificationViews/GamificationEmbedViewComponentView.h +14 -0
- package/ios/GamificationViews/GamificationEmbedViewComponentView.mm +131 -0
- package/ios/GamificationViews/GamificationLoyaltyViewComponentView.h +14 -0
- package/ios/GamificationViews/GamificationLoyaltyViewComponentView.mm +120 -0
- package/ios/HydraLib.h +16 -0
- package/ios/HydraLib.mm +207 -0
- package/ios/HydraSDK/HydraInAppMessages.swift +93 -0
- package/ios/HydraSDK/HydraInbox.swift +97 -0
- package/ios/HydraSDK/HydraInboxUI.swift +105 -0
- package/ios/HydraSDK/HydraPushNotification.swift +476 -0
- package/ios/HydraSDK/HydraSDKCore.swift +707 -0
- package/ios/NativeAPIs/Hydra.h +34 -0
- package/ios/NativeAPIs/Hydra.mm +47 -0
- package/ios/NativeAPIs/HydraNativeFirebaseRemoteConfigKeys.h +23 -0
- package/ios/NativeAPIs/HydraNativeFirebaseRemoteConfigKeys.mm +80 -0
- package/ios/NativeAPIs/HydraNativeInitializer.h +16 -0
- package/ios/NativeAPIs/HydraNativeInitializer.mm +39 -0
- package/ios/NativeAPIs/HydraNativeMessaging.h +24 -0
- package/ios/NativeAPIs/HydraNativeMessaging.mm +53 -0
- package/ios/NativeAPIs/HydraNativeRemoteConfig.h +27 -0
- package/ios/NativeAPIs/HydraNativeRemoteConfig.mm +89 -0
- package/ios/Utils/HydraExtensions.swift +322 -0
- package/ios/Utils/HydraRNConstants.swift +13 -0
- package/ios/Utils/RNHydraLogger.swift +31 -0
- package/ios/generated/RNHydraLibSpec/ComponentDescriptors.cpp +24 -0
- package/ios/generated/RNHydraLibSpec/ComponentDescriptors.h +26 -0
- package/ios/generated/RNHydraLibSpec/EventEmitters.cpp +18 -0
- package/ios/generated/RNHydraLibSpec/EventEmitters.h +37 -0
- package/ios/generated/RNHydraLibSpec/Props.cpp +39 -0
- package/ios/generated/RNHydraLibSpec/Props.h +47 -0
- package/ios/generated/RNHydraLibSpec/RCTComponentViewHelpers.h +28 -0
- package/ios/generated/RNHydraLibSpec/RNHydraLibSpec-generated.mm +291 -0
- package/ios/generated/RNHydraLibSpec/RNHydraLibSpec.h +167 -0
- package/ios/generated/RNHydraLibSpec/ShadowNodes.cpp +19 -0
- package/ios/generated/RNHydraLibSpec/ShadowNodes.h +54 -0
- package/ios/generated/RNHydraLibSpec/States.cpp +16 -0
- package/ios/generated/RNHydraLibSpec/States.h +53 -0
- package/ios/generated/RNHydraLibSpecJSI-generated.cpp +283 -0
- package/ios/generated/RNHydraLibSpecJSI.h +395 -0
- package/lib/commonjs/GamificationBannerViewNativeComponent.js +10 -0
- package/lib/commonjs/GamificationBannerViewNativeComponent.js.map +1 -0
- package/lib/commonjs/GamificationEmbedViewNativeComponent.js +10 -0
- package/lib/commonjs/GamificationEmbedViewNativeComponent.js.map +1 -0
- package/lib/commonjs/GamificationLoyaltyViewNativeComponent.js +10 -0
- package/lib/commonjs/GamificationLoyaltyViewNativeComponent.js.map +1 -0
- package/lib/commonjs/NativeHydraLib.js +11 -0
- package/lib/commonjs/NativeHydraLib.js.map +1 -0
- package/lib/commonjs/components/GamificationBannerView.js +15 -0
- package/lib/commonjs/components/GamificationBannerView.js.map +1 -0
- package/lib/commonjs/components/GamificationEmbedView.js +15 -0
- package/lib/commonjs/components/GamificationEmbedView.js.map +1 -0
- package/lib/commonjs/components/GamificationLoyaltyView.js +15 -0
- package/lib/commonjs/components/GamificationLoyaltyView.js.map +1 -0
- package/lib/commonjs/hydra-apis/Hydra.js +43 -0
- package/lib/commonjs/hydra-apis/Hydra.js.map +1 -0
- package/lib/commonjs/hydra-apis/HydraCore.js +42 -0
- package/lib/commonjs/hydra-apis/HydraCore.js.map +1 -0
- package/lib/commonjs/hydra-apis/HydraInAppMessaging.js +24 -0
- package/lib/commonjs/hydra-apis/HydraInAppMessaging.js.map +1 -0
- package/lib/commonjs/hydra-apis/HydraInbox.js +29 -0
- package/lib/commonjs/hydra-apis/HydraInbox.js.map +1 -0
- package/lib/commonjs/hydra-apis/HydraInboxUI.js +18 -0
- package/lib/commonjs/hydra-apis/HydraInboxUI.js.map +1 -0
- package/lib/commonjs/hydra-apis/HydraNativeEventEmitter.js +133 -0
- package/lib/commonjs/hydra-apis/HydraNativeEventEmitter.js.map +1 -0
- package/lib/commonjs/hydra-apis/HydraPushNotification.js +21 -0
- package/lib/commonjs/hydra-apis/HydraPushNotification.js.map +1 -0
- package/lib/commonjs/index.js +230 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/models/HydraAccountConfig.js +41 -0
- package/lib/commonjs/models/HydraAccountConfig.js.map +1 -0
- package/lib/commonjs/models/HydraFirebaseRemoteConfigKeys.js +40 -0
- package/lib/commonjs/models/HydraFirebaseRemoteConfigKeys.js.map +1 -0
- package/lib/commonjs/models/HydraGeoConfig.js +24 -0
- package/lib/commonjs/models/HydraGeoConfig.js.map +1 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppButtonComponent.js +26 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppButtonComponent.js.map +1 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppComponentStyle.js +26 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppComponentStyle.js.map +1 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.js +39 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.js.map +1 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppMessage.js +60 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppMessage.js.map +1 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppTemplateType.js +66 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppTemplateType.js.map +1 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppTextComponent.js +21 -0
- package/lib/commonjs/models/HydraInAppMessage/HydraInAppTextComponent.js.map +1 -0
- package/lib/commonjs/models/HydraLogLevel.js +16 -0
- package/lib/commonjs/models/HydraLogLevel.js.map +1 -0
- package/lib/commonjs/models/HydraNativeEvent.js +27 -0
- package/lib/commonjs/models/HydraNativeEvent.js.map +1 -0
- package/lib/commonjs/models/HydraNotification/HydraNotification.js +70 -0
- package/lib/commonjs/models/HydraNotification/HydraNotification.js.map +1 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationBody.js +25 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationBody.js.map +1 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationCta.js +23 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationCta.js.map +1 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationCtaType.js +62 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationCtaType.js.map +1 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationExpandedDetails.js +25 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationExpandedDetails.js.map +1 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationGateway.js +13 -0
- package/lib/commonjs/models/HydraNotification/HydraNotificationGateway.js.map +1 -0
- package/lib/commonjs/models/HydraPushPreferences.js +20 -0
- package/lib/commonjs/models/HydraPushPreferences.js.map +1 -0
- package/lib/commonjs/models/HydraUserDetails.js +26 -0
- package/lib/commonjs/models/HydraUserDetails.js.map +1 -0
- package/lib/commonjs/models/HydraVisitorInfo.js +19 -0
- package/lib/commonjs/models/HydraVisitorInfo.js.map +1 -0
- package/lib/commonjs/models/NonHydraNotification.js +18 -0
- package/lib/commonjs/models/NonHydraNotification.js.map +1 -0
- package/lib/commonjs/models/UserState.js +41 -0
- package/lib/commonjs/models/UserState.js.map +1 -0
- package/lib/module/GamificationBannerViewNativeComponent.js +5 -0
- package/lib/module/GamificationBannerViewNativeComponent.js.map +1 -0
- package/lib/module/GamificationEmbedViewNativeComponent.js +5 -0
- package/lib/module/GamificationEmbedViewNativeComponent.js.map +1 -0
- package/lib/module/GamificationLoyaltyViewNativeComponent.js +5 -0
- package/lib/module/GamificationLoyaltyViewNativeComponent.js.map +1 -0
- package/lib/module/NativeHydraLib.js +7 -0
- package/lib/module/NativeHydraLib.js.map +1 -0
- package/lib/module/components/GamificationBannerView.js +10 -0
- package/lib/module/components/GamificationBannerView.js.map +1 -0
- package/lib/module/components/GamificationEmbedView.js +10 -0
- package/lib/module/components/GamificationEmbedView.js.map +1 -0
- package/lib/module/components/GamificationLoyaltyView.js +10 -0
- package/lib/module/components/GamificationLoyaltyView.js.map +1 -0
- package/lib/module/hydra-apis/Hydra.js +37 -0
- package/lib/module/hydra-apis/Hydra.js.map +1 -0
- package/lib/module/hydra-apis/HydraCore.js +36 -0
- package/lib/module/hydra-apis/HydraCore.js.map +1 -0
- package/lib/module/hydra-apis/HydraInAppMessaging.js +18 -0
- package/lib/module/hydra-apis/HydraInAppMessaging.js.map +1 -0
- package/lib/module/hydra-apis/HydraInbox.js +23 -0
- package/lib/module/hydra-apis/HydraInbox.js.map +1 -0
- package/lib/module/hydra-apis/HydraInboxUI.js +12 -0
- package/lib/module/hydra-apis/HydraInboxUI.js.map +1 -0
- package/lib/module/hydra-apis/HydraNativeEventEmitter.js +127 -0
- package/lib/module/hydra-apis/HydraNativeEventEmitter.js.map +1 -0
- package/lib/module/hydra-apis/HydraPushNotification.js +15 -0
- package/lib/module/hydra-apis/HydraPushNotification.js.map +1 -0
- package/lib/module/index.js +36 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/HydraAccountConfig.js +36 -0
- package/lib/module/models/HydraAccountConfig.js.map +1 -0
- package/lib/module/models/HydraFirebaseRemoteConfigKeys.js +35 -0
- package/lib/module/models/HydraFirebaseRemoteConfigKeys.js.map +1 -0
- package/lib/module/models/HydraGeoConfig.js +19 -0
- package/lib/module/models/HydraGeoConfig.js.map +1 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppButtonComponent.js +21 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppButtonComponent.js.map +1 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppComponentStyle.js +21 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppComponentStyle.js.map +1 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.js +35 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.js.map +1 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppMessage.js +55 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppMessage.js.map +1 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppTemplateType.js +62 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppTemplateType.js.map +1 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppTextComponent.js +16 -0
- package/lib/module/models/HydraInAppMessage/HydraInAppTextComponent.js.map +1 -0
- package/lib/module/models/HydraLogLevel.js +12 -0
- package/lib/module/models/HydraLogLevel.js.map +1 -0
- package/lib/module/models/HydraNativeEvent.js +23 -0
- package/lib/module/models/HydraNativeEvent.js.map +1 -0
- package/lib/module/models/HydraNotification/HydraNotification.js +65 -0
- package/lib/module/models/HydraNotification/HydraNotification.js.map +1 -0
- package/lib/module/models/HydraNotification/HydraNotificationBody.js +20 -0
- package/lib/module/models/HydraNotification/HydraNotificationBody.js.map +1 -0
- package/lib/module/models/HydraNotification/HydraNotificationCta.js +18 -0
- package/lib/module/models/HydraNotification/HydraNotificationCta.js.map +1 -0
- package/lib/module/models/HydraNotification/HydraNotificationCtaType.js +58 -0
- package/lib/module/models/HydraNotification/HydraNotificationCtaType.js.map +1 -0
- package/lib/module/models/HydraNotification/HydraNotificationExpandedDetails.js +20 -0
- package/lib/module/models/HydraNotification/HydraNotificationExpandedDetails.js.map +1 -0
- package/lib/module/models/HydraNotification/HydraNotificationGateway.js +9 -0
- package/lib/module/models/HydraNotification/HydraNotificationGateway.js.map +1 -0
- package/lib/module/models/HydraPushPreferences.js +15 -0
- package/lib/module/models/HydraPushPreferences.js.map +1 -0
- package/lib/module/models/HydraUserDetails.js +21 -0
- package/lib/module/models/HydraUserDetails.js.map +1 -0
- package/lib/module/models/HydraVisitorInfo.js +14 -0
- package/lib/module/models/HydraVisitorInfo.js.map +1 -0
- package/lib/module/models/NonHydraNotification.js +13 -0
- package/lib/module/models/NonHydraNotification.js.map +1 -0
- package/lib/module/models/UserState.js +37 -0
- package/lib/module/models/UserState.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/GamificationBannerViewNativeComponent.d.ts +7 -0
- package/lib/typescript/commonjs/src/GamificationBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/GamificationEmbedViewNativeComponent.d.ts +7 -0
- package/lib/typescript/commonjs/src/GamificationEmbedViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/GamificationLoyaltyViewNativeComponent.d.ts +7 -0
- package/lib/typescript/commonjs/src/GamificationLoyaltyViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NativeHydraLib.d.ts +46 -0
- package/lib/typescript/commonjs/src/NativeHydraLib.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/GamificationBannerView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/GamificationBannerView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/GamificationEmbedView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/GamificationEmbedView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/GamificationLoyaltyView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/GamificationLoyaltyView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hydra-apis/Hydra.d.ts +15 -0
- package/lib/typescript/commonjs/src/hydra-apis/Hydra.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraCore.d.ts +18 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraCore.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraInAppMessaging.d.ts +8 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraInAppMessaging.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraInbox.d.ts +9 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraInbox.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraInboxUI.d.ts +5 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraInboxUI.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraNativeEventEmitter.d.ts +35 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraNativeEventEmitter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraPushNotification.d.ts +6 -0
- package/lib/typescript/commonjs/src/hydra-apis/HydraPushNotification.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +37 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraAccountConfig.d.ts +14 -0
- package/lib/typescript/commonjs/src/models/HydraAccountConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraFirebaseRemoteConfigKeys.d.ts +13 -0
- package/lib/typescript/commonjs/src/models/HydraFirebaseRemoteConfigKeys.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraGeoConfig.d.ts +14 -0
- package/lib/typescript/commonjs/src/models/HydraGeoConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppButtonComponent.d.ts +16 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppButtonComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppComponentStyle.d.ts +10 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppComponentStyle.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.d.ts +9 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppMessage.d.ts +29 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppMessage.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppTemplateType.d.ts +15 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppTemplateType.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppTextComponent.d.ts +11 -0
- package/lib/typescript/commonjs/src/models/HydraInAppMessage/HydraInAppTextComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraLogLevel.d.ts +9 -0
- package/lib/typescript/commonjs/src/models/HydraLogLevel.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraNativeEvent.d.ts +20 -0
- package/lib/typescript/commonjs/src/models/HydraNativeEvent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotification.d.ts +32 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotification.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationBody.d.ts +19 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationBody.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationCta.d.ts +13 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationCta.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationCtaType.d.ts +13 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationCtaType.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationExpandedDetails.d.ts +19 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationExpandedDetails.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationGateway.d.ts +6 -0
- package/lib/typescript/commonjs/src/models/HydraNotification/HydraNotificationGateway.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraPushPreferences.d.ts +10 -0
- package/lib/typescript/commonjs/src/models/HydraPushPreferences.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraUserDetails.d.ts +16 -0
- package/lib/typescript/commonjs/src/models/HydraUserDetails.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/HydraVisitorInfo.d.ts +6 -0
- package/lib/typescript/commonjs/src/models/HydraVisitorInfo.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/NonHydraNotification.d.ts +9 -0
- package/lib/typescript/commonjs/src/models/NonHydraNotification.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/models/UserState.d.ts +11 -0
- package/lib/typescript/commonjs/src/models/UserState.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/GamificationBannerViewNativeComponent.d.ts +7 -0
- package/lib/typescript/module/src/GamificationBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/GamificationEmbedViewNativeComponent.d.ts +7 -0
- package/lib/typescript/module/src/GamificationEmbedViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/GamificationLoyaltyViewNativeComponent.d.ts +7 -0
- package/lib/typescript/module/src/GamificationLoyaltyViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeHydraLib.d.ts +46 -0
- package/lib/typescript/module/src/NativeHydraLib.d.ts.map +1 -0
- package/lib/typescript/module/src/components/GamificationBannerView.d.ts +6 -0
- package/lib/typescript/module/src/components/GamificationBannerView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/GamificationEmbedView.d.ts +6 -0
- package/lib/typescript/module/src/components/GamificationEmbedView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/GamificationLoyaltyView.d.ts +6 -0
- package/lib/typescript/module/src/components/GamificationLoyaltyView.d.ts.map +1 -0
- package/lib/typescript/module/src/hydra-apis/Hydra.d.ts +15 -0
- package/lib/typescript/module/src/hydra-apis/Hydra.d.ts.map +1 -0
- package/lib/typescript/module/src/hydra-apis/HydraCore.d.ts +18 -0
- package/lib/typescript/module/src/hydra-apis/HydraCore.d.ts.map +1 -0
- package/lib/typescript/module/src/hydra-apis/HydraInAppMessaging.d.ts +8 -0
- package/lib/typescript/module/src/hydra-apis/HydraInAppMessaging.d.ts.map +1 -0
- package/lib/typescript/module/src/hydra-apis/HydraInbox.d.ts +9 -0
- package/lib/typescript/module/src/hydra-apis/HydraInbox.d.ts.map +1 -0
- package/lib/typescript/module/src/hydra-apis/HydraInboxUI.d.ts +5 -0
- package/lib/typescript/module/src/hydra-apis/HydraInboxUI.d.ts.map +1 -0
- package/lib/typescript/module/src/hydra-apis/HydraNativeEventEmitter.d.ts +35 -0
- package/lib/typescript/module/src/hydra-apis/HydraNativeEventEmitter.d.ts.map +1 -0
- package/lib/typescript/module/src/hydra-apis/HydraPushNotification.d.ts +6 -0
- package/lib/typescript/module/src/hydra-apis/HydraPushNotification.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +37 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraAccountConfig.d.ts +14 -0
- package/lib/typescript/module/src/models/HydraAccountConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraFirebaseRemoteConfigKeys.d.ts +13 -0
- package/lib/typescript/module/src/models/HydraFirebaseRemoteConfigKeys.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraGeoConfig.d.ts +14 -0
- package/lib/typescript/module/src/models/HydraGeoConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppButtonComponent.d.ts +16 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppButtonComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppComponentStyle.d.ts +10 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppComponentStyle.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.d.ts +9 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppMessage.d.ts +29 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppMessage.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppTemplateType.d.ts +15 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppTemplateType.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppTextComponent.d.ts +11 -0
- package/lib/typescript/module/src/models/HydraInAppMessage/HydraInAppTextComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraLogLevel.d.ts +9 -0
- package/lib/typescript/module/src/models/HydraLogLevel.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraNativeEvent.d.ts +20 -0
- package/lib/typescript/module/src/models/HydraNativeEvent.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotification.d.ts +32 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotification.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationBody.d.ts +19 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationBody.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationCta.d.ts +13 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationCta.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationCtaType.d.ts +13 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationCtaType.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationExpandedDetails.d.ts +19 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationExpandedDetails.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationGateway.d.ts +6 -0
- package/lib/typescript/module/src/models/HydraNotification/HydraNotificationGateway.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraPushPreferences.d.ts +10 -0
- package/lib/typescript/module/src/models/HydraPushPreferences.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraUserDetails.d.ts +16 -0
- package/lib/typescript/module/src/models/HydraUserDetails.d.ts.map +1 -0
- package/lib/typescript/module/src/models/HydraVisitorInfo.d.ts +6 -0
- package/lib/typescript/module/src/models/HydraVisitorInfo.d.ts.map +1 -0
- package/lib/typescript/module/src/models/NonHydraNotification.d.ts +9 -0
- package/lib/typescript/module/src/models/NonHydraNotification.d.ts.map +1 -0
- package/lib/typescript/module/src/models/UserState.d.ts +11 -0
- package/lib/typescript/module/src/models/UserState.d.ts.map +1 -0
- package/package.json +225 -0
- package/react-native-hydra-lib.podspec +256 -0
- package/react-native.config.js +33 -0
- package/sbom.spdx.json +544 -0
- package/scripts/HydraPods.rb +151 -0
- package/scripts/generate-sbom.js +367 -0
- package/scripts/hydra-podspecs/HydraCore.podspec +13 -0
- package/scripts/hydra-podspecs/HydraInAppMessage.podspec +15 -0
- package/scripts/hydra-podspecs/HydraInboxCore.podspec +15 -0
- package/scripts/hydra-podspecs/HydraInboxUI.podspec +15 -0
- package/scripts/hydra-podspecs/HydraPushNotification.podspec +14 -0
- package/scripts/hydra-podspecs/HydraPushNotificationServiceExtension.podspec +15 -0
- package/src/GamificationBannerViewNativeComponent.ts +10 -0
- package/src/GamificationEmbedViewNativeComponent.ts +10 -0
- package/src/GamificationLoyaltyViewNativeComponent.ts +10 -0
- package/src/NativeHydraLib.ts +81 -0
- package/src/components/GamificationBannerView.tsx +10 -0
- package/src/components/GamificationEmbedView.tsx +10 -0
- package/src/components/GamificationLoyaltyView.tsx +10 -0
- package/src/hydra-apis/Hydra.ts +52 -0
- package/src/hydra-apis/HydraCore.ts +76 -0
- package/src/hydra-apis/HydraInAppMessaging.ts +25 -0
- package/src/hydra-apis/HydraInbox.ts +33 -0
- package/src/hydra-apis/HydraInboxUI.ts +10 -0
- package/src/hydra-apis/HydraNativeEventEmitter.ts +216 -0
- package/src/hydra-apis/HydraPushNotification.ts +15 -0
- package/src/index.tsx +71 -0
- package/src/models/HydraAccountConfig.ts +45 -0
- package/src/models/HydraFirebaseRemoteConfigKeys.ts +43 -0
- package/src/models/HydraGeoConfig.ts +27 -0
- package/src/models/HydraInAppMessage/HydraInAppButtonComponent.ts +27 -0
- package/src/models/HydraInAppMessage/HydraInAppComponentStyle.ts +24 -0
- package/src/models/HydraInAppMessage/HydraInAppFeedbackSelectionType.ts +35 -0
- package/src/models/HydraInAppMessage/HydraInAppMessage.ts +89 -0
- package/src/models/HydraInAppMessage/HydraInAppTemplateType.ts +57 -0
- package/src/models/HydraInAppMessage/HydraInAppTextComponent.ts +18 -0
- package/src/models/HydraLogLevel.ts +8 -0
- package/src/models/HydraNativeEvent.ts +19 -0
- package/src/models/HydraNotification/HydraNotification.ts +97 -0
- package/src/models/HydraNotification/HydraNotificationBody.ts +23 -0
- package/src/models/HydraNotification/HydraNotificationCta.ts +20 -0
- package/src/models/HydraNotification/HydraNotificationCtaType.ts +59 -0
- package/src/models/HydraNotification/HydraNotificationExpandedDetails.ts +28 -0
- package/src/models/HydraNotification/HydraNotificationGateway.ts +5 -0
- package/src/models/HydraPushPreferences.ts +16 -0
- package/src/models/HydraUserDetails.ts +31 -0
- package/src/models/HydraVisitorInfo.ts +14 -0
- package/src/models/NonHydraNotification.ts +15 -0
- package/src/models/UserState.ts +33 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
//
|
|
2
|
+
// HydraCore.swift
|
|
3
|
+
// react-native-hydra-lib
|
|
4
|
+
//
|
|
5
|
+
// Created by Sandesh Kumar Jain on 23/12/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import UIKit
|
|
10
|
+
import HydraCore
|
|
11
|
+
import React
|
|
12
|
+
import HydraPushNotification
|
|
13
|
+
import FirebaseRemoteConfig
|
|
14
|
+
|
|
15
|
+
@objc public final class HydraSDKCore : NSObject, HydraGamificationDelegate{
|
|
16
|
+
public func gamificationDidInitialize() {
|
|
17
|
+
Logger.debug("gamificationDidInitialize")
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public func gamificationDidFail(_ error: any Error) {
|
|
21
|
+
Logger.debug("gamificationDidFail \(error)")
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public func gamificationDidLoadEntryPoints(
|
|
25
|
+
_ entryPoints: [HydraCore.HydraGamificationEntryPoint]
|
|
26
|
+
) {
|
|
27
|
+
Logger.debug("gamingDidLoadEntryPoints \(entryPoints)")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public func gamificationDidOpenCampaign(_ campaignId: String) {
|
|
31
|
+
Logger.debug("gamificationDidOpenCampaign \(campaignId)")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public func gamificationDidCloseCampaign(_ campaignId: String) {
|
|
35
|
+
Logger.debug("gamificationDidCloseCampaign \(campaignId)")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public func gamificationDidEmitAnalyticsEvent(
|
|
39
|
+
_ name: String,
|
|
40
|
+
payload: [String : Any]
|
|
41
|
+
) {
|
|
42
|
+
Logger.debug("gamificationDidEmitAnalyticsEvent \(name) \(payload)")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public func gamificationWidgetHeightChanged(
|
|
46
|
+
entryPointId: String,
|
|
47
|
+
height: CGFloat
|
|
48
|
+
) {
|
|
49
|
+
Logger.debug("gamificationWidgetHeightChanged \(entryPointId) \(height)")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public func gamificationRequestedDeeplink(_ url: String) {
|
|
53
|
+
Logger.debug("gamificationRequestedDeeplink \(url)")
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@objc public static let shared = HydraSDKCore()
|
|
58
|
+
|
|
59
|
+
@objc public static func isPushNotificationEnabled() -> Bool {
|
|
60
|
+
guard let path = Bundle.main.url(forResource: "HydraConfig", withExtension: "plist"),
|
|
61
|
+
let data = try? Data(contentsOf: path),
|
|
62
|
+
let hydraConfigDict = try? PropertyListSerialization.propertyList(from: data, options: .mutableContainers, format: nil) as? [String : Any]
|
|
63
|
+
else {
|
|
64
|
+
return true
|
|
65
|
+
}
|
|
66
|
+
return (hydraConfigDict["enable_push_notification"] as? Bool) ?? true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var hydra : HydraCore.Hydra? = nil
|
|
70
|
+
var lastUsedHydraConfig : HydraNativeRemoteConfig? = nil
|
|
71
|
+
// Screen name queued before hydra was ready; replayed after init.
|
|
72
|
+
private var pendingGamificationScreen: String? = nil
|
|
73
|
+
|
|
74
|
+
private override init(){
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private func ensureTrailingSlash(_ url: String) -> String {
|
|
79
|
+
if url.isEmpty {
|
|
80
|
+
return url
|
|
81
|
+
}
|
|
82
|
+
return url.hasSuffix("/") ? url : url + "/"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private func ensureHttps(_ url: String) -> String {
|
|
86
|
+
if url.isEmpty {
|
|
87
|
+
return url
|
|
88
|
+
}
|
|
89
|
+
if url.hasPrefix("http://") {
|
|
90
|
+
return url.replacingOccurrences(of: "http://", with: "https://")
|
|
91
|
+
}
|
|
92
|
+
return url
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
fileprivate func createHydraInstance(_ hydraRemoteConfig: HydraNativeRemoteConfig) {
|
|
96
|
+
if let path = Bundle.main.url(forResource: "HydraConfig", withExtension: "plist"),
|
|
97
|
+
let data = try? Data(contentsOf:path),
|
|
98
|
+
let hydraConfigDict =
|
|
99
|
+
try? PropertyListSerialization.propertyList(from: data, options: .mutableContainers, format: nil) as? [String : Any]{
|
|
100
|
+
|
|
101
|
+
let accountId : String = hydraRemoteConfig.accountId
|
|
102
|
+
let baseUrl : String = ensureTrailingSlash(ensureHttps(hydraRemoteConfig.baseUrl))
|
|
103
|
+
let sslPublicKey: String = hydraRemoteConfig.sslPublicKey
|
|
104
|
+
let remoteLogLevel : Int = hydraRemoteConfig.remoteLogLevel
|
|
105
|
+
let orgId : String? = hydraRemoteConfig.orgId
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
let supportsPushNotification : Bool = (hydraConfigDict["SUPPORTS_PUSH_NOTIFICATION"] as? Bool) ?? true
|
|
109
|
+
let logLevelsDict : [String : Int] = (hydraConfigDict["LOG_LEVELS"] as? [String: Int]) ?? [:]
|
|
110
|
+
|
|
111
|
+
let consoleLogLevel : Int = hydraConfigDict["console_log_level"] as? Int ?? logLevelsDict["CONSOLE"] ?? 1
|
|
112
|
+
let enableInAppMessaging : Bool = (hydraConfigDict["enable_in_app_messaging"] as? Bool) ?? (hydraConfigDict["ENABLE_IN_APP_MESSAGING"] as? Bool) ?? false
|
|
113
|
+
let enableSelfHandlingInInApp : Bool = (hydraConfigDict["enable_in_app_messaging_in_react_native"] as? Bool) ?? false
|
|
114
|
+
|
|
115
|
+
let enableInboxAPI : Bool = (hydraConfigDict["enable_inbox_api"] as? Bool) ?? (hydraConfigDict["ENABLE_INBOX_API"] as? Bool) ?? false
|
|
116
|
+
let enableInboxUI : Bool = (hydraConfigDict["enable_inbox_ui"] as? Bool) ?? (hydraConfigDict["ENABLE_INBOX_UI"] as? Bool) ?? false
|
|
117
|
+
|
|
118
|
+
let useDefaultInboxUIConfig : Bool = (hydraConfigDict["use_default_inbox_ui_config"] as? Bool) ?? (hydraConfigDict["USE_DEFAULT_INBOX_UI_CONFIG"] as? Bool) ?? true
|
|
119
|
+
|
|
120
|
+
let inboxUIConfigDict : [String : Any]? = !useDefaultInboxUIConfig ? hydraConfigDict["INBOX_UI_CONFIG"] as? [String : Any] : nil
|
|
121
|
+
|
|
122
|
+
let maxNotificationCount = (hydraConfigDict["max_notification_count"] as? Int)
|
|
123
|
+
|
|
124
|
+
Logger.updateLogLevel(level: getSdkLogLevel(debugLevel: consoleLogLevel), for: HydraLoggerType.console)
|
|
125
|
+
|
|
126
|
+
do{
|
|
127
|
+
Logger.debug("HydraLib: HydraCore.initializeHydra: Creating HydraConfiguration")
|
|
128
|
+
let gamificationKey = hydraRemoteConfig.gamificationKey//"d01d1d13e6e5c8a8daaadbb8f96fa054379347e3"
|
|
129
|
+
let gamificationRegion = hydraRemoteConfig.gamificationRegion
|
|
130
|
+
let gamificationBaseUrl = hydraRemoteConfig.gamificationBaseUrl
|
|
131
|
+
let config: HydraConfiguration = try HydraConfiguration(
|
|
132
|
+
accountID: accountId,
|
|
133
|
+
customerId: HydraCore.Hydra.getSharedUserDefaults()?.customerId() ?? "",
|
|
134
|
+
server:
|
|
135
|
+
.genericServer(baseUrl, sslPublicKey, [0,5,10,30,120]),
|
|
136
|
+
orgID: orgId,
|
|
137
|
+
gamificationWriteKey: gamificationKey,
|
|
138
|
+
gamificationRegion: gamificationRegion,
|
|
139
|
+
gamificationBaseURL: gamificationBaseUrl
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
Logger.debug("HydraLib: HydraCore.initializeHydra: Generating Hydra Instance")
|
|
143
|
+
hydra = try HydraCore.Hydra.generate(
|
|
144
|
+
with: config,
|
|
145
|
+
supportsPushNotifications: supportsPushNotification,
|
|
146
|
+
consoleLogLevel: getSdkLogLevel(debugLevel: consoleLogLevel),
|
|
147
|
+
remoteLogLevel: getSdkLogLevel(debugLevel: remoteLogLevel)
|
|
148
|
+
)
|
|
149
|
+
hydra?.setGamificationDelegate(self)
|
|
150
|
+
lastUsedHydraConfig = hydraRemoteConfig
|
|
151
|
+
// Replay any gamification screen that was registered before SDK was ready.
|
|
152
|
+
if let pending = pendingGamificationScreen {
|
|
153
|
+
pendingGamificationScreen = nil
|
|
154
|
+
DispatchQueue.main.async { [weak self] in
|
|
155
|
+
self?.hydra?.gamificationScreenAppeared(pending)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
NotificationCore.shared.update(sdk: hydra!)
|
|
160
|
+
|
|
161
|
+
HydraPushNotification.shared.forceUpdateFcmToken()
|
|
162
|
+
Task{
|
|
163
|
+
try await Task.sleep(seconds: 1)
|
|
164
|
+
try await MainActor.run {
|
|
165
|
+
if enableInAppMessaging{
|
|
166
|
+
Logger.debug("HydraLib: HydraCore.initializeHydra: Initializing InAppMessaging")
|
|
167
|
+
try HydraInAppMessages.shared.initializeInAppMessagingCore(hydraConfig: config, selfHandlingEnabled: enableSelfHandlingInInApp)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if enableInboxAPI || enableInboxUI{
|
|
171
|
+
Logger.debug("HydraLib: HydraCore.initializeHydra: Initializing InboxCore")
|
|
172
|
+
try HydraInbox.shared.initializeInboxCore(hydraConfig: config, maxNotificationCount: maxNotificationCount)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if enableInboxUI{
|
|
176
|
+
Logger.debug("HydraLib: HydraCore.initializeHydra: Initializing InboxUI")
|
|
177
|
+
HydraInboxUI.shared.initializeInboxUICore(inboxUIConfigDict: inboxUIConfigDict)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
catch{
|
|
184
|
+
let errorMesssage = "Error initializing Hydra SDK"
|
|
185
|
+
Logger.error("HydraLib: HydraCore.initializeHydra: \(errorMesssage)")
|
|
186
|
+
sendHydraSdkInitializationResultEvent(false, errorMesssage)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else{
|
|
190
|
+
let errorMesssage = "HydraConfig.plist not found"
|
|
191
|
+
Logger.error("HydraLib: HydraCore.initializeHydra: Error initializing Hydra SDK: \(errorMesssage)")
|
|
192
|
+
sendHydraSdkInitializationResultEvent(false, errorMesssage)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
func initializeHydra(_ hydraRemoteConfig : HydraNativeRemoteConfig){
|
|
197
|
+
Logger.updateLogLevel(level: getSdkLogLevel(debugLevel: 2), for: HydraLoggerType.console)
|
|
198
|
+
createHydraInstance(hydraRemoteConfig)
|
|
199
|
+
registerAnonymousFlowCallbacks()
|
|
200
|
+
sendHydraSdkInitializationResultEvent(hydra != nil)
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
func registerAnonymousFlowCallbacks(){
|
|
205
|
+
hydra?.setConfigFetchedCallback { isVisitorFlowEnabled in
|
|
206
|
+
HydraEventEmitter.shared.sendEvent(HydraEventType.ON_CONFIG_FETCHED_CALLBACK.rawValue, body: isVisitorFlowEnabled)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
hydra?.setVisitorSessionReadyCallback {
|
|
210
|
+
HydraEventEmitter.shared.sendEvent(HydraEventType.ON_VISITOR_SESSION_READY.rawValue, body: nil)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
hydra?.setLegacyFlowReadyCallback {
|
|
214
|
+
HydraEventEmitter.shared.sendEvent(HydraEventType.ON_LEGACY_FLOW_READY.rawValue, body: nil)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
hydra?.setUserStateChangedCallback { userState in
|
|
218
|
+
HydraEventEmitter.shared.sendEvent(HydraEventType.ON_USER_STATE_CHANGED.rawValue, body: String(describing: userState))
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
func sendHydraSdkInitializationResultEvent( _ success : Bool, _ errorMessage : String? = nil){
|
|
223
|
+
var eventAttributes : [String : Any] = [:]
|
|
224
|
+
eventAttributes["success"] = success
|
|
225
|
+
if let errorMessage = errorMessage{
|
|
226
|
+
eventAttributes["errorMessage"] = errorMessage
|
|
227
|
+
}
|
|
228
|
+
HydraEventEmitter.shared.sendEvent(HydraEventType.ON_HYDRA_SDK_INITIALIZATION_RESULT.rawValue, body: eventAttributes)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private func getSdkLogLevel(debugLevel: Int) -> LogLevel {
|
|
232
|
+
switch(debugLevel) {
|
|
233
|
+
case 0:
|
|
234
|
+
return LogLevel.none;
|
|
235
|
+
case 1:
|
|
236
|
+
return LogLevel.error;
|
|
237
|
+
case 2:
|
|
238
|
+
return LogLevel.warning;
|
|
239
|
+
case 3:
|
|
240
|
+
return LogLevel.info;
|
|
241
|
+
case 4:
|
|
242
|
+
return LogLevel.debug;
|
|
243
|
+
case 5:
|
|
244
|
+
return LogLevel.debug
|
|
245
|
+
default:
|
|
246
|
+
return LogLevel.none;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private func clearPersistentData() {
|
|
251
|
+
HydraCore.Hydra.getSharedUserDefaults()?.removeObject(forKey: HydraRNConstants.hydraRemoreConfig)
|
|
252
|
+
HydraCore.Hydra.getSharedUserDefaults()?.removeObject(forKey: HydraRNConstants.hydraFirebaseRemoteConfigKeys)
|
|
253
|
+
Logger.debug("HydraCore.clearPersistentData: Cleared all persistent data")
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@objc public func setHydraAccountConfig(_ hydraAccountConfig : [String:Any], resolve : RCTPromiseResolveBlock?,
|
|
257
|
+
reject : RCTPromiseRejectBlock?) -> Void{
|
|
258
|
+
let accountIdToSet : String? = hydraAccountConfig["accountId"] as? String
|
|
259
|
+
let baseUrlToSet : String? = hydraAccountConfig["baseUrl"] as? String
|
|
260
|
+
let sslPublicKeyToSet : String? = hydraAccountConfig["sslPublicKey"] as? String
|
|
261
|
+
let remoteDebugLevelToSet : Int? = hydraAccountConfig["remoteDebugLevel"] as? Int
|
|
262
|
+
let orgIdToSet : String? = hydraAccountConfig["orgId"] as? String
|
|
263
|
+
let gamificationKeyToSet : String? = hydraAccountConfig["gamificationKey"] as? String
|
|
264
|
+
let gamificationRegionToSet : String? = hydraAccountConfig["gamificationRegion"] as? String
|
|
265
|
+
let gamificationBaseUrlToSet : String? = hydraAccountConfig["gamificationBaseUrl"] as? String
|
|
266
|
+
if lastUsedHydraConfig != nil && lastUsedHydraConfig?.accountId == accountIdToSet && lastUsedHydraConfig?.baseUrl == baseUrlToSet && lastUsedHydraConfig?.sslPublicKey == sslPublicKeyToSet && lastUsedHydraConfig?.remoteLogLevel == remoteDebugLevelToSet && lastUsedHydraConfig?.orgId == orgIdToSet && lastUsedHydraConfig?.gamificationKey == gamificationKeyToSet && lastUsedHydraConfig?.gamificationRegion == gamificationRegionToSet && lastUsedHydraConfig?.gamificationBaseUrl == gamificationBaseUrlToSet{
|
|
267
|
+
clearPersistentData()
|
|
268
|
+
persistHydraConfig()
|
|
269
|
+
resolve?(true)
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
let hydraRemoteConfig : HydraNativeRemoteConfig? = HydraNativeRemoteConfig(accountId: accountIdToSet!, baseUrl: baseUrlToSet!, sslPublicKey: sslPublicKeyToSet!, remoteLogLevel: remoteDebugLevelToSet!, orgId: orgIdToSet, gamificationKey: gamificationKeyToSet, gamificationRegion: gamificationRegionToSet, gamificationBaseUrl: gamificationBaseUrlToSet)
|
|
274
|
+
if(hydraRemoteConfig == nil){
|
|
275
|
+
resolve?(false)
|
|
276
|
+
return
|
|
277
|
+
}
|
|
278
|
+
hydra = nil
|
|
279
|
+
createHydraInstance(hydraRemoteConfig!)
|
|
280
|
+
if hydra != nil{
|
|
281
|
+
lastUsedHydraConfig = hydraRemoteConfig
|
|
282
|
+
clearPersistentData()
|
|
283
|
+
persistHydraConfig()
|
|
284
|
+
resolve?(true)
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
resolve?(false)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
func persistHydraConfig(){
|
|
292
|
+
let dict = lastUsedHydraConfig?.toDictionary()
|
|
293
|
+
if dict != nil{
|
|
294
|
+
HydraCore.Hydra.getSharedUserDefaults()?.set(dict, forKey: HydraRNConstants.hydraRemoreConfig)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
func persistHydraConfigKeys(_ remoteConfigKeys: HydraNativeFirebaseRemoteConfigKeys){
|
|
299
|
+
let dict = remoteConfigKeys.toDictionary()
|
|
300
|
+
if dict != nil{
|
|
301
|
+
HydraCore.Hydra.getSharedUserDefaults()?.set(dict, forKey: HydraRNConstants.hydraFirebaseRemoteConfigKeys)
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
func processFirebaseRemoteConfig(_ remoteConfigKeys: HydraNativeFirebaseRemoteConfigKeys) -> HydraNativeRemoteConfig?{
|
|
306
|
+
let remoteConfig = RemoteConfig.remoteConfig()
|
|
307
|
+
let remoteConfigAccountId : String? = remoteConfig.configValue(forKey: remoteConfigKeys.keyForAccountId).stringValue
|
|
308
|
+
let remoteConfigBaseUrl : String? = remoteConfig.configValue(forKey: remoteConfigKeys.keyForBaseUrl).stringValue
|
|
309
|
+
let remoteConfigSslPublicKey : String? = remoteConfig.configValue(forKey: remoteConfigKeys.keyForSsl).stringValue
|
|
310
|
+
let remoteLogLevelStr : String? = remoteConfig.configValue(forKey: remoteConfigKeys.keyForRemoteLogLevel).stringValue
|
|
311
|
+
let remoteConfigOrgId : String? = remoteConfigKeys.keyForOrgId.flatMap { key in
|
|
312
|
+
let value = remoteConfig.configValue(forKey: key).stringValue
|
|
313
|
+
return value.isEmpty ? nil : value
|
|
314
|
+
}
|
|
315
|
+
let remoteConfigGamificationKey : String? = remoteConfigKeys.keyForGamificationKey.flatMap { key in
|
|
316
|
+
let value = remoteConfig.configValue(forKey: key).stringValue
|
|
317
|
+
return value.isEmpty ? nil : value
|
|
318
|
+
}
|
|
319
|
+
let remoteConfigGamificationRegion : String? = remoteConfigKeys.keyForGamificationRegion.flatMap { key in
|
|
320
|
+
let value = remoteConfig.configValue(forKey: key).stringValue
|
|
321
|
+
return value.isEmpty ? nil : value
|
|
322
|
+
}
|
|
323
|
+
let remoteConfigGamificationBaseUrl : String? = remoteConfigKeys.keyForGamificationBaseUrl.flatMap { key in
|
|
324
|
+
let value = remoteConfig.configValue(forKey: key).stringValue
|
|
325
|
+
return value.isEmpty ? nil : value
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
let accountId = remoteConfigAccountId ?? ""
|
|
329
|
+
let baseUrl = remoteConfigBaseUrl ?? ""
|
|
330
|
+
let sslPublicKey = remoteConfigSslPublicKey ?? ""
|
|
331
|
+
let remoteLogLevel : Int = Int(remoteLogLevelStr ?? "") ?? 0
|
|
332
|
+
|
|
333
|
+
if(accountId.isEmpty){
|
|
334
|
+
Logger.error("HydraApplicationDelegate: application: didFinishLaunchingWithOptions: remoteConfig: Please add a key in firebase remote config with name \"\(remoteConfigKeys.keyForAccountId ?? "")\"")
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if(baseUrl.isEmpty){
|
|
338
|
+
Logger.error("HydraApplicationDelegate: application: didFinishLaunchingWithOptions: remoteConfig: Please add a key in firebase remote config with name \"\(remoteConfigKeys.keyForBaseUrl ?? "")\"")
|
|
339
|
+
}
|
|
340
|
+
if(sslPublicKey.isEmpty){
|
|
341
|
+
Logger.error("HydraApplicationDelegate: application: didFinishLaunchingWithOptions: remoteConfig: Please add a key in firebase remote config with name \"\(remoteConfigKeys.keyForSsl ?? "")\"")
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
let hydraRemoteConfig = HydraNativeRemoteConfig(
|
|
345
|
+
accountId: accountId,
|
|
346
|
+
baseUrl: baseUrl,
|
|
347
|
+
sslPublicKey: sslPublicKey,
|
|
348
|
+
remoteLogLevel: remoteLogLevel,
|
|
349
|
+
orgId: remoteConfigOrgId,
|
|
350
|
+
gamificationKey: remoteConfigGamificationKey,
|
|
351
|
+
gamificationRegion: remoteConfigGamificationRegion,
|
|
352
|
+
gamificationBaseUrl: remoteConfigGamificationBaseUrl
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
return hydraRemoteConfig
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
@objc public func setFirebaseRemoteConfigKeys(_ remoteConfigKeys : [String:Any], resolve : RCTPromiseResolveBlock?,
|
|
359
|
+
reject : RCTPromiseRejectBlock?) -> Void{
|
|
360
|
+
let keyForAccountId : String? = remoteConfigKeys["keyForAccountId"] as? String
|
|
361
|
+
let keyForBaseUrl : String? = remoteConfigKeys["keyForBaseUrl"] as? String
|
|
362
|
+
let keyForSsl : String? = remoteConfigKeys["keyForSsl"] as? String
|
|
363
|
+
let keyForRemoteDebugLevel : String? = remoteConfigKeys["keyForRemoteDebugLevel"] as? String
|
|
364
|
+
let keyForOrgId : String? = remoteConfigKeys["keyForOrgId"] as? String
|
|
365
|
+
let keyForGamificationKey : String? = remoteConfigKeys["keyForGamificationKey"] as? String
|
|
366
|
+
let keyForGamificationRegion : String? = remoteConfigKeys["keyForGamificationRegion"] as? String
|
|
367
|
+
let keyForGamificationBaseUrl : String? = remoteConfigKeys["keyForGamificationBaseUrl"] as? String
|
|
368
|
+
|
|
369
|
+
guard let keyForAccountId = keyForAccountId, !keyForAccountId.isEmpty,
|
|
370
|
+
let keyForBaseUrl = keyForBaseUrl, !keyForBaseUrl.isEmpty,
|
|
371
|
+
let keyForSsl = keyForSsl, !keyForSsl.isEmpty,
|
|
372
|
+
let keyForRemoteDebugLevel = keyForRemoteDebugLevel, !keyForRemoteDebugLevel.isEmpty else {
|
|
373
|
+
Logger.error("HydraCore: setFirebaseRemoteConfigKeys: Error Invlid keys, Please provide valid firebase remote config keys")
|
|
374
|
+
reject?("Error setting firebase remote config keys", "Please provide valid firebase remote config keys", nil)
|
|
375
|
+
return
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
let hydraFirebaseRemoteConfigKeys : HydraNativeFirebaseRemoteConfigKeys = HydraNativeFirebaseRemoteConfigKeys(
|
|
379
|
+
keyForAccountId: keyForAccountId,
|
|
380
|
+
keyForBaseUrl: keyForBaseUrl,
|
|
381
|
+
keyForSsl: keyForSsl,
|
|
382
|
+
keyForRemoteLogLevel: keyForRemoteDebugLevel,
|
|
383
|
+
keyForOrgId: keyForOrgId,
|
|
384
|
+
keyForGamificationKey: keyForGamificationKey,
|
|
385
|
+
keyForGamificationRegion: keyForGamificationRegion,
|
|
386
|
+
keyForGamificationBaseUrl: keyForGamificationBaseUrl)
|
|
387
|
+
|
|
388
|
+
let hydraRemoteConfig = processFirebaseRemoteConfig(hydraFirebaseRemoteConfigKeys)
|
|
389
|
+
if hydraRemoteConfig == nil{
|
|
390
|
+
Logger.error("HydraCore: setFirebaseRemoteConfigKeys: Error getting values from firebase remote config keys")
|
|
391
|
+
reject?("Error setting firebase remote config keys", "Error getting values from firebase remote config keys", nil)
|
|
392
|
+
}
|
|
393
|
+
else{
|
|
394
|
+
if lastUsedHydraConfig != nil && lastUsedHydraConfig?.accountId == hydraRemoteConfig?.accountId && lastUsedHydraConfig?.baseUrl == hydraRemoteConfig?.baseUrl && lastUsedHydraConfig?.sslPublicKey == hydraRemoteConfig?.sslPublicKey && lastUsedHydraConfig?.remoteLogLevel == hydraRemoteConfig?.remoteLogLevel && lastUsedHydraConfig?.orgId == hydraRemoteConfig?.orgId && lastUsedHydraConfig?.gamificationKey == hydraRemoteConfig?.gamificationKey && lastUsedHydraConfig?.gamificationRegion == hydraRemoteConfig?.gamificationRegion && lastUsedHydraConfig?.gamificationBaseUrl == hydraRemoteConfig?.gamificationBaseUrl{
|
|
395
|
+
clearPersistentData()
|
|
396
|
+
persistHydraConfigKeys(hydraFirebaseRemoteConfigKeys)
|
|
397
|
+
Logger.debug("HydraCore: setFirebaseRemoteConfigKeys: Already using these account config values")
|
|
398
|
+
resolve?(true)
|
|
399
|
+
}
|
|
400
|
+
else{
|
|
401
|
+
hydra = nil
|
|
402
|
+
createHydraInstance(hydraRemoteConfig!)
|
|
403
|
+
if hydra != nil{
|
|
404
|
+
lastUsedHydraConfig = hydraRemoteConfig
|
|
405
|
+
clearPersistentData()
|
|
406
|
+
persistHydraConfigKeys(hydraFirebaseRemoteConfigKeys)
|
|
407
|
+
Logger.debug("HydraCore: setFirebaseRemoteConfigKeys: Completed successfully")
|
|
408
|
+
resolve?(true)
|
|
409
|
+
}
|
|
410
|
+
else{
|
|
411
|
+
Logger.error("HydraCore: setFirebaseRemoteConfigKeys: Error initializing hydra instance")
|
|
412
|
+
reject?("Error setting firebase remote config keys", "Error initializing hydra instance", nil)
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
@objc public func update(geoConfig : [String:Any], resolve : RCTPromiseResolveBlock?,
|
|
419
|
+
reject : RCTPromiseRejectBlock?) -> Void{
|
|
420
|
+
|
|
421
|
+
guard hydra != nil else{
|
|
422
|
+
Logger.error("HydraCore: updateGeoConfig: hydra instance not initialized")
|
|
423
|
+
reject?("Error Updating GeoData", "Hydra instance not initialized", getHydraNotFoundError())
|
|
424
|
+
return
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
let country: String? = geoConfig["country"] as? String
|
|
428
|
+
let countryCode: String? = geoConfig["countryCode"] as? String
|
|
429
|
+
let city: String? = geoConfig["city"] as? String
|
|
430
|
+
let timeZone: String? = geoConfig["timeZone"] as? String
|
|
431
|
+
let geoData : GeoData = GeoData(country: country, countryCode: countryCode, city: city, timeZone: timeZone)
|
|
432
|
+
hydra?.update(geoData: geoData)
|
|
433
|
+
resolve?(true)
|
|
434
|
+
Logger.debug("HydraCore: update:geoCinfig: not implemented yet")
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
@objc public func signIn(userDetails : [String:Any], customData : [String:Any]?, resolve : RCTPromiseResolveBlock?,
|
|
438
|
+
reject : RCTPromiseRejectBlock?) -> Void{
|
|
439
|
+
guard hydra != nil else{
|
|
440
|
+
Logger.error("HydraCore: signIn: hydra instance not initialized")
|
|
441
|
+
reject?("Error Signing In", "Hydra instance not initialized", getHydraNotFoundError())
|
|
442
|
+
return
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
let customerId : String? = userDetails["customerId"] as? String
|
|
446
|
+
let firstName : String? = userDetails["firstName"] as? String
|
|
447
|
+
let lastName : String? = userDetails["lastName"] as? String
|
|
448
|
+
let email : String? = userDetails["email"] as? String
|
|
449
|
+
let phone : String? = userDetails["phone"] as? String
|
|
450
|
+
|
|
451
|
+
guard let customerId = customerId else{
|
|
452
|
+
Logger.error("HydraCore: signIn: customeId can not be nil")
|
|
453
|
+
reject?("Error Signing In", "customeId can not be nil", nil)
|
|
454
|
+
return
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// updateCustomerId(customerId)
|
|
458
|
+
|
|
459
|
+
let userInfo : UserDetails = UserDetails(
|
|
460
|
+
customerId: customerId,
|
|
461
|
+
firstName: firstName,
|
|
462
|
+
lastName: lastName,
|
|
463
|
+
email: email,
|
|
464
|
+
phone: phone)
|
|
465
|
+
|
|
466
|
+
hydra?.reportUserSignIn(data: userInfo, customData: customData ?? [:])
|
|
467
|
+
resolve?(true)
|
|
468
|
+
Logger.debug("HydraCore: signIn: completed successfully")
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
@objc public func signUp(userDetails : [String:Any], customData : [String:Any]?, resolve : RCTPromiseResolveBlock?,
|
|
472
|
+
reject : RCTPromiseRejectBlock?) -> Void{
|
|
473
|
+
guard hydra != nil else{
|
|
474
|
+
Logger.error("HydraCore: signUp: hydra instance not initialized")
|
|
475
|
+
reject?("Error Signing Up", "Hydra instance not initialized", getHydraNotFoundError())
|
|
476
|
+
return
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
let customerId : String? = userDetails["customerId"] as? String
|
|
480
|
+
let firstName : String? = userDetails["firstName"] as? String
|
|
481
|
+
let lastName : String? = userDetails["lastName"] as? String
|
|
482
|
+
let email : String? = userDetails["email"] as? String
|
|
483
|
+
let phone : String? = userDetails["phone"] as? String
|
|
484
|
+
|
|
485
|
+
guard let customerId = customerId else{
|
|
486
|
+
Logger.error("HydraCore: signUp: customeId can not be nil")
|
|
487
|
+
reject?("Error Signing Up", "customeId can not be nil", nil)
|
|
488
|
+
return
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// updateCustomerId(customerId)
|
|
492
|
+
|
|
493
|
+
let userInfo : UserDetails = UserDetails(
|
|
494
|
+
customerId: customerId,
|
|
495
|
+
firstName: firstName,
|
|
496
|
+
lastName: lastName,
|
|
497
|
+
email: email,
|
|
498
|
+
phone: phone)
|
|
499
|
+
|
|
500
|
+
hydra?.reportUserSignUP(data: userInfo, customData: customData ?? [:])
|
|
501
|
+
resolve?(true)
|
|
502
|
+
Logger.debug("HydraCore: signUp: completed successfully")
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
@objc public func signOut(customerId : String, resolve : RCTPromiseResolveBlock?,
|
|
507
|
+
reject : RCTPromiseRejectBlock?) -> Void{
|
|
508
|
+
guard hydra != nil else{
|
|
509
|
+
Logger.error("HydraCore: signOut: hydra instance not initialized")
|
|
510
|
+
reject?("Error Signing out", "Hydra instance not initialized", getHydraNotFoundError())
|
|
511
|
+
return
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
hydra?.reportUserSignOut(customData: ["customerId": customerId])
|
|
515
|
+
updateCustomerId(nil)
|
|
516
|
+
resolve?(true)
|
|
517
|
+
Logger.debug("HydraCore: signOut: completed successfully")
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
@objc public func update(userDetails : [String:Any], customData : [String:Any]?, subscriptions : [Any]?, resolve : RCTPromiseResolveBlock?, reject : RCTPromiseRejectBlock? ) -> Void{
|
|
521
|
+
guard hydra != nil else{
|
|
522
|
+
Logger.error("HydraCore: updateUserDetails: hydra instance not initialized")
|
|
523
|
+
reject?("Error Updating UserDetails", "Hydra instance not initialized", getHydraNotFoundError())
|
|
524
|
+
return
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
let customerId : String? = userDetails["customerId"] as? String
|
|
528
|
+
let firstName : String? = userDetails["firstName"] as? String
|
|
529
|
+
let lastName : String? = userDetails["lastName"] as? String
|
|
530
|
+
let email : String? = userDetails["email"] as? String
|
|
531
|
+
let phone : String? = userDetails["phone"] as? String
|
|
532
|
+
|
|
533
|
+
guard let customerId = customerId else{
|
|
534
|
+
Logger.error("HydraCore: updateUserDetails: customeId can not be nil")
|
|
535
|
+
reject?("Error Updating UserDetails", "customeId can not be nil", nil)
|
|
536
|
+
return
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
updateCustomerId(customerId)
|
|
540
|
+
|
|
541
|
+
let userInfo : UserDetails = UserDetails(
|
|
542
|
+
customerId: customerId,
|
|
543
|
+
firstName: firstName,
|
|
544
|
+
lastName: lastName,
|
|
545
|
+
email: email,
|
|
546
|
+
phone: phone)
|
|
547
|
+
|
|
548
|
+
hydra?.reportUserProfileUpdate(data: userInfo, customData: customData ?? [:], subscriptions: subscriptions)
|
|
549
|
+
resolve?(true)
|
|
550
|
+
Logger.debug("HydraCore: updateUserDetails: completed successfully")
|
|
551
|
+
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
@objc public func reportUserEvent(eventName : String, attributes : [String:Any]?, resolve : RCTPromiseResolveBlock?, reject : RCTPromiseRejectBlock?) -> Void {
|
|
555
|
+
guard hydra != nil else{
|
|
556
|
+
Logger.error("HydraCore: reportUserEvent: hydra instance not initialized")
|
|
557
|
+
reject?("Error reporting user event", "Hydra instance not initialized", getHydraNotFoundError())
|
|
558
|
+
return
|
|
559
|
+
}
|
|
560
|
+
hydra?.reportBehavioralEvent(name: eventName, customAttributes: attributes ?? [:])
|
|
561
|
+
// hydra?.reportUserEvent(name: eventName, customAttributes: attributes ?? [:])
|
|
562
|
+
resolve?(true)
|
|
563
|
+
Logger.debug("HydraCore: reportUserEvent: completed successfully")
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
@objc public func identify(userDetails : [String:Any], customData : [String:Any]?, resolve : RCTPromiseResolveBlock?,
|
|
567
|
+
reject : RCTPromiseRejectBlock?) -> Void {
|
|
568
|
+
signIn(userDetails: userDetails, customData: customData, resolve: resolve, reject: reject)
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
@objc public func track(eventName : String, attributes : [String:Any]?, resolve : RCTPromiseResolveBlock?,
|
|
572
|
+
reject : RCTPromiseRejectBlock?) -> Void {
|
|
573
|
+
reportUserEvent(eventName: eventName, attributes: attributes, resolve: resolve, reject: reject)
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
@objc public func reset(customerId : String, resolve : RCTPromiseResolveBlock?,
|
|
577
|
+
reject : RCTPromiseRejectBlock?) -> Void {
|
|
578
|
+
signOut(customerId: customerId, resolve: resolve, reject: reject)
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
@objc public func isSdkInitialized(resolve : RCTPromiseResolveBlock?, reject : RCTPromiseRejectBlock?) -> Void {
|
|
582
|
+
let isInitialized = hydra != nil
|
|
583
|
+
Logger.debug("HydraCore: isSdkInitialized: SDK initialization status: \(isInitialized)")
|
|
584
|
+
resolve?(isInitialized)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
@objc public func getCurrentUserState(resolve : RCTPromiseResolveBlock?, reject : RCTPromiseRejectBlock?) -> Void {
|
|
588
|
+
let userState = hydra?.getCurrentUserState()
|
|
589
|
+
let stateString = userState?.rawValue
|
|
590
|
+
Logger.debug("HydraCore: getCurrentUserState: Current user state: \(stateString ?? "nil")")
|
|
591
|
+
resolve?(stateString)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
@objc public func getVisitorDetails(resolve : RCTPromiseResolveBlock?, reject : RCTPromiseRejectBlock?) -> Void {
|
|
595
|
+
let visitorInfo = hydra?.getUserDetails()
|
|
596
|
+
if let visitorInfo = visitorInfo {
|
|
597
|
+
let visitorDict: [String: String?] = [
|
|
598
|
+
"visitorId": visitorInfo.visitorId
|
|
599
|
+
]
|
|
600
|
+
Logger.debug("HydraCore: getVisitorDetails: Visitor details retrieved")
|
|
601
|
+
resolve?(visitorDict)
|
|
602
|
+
} else {
|
|
603
|
+
Logger.debug("HydraCore: getVisitorDetails: Visitor details not available")
|
|
604
|
+
resolve?(nil)
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
@objc public func isVisitorFlowEnabled(resolve : RCTPromiseResolveBlock?, reject : RCTPromiseRejectBlock?) -> Void {
|
|
609
|
+
let isEnabled = hydra?.isVisitorFlowEnabled() ?? false
|
|
610
|
+
Logger.debug("HydraCore: isVisitorFlowEnabled: Visitor flow enabled: \(isEnabled)")
|
|
611
|
+
resolve?(isEnabled)
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
@objc public func update(pushPreferences : [String : Any], resolve : RCTPromiseResolveBlock?, reject : RCTPromiseRejectBlock? ) -> Void{
|
|
615
|
+
guard hydra != nil else{
|
|
616
|
+
Logger.error("HydraCore: updatePushPreferences: hydra instance not initialized")
|
|
617
|
+
reject?("Error updating push preferences", "Hydra instance not initialized", getHydraNotFoundError())
|
|
618
|
+
return
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
let promPushOpted = pushPreferences["promPushOpted"] as? Bool ?? false
|
|
622
|
+
let transPushOpted = pushPreferences["transPushOpted"] as? Bool ?? false
|
|
623
|
+
hydra?.updateUserNotificationSettingsFor(promoPushOpted: promPushOpted, transPushOpted: transPushOpted)
|
|
624
|
+
hydra?.reportUserPreferencesUpdate()
|
|
625
|
+
resolve?(true)
|
|
626
|
+
Logger.debug("HydraCore: updatePushPreferences: completed successfully")
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
private func updateCustomerId(_ customerId : String?){
|
|
632
|
+
if let customerId = customerId{
|
|
633
|
+
hydra?.update(customerID: customerId)
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
private func getHydraNotFoundError() -> NSError {
|
|
638
|
+
return NSError(domain: "com.reactnative.ccapillary",
|
|
639
|
+
code: 400,
|
|
640
|
+
userInfo: [NSLocalizedDescriptionKey: "Hydra instance not initialized"]
|
|
641
|
+
)
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
@MainActor @objc public func gamificationScreenAppeared(_ screenName: String, resolve: RCTPromiseResolveBlock?, reject: RCTPromiseRejectBlock?) -> Void {
|
|
645
|
+
guard hydra != nil else {
|
|
646
|
+
// SDK not ready yet — queue for replay after init.
|
|
647
|
+
pendingGamificationScreen = screenName
|
|
648
|
+
resolve?(true)
|
|
649
|
+
return
|
|
650
|
+
}
|
|
651
|
+
hydra?.gamificationScreenAppeared(screenName)
|
|
652
|
+
resolve?(true)
|
|
653
|
+
Logger.debug("HydraCore: gamificationScreenAppeared: completed successfully")
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
@MainActor @objc public func gamificationScreenDisappeared(_ screenName: String, resolve: RCTPromiseResolveBlock?, reject: RCTPromiseRejectBlock?) -> Void {
|
|
657
|
+
pendingGamificationScreen = nil
|
|
658
|
+
hydra?.gamificationScreenDisappeared(screenName)
|
|
659
|
+
|
|
660
|
+
resolve?(true)
|
|
661
|
+
Logger.debug("HydraCore: gamificationScreenDisappeared: completed successfully")
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
@MainActor @objc public func createGamificationBannerView(bannerId: String) -> UIView? {
|
|
665
|
+
return hydra?.gamificationBannerView(bannerId: bannerId) { height in
|
|
666
|
+
Logger.debug("banner height changed: \(height)")
|
|
667
|
+
HydraEventEmitter.shared.sendEvent(HydraEventType.ON_GAMIFICATION_VIEW_HEIGHT_CHANGED.rawValue, body: ["height": height, "entryPointId": bannerId])
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
@MainActor @objc public func createGamificationEmbedView(embedId: String) -> UIView? {
|
|
672
|
+
return hydra?
|
|
673
|
+
.gamificationEmbedView(
|
|
674
|
+
embedId: embedId) { height in
|
|
675
|
+
Logger.debug("height changed: \(height)")
|
|
676
|
+
HydraEventEmitter.shared.sendEvent(HydraEventType.ON_GAMIFICATION_VIEW_HEIGHT_CHANGED.rawValue, body: ["height": height, "entryPointId": embedId])
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
@MainActor @objc public func createGamificationLoyaltyView(loyaltyId: String) -> UIView? {
|
|
681
|
+
return hydra?.gamificationLoyaltyView(embedId: loyaltyId) { height in
|
|
682
|
+
Logger.debug("height changed: \(height)")
|
|
683
|
+
HydraEventEmitter.shared
|
|
684
|
+
.sendEvent(
|
|
685
|
+
HydraEventType.ON_GAMIFICATION_VIEW_HEIGHT_CHANGED.rawValue,
|
|
686
|
+
body: ["height": height, "entryPointId": loyaltyId]
|
|
687
|
+
)
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
@objc public func setCapToken(_ token: String, resolve: RCTPromiseResolveBlock?, reject: RCTPromiseRejectBlock?) {
|
|
692
|
+
hydra?.setCapToken(token)
|
|
693
|
+
resolve?(nil)
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
@objc public func logError(errorMsg : String){
|
|
697
|
+
Logger.error(errorMsg)
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
@objc public func logDebug(debugMsg : String){
|
|
701
|
+
Logger.debug(debugMsg)
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
@objc public func getNotificationName() -> String {
|
|
705
|
+
return HydraGamificationUI.dataReloadedNotificationName
|
|
706
|
+
}
|
|
707
|
+
}
|