@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,860 @@
|
|
|
1
|
+
package com.hydralib.hydrasdk
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.os.Handler
|
|
6
|
+
import android.os.Looper
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import androidx.annotation.RestrictTo
|
|
9
|
+
import com.capillary.hydra.android.sdk.FcmConfig
|
|
10
|
+
import com.capillary.hydra.android.sdk.HydraAPI
|
|
11
|
+
import com.capillary.hydra.android.sdk.HydraConfig
|
|
12
|
+
import com.capillary.hydra.android.sdk.InAppConfig
|
|
13
|
+
import com.capillary.hydra.android.sdk.NotificationCenterConfig
|
|
14
|
+
import com.capillary.hydra.android.sdk.NotificationConfig
|
|
15
|
+
import com.capillary.hydra.android.sdk.UserPreferences
|
|
16
|
+
import com.capillary.hydra.android.sdk.utils.Logger
|
|
17
|
+
import com.capillary.hydra.gamification.GamificationFlowManager
|
|
18
|
+
import com.capillary.hydra.gamification.GamificationRegion
|
|
19
|
+
import com.capillary.hydra.gamification.ui.GamificationUIManager
|
|
20
|
+
import com.facebook.react.ReactActivity
|
|
21
|
+
import com.facebook.react.bridge.Arguments
|
|
22
|
+
import com.facebook.react.bridge.Promise
|
|
23
|
+
import com.facebook.react.bridge.ReadableArray
|
|
24
|
+
import com.facebook.react.bridge.ReadableMap
|
|
25
|
+
import com.facebook.react.bridge.WritableMap
|
|
26
|
+
import com.google.firebase.ktx.Firebase
|
|
27
|
+
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
|
28
|
+
import com.google.gson.Gson
|
|
29
|
+
import com.google.gson.JsonSyntaxException
|
|
30
|
+
import com.google.gson.reflect.TypeToken
|
|
31
|
+
import com.hydralib.eventemitter.HydraEventEmitter
|
|
32
|
+
import com.hydralib.eventemitter.HydraEventType
|
|
33
|
+
import com.hydralib.nativeapis.HydraFirebaseRemoteConfigKeys
|
|
34
|
+
import com.hydralib.nativeapis.HydraRemoteConfig
|
|
35
|
+
import com.hydralib.utils.RNHydraPreferencesManager
|
|
36
|
+
import com.hydralib.utils.getDrawableId
|
|
37
|
+
import okio.IOException
|
|
38
|
+
|
|
39
|
+
@RestrictTo(RestrictTo.Scope.LIBRARY)
|
|
40
|
+
object HydraCore {
|
|
41
|
+
@SuppressLint("StaticFieldLeak")
|
|
42
|
+
var hydraAPI: HydraAPI? = null
|
|
43
|
+
private set
|
|
44
|
+
var appContext: Context? = null
|
|
45
|
+
private set
|
|
46
|
+
private var lastUsedHydraRemoteConfig: HydraRemoteConfig? = null
|
|
47
|
+
private var gamificationUIManager: GamificationUIManager? = null
|
|
48
|
+
private var flowManager: GamificationFlowManager? = null
|
|
49
|
+
|
|
50
|
+
internal fun getFlowManager(): GamificationFlowManager? = flowManager
|
|
51
|
+
internal fun getGamificationUIManager(): GamificationUIManager? = gamificationUIManager
|
|
52
|
+
var curReactActivity : ReactActivity? = null
|
|
53
|
+
// Screen name queued before gamificationUIManager was ready; replayed after init.
|
|
54
|
+
// Guarded by gamificationLock rather than just @Volatile — the write in
|
|
55
|
+
// gamificationScreenAppeared and the read-and-clear in initHydraInstance are each a
|
|
56
|
+
// check-then-act, and @Volatile alone only guarantees visibility, not atomicity between them.
|
|
57
|
+
private var pendingGamificationScreen: String? = null
|
|
58
|
+
private val gamificationLock = Any()
|
|
59
|
+
|
|
60
|
+
var firebaseRemoteConfigActivated = false
|
|
61
|
+
|
|
62
|
+
private fun ensureTrailingSlash(url: String): String {
|
|
63
|
+
return if (url.isEmpty()) {
|
|
64
|
+
url
|
|
65
|
+
} else {
|
|
66
|
+
if (url.endsWith("/")) url else "$url/"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private fun ensureHttps(url: String): String {
|
|
71
|
+
return if (url.isEmpty()) {
|
|
72
|
+
url
|
|
73
|
+
} else if (url.startsWith("http://")) {
|
|
74
|
+
url.replace("http://", "https://")
|
|
75
|
+
} else {
|
|
76
|
+
url
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Sets the app context early in initialization to prevent race conditions.
|
|
82
|
+
* This should be called before any async operations that might delay initHydra().
|
|
83
|
+
*/
|
|
84
|
+
@RestrictTo(RestrictTo.Scope.LIBRARY)
|
|
85
|
+
fun setAppContext(context: Context) {
|
|
86
|
+
appContext = context
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private fun clearPersistentData() {
|
|
90
|
+
if (appContext != null) {
|
|
91
|
+
RNHydraPreferencesManager.removeHydraRemoteConfig(appContext!!)
|
|
92
|
+
RNHydraPreferencesManager.removeHydraFirebaseRemoteConfigKeys(appContext!!)
|
|
93
|
+
Logger.d("HydraCore.clearPersistentData", "Cleared all persistent data")
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fun initHydra(appContext: Context, hydraRemoteConfig: HydraRemoteConfig) {
|
|
98
|
+
HydraCore.appContext = appContext
|
|
99
|
+
initHydraInstance(hydraRemoteConfig)
|
|
100
|
+
|
|
101
|
+
Logger.d("HydraCore.initHydra", "registering listeners")
|
|
102
|
+
|
|
103
|
+
HydraPushNotification.registerListenersNotDependentOnAccountId()
|
|
104
|
+
registerAnonymousFlowCallbacks()
|
|
105
|
+
HydraPushNotification.registerHydraPushNotificationListener()
|
|
106
|
+
HydraInAppMessages.registerListener()
|
|
107
|
+
HydraInboxUI.registerListener()
|
|
108
|
+
|
|
109
|
+
sendHydraInitializationResultEvent(true)
|
|
110
|
+
|
|
111
|
+
Logger.i("HydraCore.initHydra", "HydraSDK initialized successfully")
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private fun initHydraInstance(hydraRemoteConfig: HydraRemoteConfig) {
|
|
115
|
+
try {
|
|
116
|
+
|
|
117
|
+
val configFileName = if (appContext!!.assets.list("capillary")?.contains("hydra-config.json")
|
|
118
|
+
?: false
|
|
119
|
+
) "capillary/hydra-config.json" else "hydra-config.json"
|
|
120
|
+
val fileInString: String =
|
|
121
|
+
appContext!!.assets.open(configFileName).bufferedReader().use { it.readText() }
|
|
122
|
+
val gson = Gson()
|
|
123
|
+
val type = object : TypeToken<Map<String, Any>>() {}.type
|
|
124
|
+
val hydraConfigMap = gson.fromJson<Map<String, Any>>(fileInString, type)
|
|
125
|
+
Log.i("HydraCore.initHydra", "hydraConfigMap = $hydraConfigMap")
|
|
126
|
+
|
|
127
|
+
val accountId: String = hydraRemoteConfig.accountId
|
|
128
|
+
val baseUrl: String = ensureTrailingSlash(ensureHttps(hydraRemoteConfig.baseURL))
|
|
129
|
+
val sslPublicKey: String = hydraRemoteConfig.sslPublicKey
|
|
130
|
+
val remoteLogLevel: Int = hydraRemoteConfig.remoteDebugLevel
|
|
131
|
+
val orgId: String? = hydraRemoteConfig.orgId
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
val logLevelsMap: Map<*, *> =
|
|
135
|
+
hydraConfigMap["log_levels"] as Map<*, *>? ?: mapOf<String, Int>()
|
|
136
|
+
val pushNotificationMap: Map<*, *> =
|
|
137
|
+
hydraConfigMap["push_notification"] as Map<*, *>? ?: mapOf<String, Any>()
|
|
138
|
+
val inboxUIMap: Map<*, *> = hydraConfigMap["inbox_ui"] as Map<*, *>? ?: mapOf<String, Any>()
|
|
139
|
+
|
|
140
|
+
val captureViewPortDetails: Boolean =
|
|
141
|
+
hydraConfigMap["capture_view_port_details"] as Boolean? ?: true
|
|
142
|
+
val disableAppLaunchEvent: Boolean =
|
|
143
|
+
hydraConfigMap["disable_app_launch_event"] as Boolean? ?: false
|
|
144
|
+
|
|
145
|
+
val enableInAppMessaging: Boolean =
|
|
146
|
+
hydraConfigMap["enable_in_app_messaging"] as Boolean? ?: false
|
|
147
|
+
val enableSelfHandledInAppMessaging: Boolean =
|
|
148
|
+
hydraConfigMap["enable_in_app_messaging_in_react_native"] as Boolean? ?: false
|
|
149
|
+
val enableInboxUI: Boolean = hydraConfigMap["enable_inbox_ui"] as Boolean? ?: false
|
|
150
|
+
|
|
151
|
+
val consoleDebugLevel: Int = (hydraConfigMap["console"] as Double?)?.toInt()
|
|
152
|
+
?: (logLevelsMap["console"] as Double?)?.toInt() ?: 4
|
|
153
|
+
|
|
154
|
+
val enableHydraSDKFirebaseRegistration: Boolean =
|
|
155
|
+
hydraConfigMap["enable_hydra_sdk_firebase_registration"] as Boolean?
|
|
156
|
+
?: pushNotificationMap["enable_hydra_sdk_firebase_registration"] as Boolean? ?: true
|
|
157
|
+
|
|
158
|
+
val enableMultipleNotificationsInDrawer: Boolean =
|
|
159
|
+
pushNotificationMap["enable_multiple_notifications_in_drawer"] as Boolean? ?: true
|
|
160
|
+
|
|
161
|
+
val maxNotificationCountInInbox: Int =
|
|
162
|
+
(hydraConfigMap["max_notification_count"] as Double?)?.toInt()
|
|
163
|
+
?: (inboxUIMap["max_notification_count"] as Double?)?.toInt() ?: 200
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
val fcmConfig = FcmConfig(enableHydraSDKFirebaseRegistration)
|
|
167
|
+
|
|
168
|
+
val notificationSmallIconResId =
|
|
169
|
+
getDrawableId(appContext!!, "hydra_notification_small_icon", "drawable")
|
|
170
|
+
val notificationColorResId = getDrawableId(appContext!!, "hydra_notification_color", "color")
|
|
171
|
+
if (notificationSmallIconResId == 0) {
|
|
172
|
+
Log.e(
|
|
173
|
+
"HydraCore.initHydraInstance",
|
|
174
|
+
"Could not initialize Push Notifications, notification icon is missing, please add an icon with name hydra_notification_small_icon in android/app/src/main/res/drawable folder"
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
if (notificationColorResId == 0) {
|
|
178
|
+
Log.e(
|
|
179
|
+
"HydraCore.initHydraInstance",
|
|
180
|
+
"Could not initialize Push Notifications, notification color is missing, please add a color with name hydra_notification_color in android/app/src/main/res/values/colors.xml"
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
var notificationConfig: NotificationConfig? = null
|
|
185
|
+
if (notificationColorResId > 0 && notificationSmallIconResId > 0) {
|
|
186
|
+
notificationConfig = NotificationConfig(
|
|
187
|
+
notificationSmallIconResId,
|
|
188
|
+
notificationColorResId,
|
|
189
|
+
enableMultipleNotificationsInDrawer,
|
|
190
|
+
isCrossPlatformEnabled = true
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var inAppConfig: InAppConfig? = null
|
|
195
|
+
if (enableInAppMessaging) {
|
|
196
|
+
val inAppPlaceholderResId =
|
|
197
|
+
getDrawableId(appContext!!, "hydra_in_app_placeholder", "drawable")
|
|
198
|
+
if (inAppPlaceholderResId == 0) {
|
|
199
|
+
Log.e(
|
|
200
|
+
"HydraCore.initHydraInstance",
|
|
201
|
+
"Could not initialize InAppMessaging, the placeholder icon is missing, please add an icon with name hydra_in_app_placeholder in android/app/src/main/res/drawable folder"
|
|
202
|
+
)
|
|
203
|
+
} else {
|
|
204
|
+
inAppConfig = InAppConfig(inAppPlaceholderResId, enableSelfHandledInAppMessaging)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
var notificationCenterConfig: NotificationCenterConfig? = null
|
|
209
|
+
if (enableInboxUI) {
|
|
210
|
+
val inboxUIPlaceholderResId =
|
|
211
|
+
getDrawableId(appContext!!, "hydra_inbox_ui_placeholder", "drawable")
|
|
212
|
+
if (inboxUIPlaceholderResId == 0) {
|
|
213
|
+
Log.e(
|
|
214
|
+
"HydraCore.initHydraInstance",
|
|
215
|
+
"Could not initialize InboxUI, the placeholder icon is missing, please add an icon with name hydra_inbox_ui_placeholder in android/app/src/main/res/drawable folder"
|
|
216
|
+
)
|
|
217
|
+
} else {
|
|
218
|
+
notificationCenterConfig =
|
|
219
|
+
NotificationCenterConfig(inboxUIPlaceholderResId, maxNotificationCountInInbox)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
val hydraConfig: HydraConfig = HydraConfig.Builder(
|
|
224
|
+
appContext!!,
|
|
225
|
+
accountId,
|
|
226
|
+
orgId,
|
|
227
|
+
baseUrl,
|
|
228
|
+
sslPublicKey,
|
|
229
|
+
"",
|
|
230
|
+
"",
|
|
231
|
+
"",
|
|
232
|
+
captureViewPortDetails,
|
|
233
|
+
fcmConfig,
|
|
234
|
+
notificationConfig,
|
|
235
|
+
inAppConfig,
|
|
236
|
+
notificationCenterConfig,
|
|
237
|
+
disableAppLaunchEvent,
|
|
238
|
+
consoleDebugLevel - 1, //ReactNative Log level starts from 0, Android starts from -1
|
|
239
|
+
remoteLogLevel - 1 //ReactNative Log level starts from 0, Android starts from -1
|
|
240
|
+
).apply {
|
|
241
|
+
val cgWriteKey = hydraRemoteConfig.gamificationKey ?: ""
|
|
242
|
+
val cgRegion = hydraRemoteConfig.gamificationRegion ?: ""
|
|
243
|
+
val cgBaseUrl = hydraRemoteConfig.gamificationBaseUrl ?: ""
|
|
244
|
+
if (cgWriteKey.isNotEmpty() && cgRegion.isNotEmpty()) {
|
|
245
|
+
gamificationWriteKey(cgWriteKey)
|
|
246
|
+
try {
|
|
247
|
+
gamificationRegion(GamificationRegion.valueOf(cgRegion.uppercase()))
|
|
248
|
+
} catch (_: IllegalArgumentException) {
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (cgBaseUrl.isNotEmpty()) {
|
|
253
|
+
gamificationBaseUrl(cgBaseUrl)
|
|
254
|
+
}
|
|
255
|
+
}.build()
|
|
256
|
+
|
|
257
|
+
hydraAPI = HydraAPI.instanceWithConfig(appContext!!, hydraConfig)
|
|
258
|
+
|
|
259
|
+
hydraAPI?.getGamificationManager()?.let {
|
|
260
|
+
flowManager = it
|
|
261
|
+
// Synchronized against gamificationScreenAppeared's check-then-set so a screen name
|
|
262
|
+
// set concurrently with init can't be missed by this read-and-clear.
|
|
263
|
+
val pending = synchronized(gamificationLock) {
|
|
264
|
+
gamificationUIManager = GamificationUIManager(it, appContext!!)
|
|
265
|
+
pendingGamificationScreen.also { pendingGamificationScreen = null }
|
|
266
|
+
}
|
|
267
|
+
// Replay any screen that was registered before the manager was ready.
|
|
268
|
+
if (pending != null) {
|
|
269
|
+
Handler(Looper.getMainLooper()).post {
|
|
270
|
+
val act = curReactActivity
|
|
271
|
+
if (act != null) {
|
|
272
|
+
gamificationUIManager?.onScreenChanged(act, pending)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
lastUsedHydraRemoteConfig = hydraRemoteConfig
|
|
280
|
+
|
|
281
|
+
Logger.d(
|
|
282
|
+
"HydraCore.initHydraInstance",
|
|
283
|
+
"Hydra instance initialized with accountId: $accountId, baseUrl: $baseUrl, sslPublicKey: $sslPublicKey"
|
|
284
|
+
)
|
|
285
|
+
} catch (_: IOException) {
|
|
286
|
+
val errorMessage =
|
|
287
|
+
"Could not load hydra-config.json, save the config file to capillary folder"
|
|
288
|
+
|
|
289
|
+
sendHydraInitializationResultEvent(false, errorMessage)
|
|
290
|
+
|
|
291
|
+
Log.e(
|
|
292
|
+
"HydraCore.initHydraInstance",
|
|
293
|
+
errorMessage
|
|
294
|
+
)
|
|
295
|
+
} catch (_: JsonSyntaxException) {
|
|
296
|
+
val errorMessage = "hydra-config.json is not in correct format, please check the file"
|
|
297
|
+
sendHydraInitializationResultEvent(false, errorMessage)
|
|
298
|
+
|
|
299
|
+
Log.e("HydraCore.initHydraInstance", errorMessage)
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
fun sendHydraInitializationResultEvent(success: Boolean, errorMessage: String? = null) {
|
|
304
|
+
val resultMap = mutableMapOf<String, Any>()
|
|
305
|
+
resultMap["success"] = success
|
|
306
|
+
if (errorMessage != null) {
|
|
307
|
+
resultMap["errorMessage"] = errorMessage
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
HydraEventEmitter.sendEvent(
|
|
311
|
+
HydraEventType.ON_HYDRA_SDK_INITIALIZATION_RESULT,
|
|
312
|
+
resultMap
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
fun registerAnonymousFlowCallbacks(){
|
|
317
|
+
HydraAPI.setConfigFetchedCallback { isVisitorFlowEnabled ->
|
|
318
|
+
HydraEventEmitter.sendEvent(
|
|
319
|
+
HydraEventType.ON_CONFIG_FETCHED_CALLBACK,
|
|
320
|
+
isVisitorFlowEnabled
|
|
321
|
+
)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
HydraAPI.setLegacyFlowReadyCallback {
|
|
325
|
+
HydraEventEmitter.sendEvent(
|
|
326
|
+
HydraEventType.ON_LEGACY_FLOW_READY,
|
|
327
|
+
null
|
|
328
|
+
)
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
HydraAPI.setVisitorSessionReadyCallback {
|
|
332
|
+
HydraEventEmitter.sendEvent(
|
|
333
|
+
HydraEventType.ON_VISITOR_SESSION_READY,
|
|
334
|
+
null
|
|
335
|
+
)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
HydraAPI.setUserStateChangedCallback { userState ->
|
|
339
|
+
Logger.d("HydraCore.setUserStateChangedCallback", "User state changed callback triggered: ${userState.name}")
|
|
340
|
+
HydraEventEmitter.sendEvent(
|
|
341
|
+
HydraEventType.ON_USER_STATE_CHANGED,
|
|
342
|
+
userState.name
|
|
343
|
+
)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
fun setHydraAccountConfig(hydraAccountConfig: ReadableMap?, promise: Promise?) {
|
|
349
|
+
// Defensive null check to prevent crashes if called before initialization completes
|
|
350
|
+
if (appContext == null) {
|
|
351
|
+
Logger.e("HydraCore.setHydraAccountConfig", "Hydra SDK not initialized yet")
|
|
352
|
+
promise?.reject("Error", "Hydra SDK is still initializing. Please try again.", Throwable())
|
|
353
|
+
return
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
Logger.d("hydraAccountConfig", "Received account config: $hydraAccountConfig")
|
|
357
|
+
val accountIdToSet = hydraAccountConfig?.getString("accountId")
|
|
358
|
+
val baseUrlToSet = hydraAccountConfig?.getString("baseUrl")
|
|
359
|
+
val sslPublicKeyToSet = hydraAccountConfig?.getString("sslPublicKey")
|
|
360
|
+
val remoteDebugLevelToSet = hydraAccountConfig?.getInt("remoteDebugLevel")
|
|
361
|
+
val orgIdToSet = hydraAccountConfig?.getString("orgId")
|
|
362
|
+
val gamificationKeyToSet = hydraAccountConfig?.getString("gamificationKey")
|
|
363
|
+
val gamificationRegionToSet = hydraAccountConfig?.getString("gamificationRegion")
|
|
364
|
+
val gamificationBaseUrlToSet = hydraAccountConfig?.getString("gamificationBaseUrl")
|
|
365
|
+
|
|
366
|
+
if (accountIdToSet == null || accountIdToSet.isEmpty() || baseUrlToSet == null || baseUrlToSet.isEmpty() || sslPublicKeyToSet == null || sslPublicKeyToSet.isEmpty() || remoteDebugLevelToSet == null || remoteDebugLevelToSet < 0 || remoteDebugLevelToSet > 5) {
|
|
367
|
+
Logger.e("HydraCore.setHydraAccountConfig", "Invalid account config values")
|
|
368
|
+
promise?.reject("Error setting account config", "Invalid account config values", Throwable())
|
|
369
|
+
return
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (
|
|
373
|
+
lastUsedHydraRemoteConfig != null &&
|
|
374
|
+
lastUsedHydraRemoteConfig!!.accountId == accountIdToSet &&
|
|
375
|
+
lastUsedHydraRemoteConfig!!.sslPublicKey == sslPublicKeyToSet &&
|
|
376
|
+
lastUsedHydraRemoteConfig!!.baseURL == baseUrlToSet &&
|
|
377
|
+
lastUsedHydraRemoteConfig!!.remoteDebugLevel == remoteDebugLevelToSet &&
|
|
378
|
+
lastUsedHydraRemoteConfig!!.orgId == orgIdToSet &&
|
|
379
|
+
lastUsedHydraRemoteConfig!!.gamificationKey == gamificationKeyToSet &&
|
|
380
|
+
lastUsedHydraRemoteConfig!!.gamificationRegion == gamificationRegionToSet &&
|
|
381
|
+
lastUsedHydraRemoteConfig!!.gamificationBaseUrl == gamificationBaseUrlToSet
|
|
382
|
+
) {
|
|
383
|
+
clearPersistentData()
|
|
384
|
+
RNHydraPreferencesManager.saveHydraRemoteConfig(appContext!!, lastUsedHydraRemoteConfig!!)
|
|
385
|
+
Logger.d("HydraCore.setHydraAccountConfig", "Already using these account config values")
|
|
386
|
+
promise?.resolve(true)
|
|
387
|
+
return
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
val remoteConfig: HydraRemoteConfig = HydraRemoteConfig.Builder(
|
|
391
|
+
accountIdToSet,
|
|
392
|
+
baseUrlToSet,
|
|
393
|
+
sslPublicKeyToSet,
|
|
394
|
+
remoteDebugLevelToSet
|
|
395
|
+
).also { builder ->
|
|
396
|
+
orgIdToSet?.let { builder.orgId(it) }
|
|
397
|
+
gamificationKeyToSet?.let { builder.gamificationKey(it) }
|
|
398
|
+
gamificationRegionToSet?.let { builder.gamificationRegion(it) }
|
|
399
|
+
gamificationBaseUrlToSet?.let { builder.gamificationBaseUrl(it) }
|
|
400
|
+
}.build()
|
|
401
|
+
|
|
402
|
+
initHydraInstance(remoteConfig)
|
|
403
|
+
clearPersistentData()
|
|
404
|
+
RNHydraPreferencesManager.saveHydraRemoteConfig(appContext!!, remoteConfig)
|
|
405
|
+
HydraPushNotification.registerHydraPushNotificationListener()
|
|
406
|
+
HydraInAppMessages.registerListener()
|
|
407
|
+
HydraInboxUI.registerListener()
|
|
408
|
+
promise?.resolve(true)
|
|
409
|
+
Logger.d(
|
|
410
|
+
"HydraCore.setHydraAccountConfig",
|
|
411
|
+
"Updated account config successfully with accountId: $accountIdToSet, baseUrl: $baseUrlToSet, sslPublicKey: $sslPublicKeyToSet"
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@RestrictTo(RestrictTo.Scope.LIBRARY)
|
|
416
|
+
fun processFirebaseRemoteConfig(
|
|
417
|
+
hydraFirebaseRemoteConfigKeys: HydraFirebaseRemoteConfigKeys
|
|
418
|
+
): HydraRemoteConfig? {
|
|
419
|
+
val firebaseRemoteConfig = Firebase.remoteConfig
|
|
420
|
+
Log.d("HydraInitializer", "Processing remote config values")
|
|
421
|
+
|
|
422
|
+
val accountId = firebaseRemoteConfig.getString(hydraFirebaseRemoteConfigKeys.keyForAccountId)
|
|
423
|
+
val baseURL = firebaseRemoteConfig.getString(hydraFirebaseRemoteConfigKeys.keyForBaseURL)
|
|
424
|
+
val sslPublicKey = firebaseRemoteConfig.getString(hydraFirebaseRemoteConfigKeys.keyForSsl)
|
|
425
|
+
val remoteDebugLevelStr =
|
|
426
|
+
firebaseRemoteConfig.getString(hydraFirebaseRemoteConfigKeys.keyForRemoteDebugLevel)
|
|
427
|
+
val orgId = hydraFirebaseRemoteConfigKeys.keyForOrgId?.takeIf { it.isNotEmpty() }?.let {
|
|
428
|
+
firebaseRemoteConfig.getString(it).takeIf { value -> value.isNotEmpty() }
|
|
429
|
+
}
|
|
430
|
+
val gamificationKey = hydraFirebaseRemoteConfigKeys.keyForGamificationKey?.takeIf { it.isNotEmpty() }?.let {
|
|
431
|
+
firebaseRemoteConfig.getString(it).takeIf { value -> value.isNotEmpty() }
|
|
432
|
+
}
|
|
433
|
+
val gamificationRegion = hydraFirebaseRemoteConfigKeys.keyForGamificationRegion?.takeIf { it.isNotEmpty() }?.let {
|
|
434
|
+
firebaseRemoteConfig.getString(it).takeIf { value -> value.isNotEmpty() }
|
|
435
|
+
}
|
|
436
|
+
val gamificationBaseUrl = hydraFirebaseRemoteConfigKeys.keyForGamificationBaseUrl?.takeIf { it.isNotEmpty() }?.let {
|
|
437
|
+
firebaseRemoteConfig.getString(it).takeIf { value -> value.isNotEmpty() }
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
Log.d(
|
|
441
|
+
"HydraInitializer", """
|
|
442
|
+
Remote config values:
|
|
443
|
+
accountId: $accountId
|
|
444
|
+
baseURL: $baseURL
|
|
445
|
+
sslPublicKey: $sslPublicKey
|
|
446
|
+
remoteDebugLevel: $remoteDebugLevelStr
|
|
447
|
+
orgId: $orgId
|
|
448
|
+
""".trimIndent()
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
// Validate required values
|
|
452
|
+
if (accountId.isEmpty()) {
|
|
453
|
+
val errorMessage =
|
|
454
|
+
"Please add a key in firebase remote config with name \"hydra_account_id\" or pass the key name in initializeUsingFirebaseRemoteConfig"
|
|
455
|
+
Log.e("HydraInitializer", errorMessage)
|
|
456
|
+
sendHydraInitializationResultEvent(false, errorMessage)
|
|
457
|
+
return null
|
|
458
|
+
}
|
|
459
|
+
if (baseURL.isEmpty()) {
|
|
460
|
+
val errorMessage =
|
|
461
|
+
"Please add a key in firebase remote config with name \"hydra_base_url\" or pass the key name in initializeUsingFirebaseRemoteConfig"
|
|
462
|
+
Log.e("HydraInitializer", errorMessage)
|
|
463
|
+
sendHydraInitializationResultEvent(false, errorMessage)
|
|
464
|
+
return null
|
|
465
|
+
}
|
|
466
|
+
if (sslPublicKey.isEmpty()) {
|
|
467
|
+
val errorMessage =
|
|
468
|
+
"Please add a key in firebase remote config with name \"hydra_ssl_public_key\" or pass the key name in initializeUsingFirebaseRemoteConfig"
|
|
469
|
+
Log.e("HydraInitializer", errorMessage)
|
|
470
|
+
sendHydraInitializationResultEvent(false, errorMessage)
|
|
471
|
+
return null
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Initialize with the fetched values
|
|
475
|
+
HydraRemoteConfig.Builder(
|
|
476
|
+
accountId,
|
|
477
|
+
baseURL,
|
|
478
|
+
sslPublicKey,
|
|
479
|
+
remoteDebugLevelStr.toIntOrNull() ?: 0
|
|
480
|
+
).also { builder ->
|
|
481
|
+
orgId?.let { builder.orgId(it) }
|
|
482
|
+
gamificationKey?.let { builder.gamificationKey(it) }
|
|
483
|
+
gamificationRegion?.let { builder.gamificationRegion(it) }
|
|
484
|
+
gamificationBaseUrl?.let { builder.gamificationBaseUrl(it) }
|
|
485
|
+
}.build().let { remoteConfig ->
|
|
486
|
+
Logger.d("processRemoteConfig", "Remote config values: $remoteConfig")
|
|
487
|
+
return remoteConfig
|
|
488
|
+
}
|
|
489
|
+
return null
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
fun setFirebaseRemoteConfigKeys(
|
|
494
|
+
remoteConfigKeys: ReadableMap?,
|
|
495
|
+
promise: Promise?
|
|
496
|
+
) {
|
|
497
|
+
// Defensive null check to prevent crashes if called before initialization completes
|
|
498
|
+
if (appContext == null) {
|
|
499
|
+
Logger.e("HydraCore.setFirebaseRemoteConfigKeys", "Hydra SDK not initialized yet")
|
|
500
|
+
promise?.reject("Error", "Hydra SDK is still initializing. Please try again.", Throwable())
|
|
501
|
+
return
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
val keyForAccountId = remoteConfigKeys?.getString("keyForAccountId")
|
|
505
|
+
val keyForBaseUrl = remoteConfigKeys?.getString("keyForBaseUrl")
|
|
506
|
+
val keyForSsl = remoteConfigKeys?.getString("keyForSsl")
|
|
507
|
+
val keyForRemoteDebugLevel = remoteConfigKeys?.getString("keyForRemoteDebugLevel")
|
|
508
|
+
val keyForOrgId = remoteConfigKeys?.getString("keyForOrgId")
|
|
509
|
+
val keyForGamificationKey = remoteConfigKeys?.getString("keyForGamificationKey")
|
|
510
|
+
val keyForGamificationRegion = remoteConfigKeys?.getString("keyForGamificationRegion")
|
|
511
|
+
val keyForGamificationBaseUrl = remoteConfigKeys?.getString("keyForGamificationBaseUrl")
|
|
512
|
+
|
|
513
|
+
if (keyForAccountId == null || keyForAccountId.isEmpty() || keyForBaseUrl == null || keyForBaseUrl.isEmpty() || keyForSsl == null || keyForSsl.isEmpty() || keyForRemoteDebugLevel == null || keyForRemoteDebugLevel.isEmpty()) {
|
|
514
|
+
Logger.e("HydraCore.setFirebaseRemoteConfigKeys", "Invalid remote config keys")
|
|
515
|
+
promise?.reject("Error setting remote config keys", "Invalid remote config keys", Throwable())
|
|
516
|
+
return
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
val hydraFirebaseRemoteConfigKeys: HydraFirebaseRemoteConfigKeys =
|
|
520
|
+
HydraFirebaseRemoteConfigKeys(
|
|
521
|
+
keyForAccountId,
|
|
522
|
+
keyForBaseUrl,
|
|
523
|
+
keyForSsl,
|
|
524
|
+
keyForRemoteDebugLevel,
|
|
525
|
+
keyForOrgId,
|
|
526
|
+
keyForGamificationKey,
|
|
527
|
+
keyForGamificationRegion,
|
|
528
|
+
keyForGamificationBaseUrl
|
|
529
|
+
)
|
|
530
|
+
val hydraRemoteConfig: HydraRemoteConfig? =
|
|
531
|
+
processFirebaseRemoteConfig(hydraFirebaseRemoteConfigKeys)
|
|
532
|
+
if (hydraRemoteConfig == null) {
|
|
533
|
+
val errorMessage = "Failed to get values for these keys from Firebase remote config"
|
|
534
|
+
Logger.e("HydraCore.setFirebaseRemoteConfigKeys", errorMessage)
|
|
535
|
+
promise?.reject("Error setting remote config keys", errorMessage, Throwable())
|
|
536
|
+
return
|
|
537
|
+
} else {
|
|
538
|
+
if (
|
|
539
|
+
lastUsedHydraRemoteConfig != null &&
|
|
540
|
+
lastUsedHydraRemoteConfig!!.accountId == hydraRemoteConfig.accountId &&
|
|
541
|
+
lastUsedHydraRemoteConfig!!.sslPublicKey == hydraRemoteConfig.sslPublicKey &&
|
|
542
|
+
lastUsedHydraRemoteConfig!!.baseURL == hydraRemoteConfig.baseURL &&
|
|
543
|
+
lastUsedHydraRemoteConfig!!.remoteDebugLevel == hydraRemoteConfig.remoteDebugLevel &&
|
|
544
|
+
lastUsedHydraRemoteConfig!!.orgId == hydraRemoteConfig.orgId &&
|
|
545
|
+
lastUsedHydraRemoteConfig!!.gamificationKey == hydraRemoteConfig.gamificationKey &&
|
|
546
|
+
lastUsedHydraRemoteConfig!!.gamificationRegion == hydraRemoteConfig.gamificationRegion &&
|
|
547
|
+
lastUsedHydraRemoteConfig!!.gamificationBaseUrl == hydraRemoteConfig.gamificationBaseUrl
|
|
548
|
+
) {
|
|
549
|
+
clearPersistentData()
|
|
550
|
+
RNHydraPreferencesManager.saveHydraFirebaseRemoteConfigKeys(
|
|
551
|
+
appContext!!,
|
|
552
|
+
hydraFirebaseRemoteConfigKeys
|
|
553
|
+
)
|
|
554
|
+
Logger.d(
|
|
555
|
+
"HydraCore.hydraFirebaseRemoteConfigKeys",
|
|
556
|
+
"Already using these account config values"
|
|
557
|
+
)
|
|
558
|
+
promise?.resolve(true)
|
|
559
|
+
return
|
|
560
|
+
} else {
|
|
561
|
+
initHydraInstance(hydraRemoteConfig)
|
|
562
|
+
clearPersistentData()
|
|
563
|
+
RNHydraPreferencesManager.saveHydraFirebaseRemoteConfigKeys(
|
|
564
|
+
appContext!!,
|
|
565
|
+
hydraFirebaseRemoteConfigKeys
|
|
566
|
+
)
|
|
567
|
+
HydraPushNotification.registerHydraPushNotificationListener()
|
|
568
|
+
HydraInAppMessages.registerListener()
|
|
569
|
+
HydraInboxUI.registerListener()
|
|
570
|
+
promise?.resolve(true)
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
fun updateGeoConfig(geoConfig: ReadableMap?, promise: Promise?) {
|
|
576
|
+
if (hydraAPI == null) {
|
|
577
|
+
Logger.e("HydraCore.updateGeoConfig", "Hydra instance not initialized")
|
|
578
|
+
promise?.reject("Error updating geo config", "Hydra instance not initialized", Throwable())
|
|
579
|
+
return
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
val country: String? = geoConfig?.getString("country")
|
|
583
|
+
val city: String? = geoConfig?.getString("city")
|
|
584
|
+
val countryCode: String? = geoConfig?.getString("countryCode")
|
|
585
|
+
|
|
586
|
+
country?.let { hydraAPI!!.setCountry(country) }
|
|
587
|
+
city?.let { hydraAPI!!.setCity(city) }
|
|
588
|
+
countryCode?.let { hydraAPI!!.setCountryCode(countryCode) }
|
|
589
|
+
|
|
590
|
+
promise?.resolve(true)
|
|
591
|
+
|
|
592
|
+
Logger.d("HydraCore.updateGeoConfig", "Updated geo config successfully")
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
fun updatePushPreferences(customerId: String?, preferences: ReadableMap?, promise: Promise?) {
|
|
596
|
+
if (hydraAPI == null) {
|
|
597
|
+
Logger.e("HydraCore.updatePushPreferences", "Hydra instance not initialized")
|
|
598
|
+
promise?.reject(
|
|
599
|
+
"Error updating push preferences",
|
|
600
|
+
"Hydra instance not initialized",
|
|
601
|
+
Throwable()
|
|
602
|
+
)
|
|
603
|
+
return
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (customerId == null) {
|
|
607
|
+
Logger.e("HydraCore.updatePushPreferences", "CustomerId can not be null")
|
|
608
|
+
promise?.reject("Error updating push preferences", "CustomerId can not be null", Throwable())
|
|
609
|
+
return
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
val promPushOpted = preferences?.getBoolean("promPushOpted") ?: false
|
|
613
|
+
val transPushOpted = preferences?.getBoolean("transPushOpted") ?: false
|
|
614
|
+
|
|
615
|
+
hydraAPI!!.passUserPreferences(customerId, UserPreferences(promPushOpted, transPushOpted))
|
|
616
|
+
|
|
617
|
+
Logger.d("HydraCore.updatePushPreferences", "User preferences data updated successfully!")
|
|
618
|
+
promise?.resolve(true)
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
fun signUp(userDetails: ReadableMap?, customData: ReadableMap?, promise: Promise?) {
|
|
622
|
+
if (hydraAPI == null) {
|
|
623
|
+
Logger.e("HydraCore.signUp", "Hydra instance not initialized")
|
|
624
|
+
promise?.reject("Error Signing up", "Hydra instance not initialized", Throwable())
|
|
625
|
+
return
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
val customerId: String? = userDetails?.getString("customerId")
|
|
629
|
+
val firstName: String? = userDetails?.getString("firstName")
|
|
630
|
+
val lastName: String? = userDetails?.getString("lastName")
|
|
631
|
+
val email: String? = userDetails?.getString("email")
|
|
632
|
+
val phone: String? = userDetails?.getString("phone")
|
|
633
|
+
|
|
634
|
+
if (customerId == null) {
|
|
635
|
+
Logger.e("HydraCore.signUp", "CustomerId can not be null")
|
|
636
|
+
promise?.reject("Error Signing up", "CustomerId can not be null", Throwable())
|
|
637
|
+
return
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
hydraAPI!!.pushUserSignup(
|
|
641
|
+
customerId,
|
|
642
|
+
firstName,
|
|
643
|
+
lastName,
|
|
644
|
+
email,
|
|
645
|
+
phone,
|
|
646
|
+
customData?.let { customData.toMap() },
|
|
647
|
+
)
|
|
648
|
+
|
|
649
|
+
promise?.resolve(true)
|
|
650
|
+
Logger.d("HydraCore.signUp", "Signed up successfully")
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
fun signIn(userDetails: ReadableMap?, customData: ReadableMap?, promise: Promise?) {
|
|
654
|
+
|
|
655
|
+
if (hydraAPI == null) {
|
|
656
|
+
Logger.e("HydraCore.signIn", "Hydra instance not initialized")
|
|
657
|
+
promise?.reject("Error Signing in", "Hydra instance not initialized", Throwable())
|
|
658
|
+
return
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
val customerId: String? = userDetails?.getString("customerId")
|
|
662
|
+
val firstName: String? = userDetails?.getString("firstName")
|
|
663
|
+
val lastName: String? = userDetails?.getString("lastName")
|
|
664
|
+
val email: String? = userDetails?.getString("email")
|
|
665
|
+
val phone: String? = userDetails?.getString("phone")
|
|
666
|
+
|
|
667
|
+
if (customerId == null) {
|
|
668
|
+
Logger.e("HydraCore.signIn", "CustomerId can not be null")
|
|
669
|
+
promise?.reject("Error Signing in", "CustomerId can not be null", Throwable())
|
|
670
|
+
return
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
hydraAPI!!.pushUserSignin(
|
|
674
|
+
customerId,
|
|
675
|
+
firstName,
|
|
676
|
+
lastName,
|
|
677
|
+
email,
|
|
678
|
+
phone,
|
|
679
|
+
customData?.let { customData.toMap() },
|
|
680
|
+
)
|
|
681
|
+
|
|
682
|
+
promise?.resolve(true)
|
|
683
|
+
Logger.d("HydraCore.signIn", "Signed in successfully")
|
|
684
|
+
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
fun updateUser(
|
|
688
|
+
userDetails: ReadableMap?,
|
|
689
|
+
customAttributes: ReadableMap?,
|
|
690
|
+
subscriptions: ReadableArray?,
|
|
691
|
+
promise: Promise?
|
|
692
|
+
) {
|
|
693
|
+
if (hydraAPI == null) {
|
|
694
|
+
Logger.e("HydraCore.updateUser", "Hydra instance not initialized")
|
|
695
|
+
promise?.reject("Error Updating user details", "Hydra instance not initialized", Throwable())
|
|
696
|
+
return
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
val customerId: String? = userDetails?.getString("customerId")
|
|
700
|
+
val firstName: String? = userDetails?.getString("firstName")
|
|
701
|
+
val lastName: String? = userDetails?.getString("lastName")
|
|
702
|
+
val email: String? = userDetails?.getString("email")
|
|
703
|
+
val phone: String? = userDetails?.getString("phone")
|
|
704
|
+
|
|
705
|
+
if (customerId == null) {
|
|
706
|
+
Logger.e("HydraCore.updateUser", "CustomerId can not be null")
|
|
707
|
+
promise?.reject("Error Updating user details", "CustomerId can not be null", Throwable())
|
|
708
|
+
return
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
hydraAPI!!.pushUserUpdate(
|
|
712
|
+
customerId,
|
|
713
|
+
firstName,
|
|
714
|
+
lastName,
|
|
715
|
+
email,
|
|
716
|
+
phone,
|
|
717
|
+
customAttributes?.let { customAttributes.toMap() },
|
|
718
|
+
subscriptions?.let { subscriptions.toList() }
|
|
719
|
+
)
|
|
720
|
+
|
|
721
|
+
promise?.resolve(true)
|
|
722
|
+
Logger.d("HydraCore.updateUser", "User details updated successfully")
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
fun signOut(customerId: String?, promise: Promise?) {
|
|
726
|
+
if (hydraAPI == null) {
|
|
727
|
+
Logger.e("HydraCore.signOut", "Hydra instance not initialized")
|
|
728
|
+
promise?.reject("Error Signing out", "Hydra instance not initialized", Throwable())
|
|
729
|
+
return
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
if (customerId == null) {
|
|
733
|
+
Logger.e("HydraCore.signOut", "Customer id can not be null")
|
|
734
|
+
promise?.reject("Error Signing out", "Customer id can not be null", Throwable())
|
|
735
|
+
return
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
hydraAPI!!.pushUserSignOut(customerId)
|
|
739
|
+
promise?.resolve(true)
|
|
740
|
+
Logger.d("HydraCore.signOut", "User signed out successfully")
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
fun reportUserEvent(eventName: String?, attributes: ReadableMap?, promise: Promise?) {
|
|
744
|
+
if (hydraAPI == null) {
|
|
745
|
+
Logger.e("HydraCore.reportUserEvent", "Hydra instance not initialized")
|
|
746
|
+
promise?.reject("Error Reporting user event", "Hydra instance not initialized", Throwable())
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
if (eventName == null) {
|
|
750
|
+
Logger.e("HydraCore.reportUserEvent", "Event name cannot be null")
|
|
751
|
+
promise?.reject("Error Reporting user event", "Event name cannot be null", Throwable())
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
hydraAPI!!.pushEvent(eventName!!, attributes?.toMap())
|
|
755
|
+
promise?.resolve(true)
|
|
756
|
+
Logger.d("HydraCore.reportUserEvent", "User event reported successfully")
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
fun identify(userDetails: ReadableMap?, customData: ReadableMap?, promise: Promise?) {
|
|
760
|
+
signIn(userDetails, customData, promise)
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
fun track(eventName: String?, attributes: ReadableMap?, promise: Promise?) {
|
|
764
|
+
reportUserEvent(eventName, attributes, promise)
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
fun reset(customerId: String?, promise: Promise?) {
|
|
768
|
+
signOut(customerId, promise)
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
fun isSdkInitialized(promise: Promise?) {
|
|
772
|
+
val isInitialized = hydraAPI != null
|
|
773
|
+
Logger.d("HydraCore.isSdkInitialized", "SDK initialization status: $isInitialized")
|
|
774
|
+
promise?.resolve(isInitialized)
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
fun getCurrentUserState(promise: Promise?) {
|
|
778
|
+
try {
|
|
779
|
+
val userState = hydraAPI?.getCurrentUserState()
|
|
780
|
+
val stateString = userState?.name
|
|
781
|
+
Logger.d("HydraCore.getCurrentUserState", "Current user state: $stateString")
|
|
782
|
+
promise?.resolve(stateString)
|
|
783
|
+
} catch (e: Exception) {
|
|
784
|
+
Logger.e("HydraCore.getCurrentUserState", "Error getting current user state: ${e.message}")
|
|
785
|
+
promise?.reject("Error", "Failed to get current user state", e)
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
fun getVisitorDetails(promise: Promise?) {
|
|
790
|
+
try {
|
|
791
|
+
val anonymousId = hydraAPI?.getAnonymousId()
|
|
792
|
+
if (!anonymousId.isNullOrEmpty()) {
|
|
793
|
+
val visitorMap: WritableMap = Arguments.createMap()
|
|
794
|
+
visitorMap.putString("visitorId", anonymousId)
|
|
795
|
+
promise?.resolve(visitorMap)
|
|
796
|
+
} else {
|
|
797
|
+
Logger.d("HydraCore.getVisitorDetails", "Visitor details not available")
|
|
798
|
+
promise?.resolve(null)
|
|
799
|
+
}
|
|
800
|
+
} catch (e: Exception) {
|
|
801
|
+
Logger.e("HydraCore.getVisitorDetails", "Error getting visitor details: ${e.message}")
|
|
802
|
+
promise?.reject("Error", "Failed to get visitor details", e)
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
fun isVisitorFlowEnabled(promise: Promise?) {
|
|
807
|
+
try {
|
|
808
|
+
val isEnabled = if (appContext != null) {
|
|
809
|
+
HydraAPI.isVisitorFlowEnabled(appContext!!)
|
|
810
|
+
} else {
|
|
811
|
+
false
|
|
812
|
+
}
|
|
813
|
+
Logger.d("HydraCore.isVisitorFlowEnabled", "Visitor flow enabled: $isEnabled")
|
|
814
|
+
promise?.resolve(isEnabled)
|
|
815
|
+
} catch (e: Exception) {
|
|
816
|
+
Logger.e("HydraCore.isVisitorFlowEnabled", "Error checking visitor flow: ${e.message}")
|
|
817
|
+
promise?.reject("Error", "Failed to check visitor flow", e)
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
fun gamificationScreenAppeared(
|
|
822
|
+
screenName: String?,
|
|
823
|
+
promise: Promise?
|
|
824
|
+
){
|
|
825
|
+
val activity = curReactActivity
|
|
826
|
+
if (activity != null) {
|
|
827
|
+
activity.runOnUiThread {
|
|
828
|
+
// Synchronized against initHydraInstance's read-and-clear so the manager readiness
|
|
829
|
+
// check and the queueing of the screen name happen atomically relative to it.
|
|
830
|
+
synchronized(gamificationLock) {
|
|
831
|
+
val manager = gamificationUIManager
|
|
832
|
+
if (manager != null) {
|
|
833
|
+
manager.onScreenChanged(activity, screenName ?: "")
|
|
834
|
+
} else {
|
|
835
|
+
pendingGamificationScreen = screenName
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
promise?.resolve(true)
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
fun gamificationScreenDisappeared(promise: Promise?){
|
|
844
|
+
synchronized(gamificationLock) {
|
|
845
|
+
pendingGamificationScreen = null
|
|
846
|
+
}
|
|
847
|
+
curReactActivity?.let {
|
|
848
|
+
it.runOnUiThread {
|
|
849
|
+
gamificationUIManager?.onActivityDestroyed(it)
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
promise?.resolve(true)
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
fun setCapToken(token: String, promise: Promise) {
|
|
856
|
+
getFlowManager()?.setCapToken(token)
|
|
857
|
+
promise.resolve(null)
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
}
|