clevertap-react-native 3.9.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/worktrees/ecstatic-goldberg/.claude/settings.local.json +12 -0
- package/.claude/worktrees/ecstatic-goldberg/.codebeatignore +1 -0
- package/.claude/worktrees/ecstatic-goldberg/.eslintrc.json +34 -0
- package/.claude/worktrees/ecstatic-goldberg/.vscode/settings.json +3 -0
- package/.claude/worktrees/ecstatic-goldberg/CHANGELOG.md +689 -0
- package/.claude/worktrees/ecstatic-goldberg/LICENSE +9 -0
- package/.claude/worktrees/ecstatic-goldberg/README.md +52 -0
- package/.claude/worktrees/ecstatic-goldberg/android/.gradle/8.5/checksums/checksums.lock +0 -0
- package/.claude/worktrees/ecstatic-goldberg/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/.claude/worktrees/ecstatic-goldberg/android/.gradle/8.5/fileChanges/last-build.bin +0 -0
- package/.claude/worktrees/ecstatic-goldberg/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/.claude/worktrees/ecstatic-goldberg/android/.gradle/8.5/gc.properties +0 -0
- package/.claude/worktrees/ecstatic-goldberg/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/.claude/worktrees/ecstatic-goldberg/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/.claude/worktrees/ecstatic-goldberg/android/.gradle/vcs-1/gc.properties +0 -0
- package/.claude/worktrees/ecstatic-goldberg/android/build.gradle +63 -0
- package/.claude/worktrees/ecstatic-goldberg/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/.claude/worktrees/ecstatic-goldberg/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/.claude/worktrees/ecstatic-goldberg/android/gradle.properties +2 -0
- package/.claude/worktrees/ecstatic-goldberg/android/gradlew +160 -0
- package/.claude/worktrees/ecstatic-goldberg/android/gradlew.bat +90 -0
- package/{android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt → .claude/worktrees/ecstatic-goldberg/android/src/main}/AndroidManifest.xml +2 -7
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapApplication.kt +12 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapCustomTemplates.kt +66 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapEvent.kt +42 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapEventEmitter.kt +128 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapListenerProxy.kt +225 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapModuleImpl.java +2112 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapPackage.kt +36 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapRnAPI.kt +35 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/CleverTapUtils.java +333 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/main/java/com/clevertap/react/Constants.kt +13 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/newarch/CleverTapModule.kt +622 -0
- package/.claude/worktrees/ecstatic-goldberg/android/src/oldarch/CleverTapModule.kt +716 -0
- package/.claude/worktrees/ecstatic-goldberg/clevertap-react-native.podspec +37 -0
- package/.claude/worktrees/ecstatic-goldberg/docs/CustomCodeTemplates.md +215 -0
- package/.claude/worktrees/ecstatic-goldberg/docs/Variables.md +191 -0
- package/.claude/worktrees/ecstatic-goldberg/docs/callbackPayloadFormat.md +26 -0
- package/.claude/worktrees/ecstatic-goldberg/docs/install.md +162 -0
- package/.claude/worktrees/ecstatic-goldberg/docs/integration.md +122 -0
- package/.claude/worktrees/ecstatic-goldberg/docs/iospushtemplates.md +582 -0
- package/.claude/worktrees/ecstatic-goldberg/docs/pushprimer.md +99 -0
- package/.claude/worktrees/ecstatic-goldberg/docs/usage.md +524 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReact.h +41 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReact.mm +1428 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactAppFunctionPresenter.h +20 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactAppFunctionPresenter.mm +21 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactCustomTemplates.h +42 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactCustomTemplates.mm +51 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactManager.h +14 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactManager.mm +168 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactPendingEvent.h +14 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactPendingEvent.mm +14 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactTemplatePresenter.h +22 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact/CleverTapReactTemplatePresenter.mm +21 -0
- package/.claude/worktrees/ecstatic-goldberg/ios/CleverTapReact.xcodeproj/project.pbxproj +371 -0
- package/.claude/worktrees/ecstatic-goldberg/package-lock.json +9891 -0
- package/.claude/worktrees/ecstatic-goldberg/package.json +57 -0
- package/.claude/worktrees/ecstatic-goldberg/src/NativeCleverTapModule.ts +252 -0
- package/.claude/worktrees/ecstatic-goldberg/src/index.d.ts +1031 -0
- package/.claude/worktrees/ecstatic-goldberg/src/index.js +1258 -0
- package/.claude/worktrees/ecstatic-goldberg/static/Finder.png +0 -0
- package/.claude/worktrees/ecstatic-goldberg/static/GenerateSpecs.png +0 -0
- package/.claude/worktrees/ecstatic-goldberg/static/NotificationContent.png +0 -0
- package/.claude/worktrees/ecstatic-goldberg/static/NotificationContentStoryboard.png +0 -0
- package/.claude/worktrees/ecstatic-goldberg/static/NotificationContentTarget.png +0 -0
- package/.claude/worktrees/ecstatic-goldberg/static/NotificationServiceTarget.png +0 -0
- package/.claude/worktrees/vigilant-davinci/.claude/settings.local.json +7 -0
- package/.claude/worktrees/vigilant-davinci/.codebeatignore +1 -0
- package/.claude/worktrees/vigilant-davinci/.eslintrc.json +34 -0
- package/.claude/worktrees/vigilant-davinci/.vscode/settings.json +3 -0
- package/.claude/worktrees/vigilant-davinci/CHANGELOG.md +702 -0
- package/.claude/worktrees/vigilant-davinci/LICENSE +9 -0
- package/.claude/worktrees/vigilant-davinci/README.md +52 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/8.5/checksums/checksums.lock +0 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/8.5/dependencies-accessors/gc.properties +0 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/8.5/fileChanges/last-build.bin +0 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/8.5/gc.properties +0 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/.claude/worktrees/vigilant-davinci/android/.gradle/vcs-1/gc.properties +0 -0
- package/.claude/worktrees/vigilant-davinci/android/build.gradle +63 -0
- package/.claude/worktrees/vigilant-davinci/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/.claude/worktrees/vigilant-davinci/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/.claude/worktrees/vigilant-davinci/android/gradle.properties +2 -0
- package/.claude/worktrees/vigilant-davinci/android/gradlew +160 -0
- package/.claude/worktrees/vigilant-davinci/android/gradlew.bat +90 -0
- package/{android/build/intermediates/merged_manifest/debug → .claude/worktrees/vigilant-davinci/android/src/main}/AndroidManifest.xml +2 -7
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapApplication.kt +12 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapCustomTemplates.kt +66 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapEvent.kt +42 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapEventEmitter.kt +128 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapListenerProxy.kt +225 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapModuleImpl.java +2139 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapPackage.kt +36 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapRnAPI.kt +35 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/CleverTapUtils.java +333 -0
- package/.claude/worktrees/vigilant-davinci/android/src/main/java/com/clevertap/react/Constants.kt +13 -0
- package/.claude/worktrees/vigilant-davinci/android/src/newarch/CleverTapModule.kt +622 -0
- package/.claude/worktrees/vigilant-davinci/android/src/oldarch/CleverTapModule.kt +716 -0
- package/.claude/worktrees/vigilant-davinci/clevertap-react-native.podspec +37 -0
- package/.claude/worktrees/vigilant-davinci/docs/CustomCodeTemplates.md +215 -0
- package/.claude/worktrees/vigilant-davinci/docs/Variables.md +191 -0
- package/.claude/worktrees/vigilant-davinci/docs/callbackPayloadFormat.md +26 -0
- package/.claude/worktrees/vigilant-davinci/docs/install.md +162 -0
- package/.claude/worktrees/vigilant-davinci/docs/integration.md +122 -0
- package/.claude/worktrees/vigilant-davinci/docs/iospushtemplates.md +582 -0
- package/.claude/worktrees/vigilant-davinci/docs/pushprimer.md +99 -0
- package/.claude/worktrees/vigilant-davinci/docs/usage.md +524 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReact.h +41 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReact.mm +1428 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactAppFunctionPresenter.h +20 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactAppFunctionPresenter.mm +21 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactCustomTemplates.h +42 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactCustomTemplates.mm +51 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactManager.h +14 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactManager.mm +168 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactPendingEvent.h +14 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactPendingEvent.mm +14 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactTemplatePresenter.h +22 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact/CleverTapReactTemplatePresenter.mm +21 -0
- package/.claude/worktrees/vigilant-davinci/ios/CleverTapReact.xcodeproj/project.pbxproj +371 -0
- package/.claude/worktrees/vigilant-davinci/package-lock.json +9891 -0
- package/.claude/worktrees/vigilant-davinci/package.json +57 -0
- package/.claude/worktrees/vigilant-davinci/src/NativeCleverTapModule.ts +252 -0
- package/.claude/worktrees/vigilant-davinci/src/index.d.ts +1031 -0
- package/.claude/worktrees/vigilant-davinci/src/index.js +1270 -0
- package/.claude/worktrees/vigilant-davinci/static/Finder.png +0 -0
- package/.claude/worktrees/vigilant-davinci/static/GenerateSpecs.png +0 -0
- package/.claude/worktrees/vigilant-davinci/static/NotificationContent.png +0 -0
- package/.claude/worktrees/vigilant-davinci/static/NotificationContentStoryboard.png +0 -0
- package/.claude/worktrees/vigilant-davinci/static/NotificationContentTarget.png +0 -0
- package/.claude/worktrees/vigilant-davinci/static/NotificationServiceTarget.png +0 -0
- package/CHANGELOG.md +13 -0
- package/android/.gradle/8.5/checksums/checksums.lock +0 -0
- package/android/{build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i → .gradle/8.5/checksums/sha1-checksums.bin} +0 -0
- package/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/build.gradle +3 -3
- package/clevertap-react-native.podspec +1 -1
- package/docs/install.md +1 -1
- package/ios/CleverTapReact/CleverTapReactManager.mm +8 -0
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/build/generated/source/buildConfig/debug/com/clevertap/react/BuildConfig.java +0 -12
- package/android/build/generated/source/codegen/java/com/clevertap/react/NativeCleverTapModuleSpec.java +0 -582
- package/android/build/generated/source/codegen/jni/CMakeLists.txt +0 -49
- package/android/build/generated/source/codegen/jni/CTTurboModuleSpec-generated.cpp +0 -764
- package/android/build/generated/source/codegen/jni/CTTurboModuleSpec.h +0 -31
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/CTTurboModuleSpecJSI-generated.cpp +0 -1035
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/CTTurboModuleSpecJSI.h +0 -1161
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/ComponentDescriptors.cpp +0 -22
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/ComponentDescriptors.h +0 -24
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/EventEmitters.cpp +0 -16
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/EventEmitters.h +0 -17
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/Props.cpp +0 -19
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/Props.h +0 -18
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/ShadowNodes.cpp +0 -17
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/ShadowNodes.h +0 -23
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/States.cpp +0 -16
- package/android/build/generated/source/codegen/jni/react/renderer/components/CTTurboModuleSpec/States.h +0 -21
- package/android/build/generated/source/codegen/schema.json +0 -3695
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -6
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -7705
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/java_res/debug/out/META-INF/clevertap-react-native_debug.kotlin_module +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$10.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$4.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$5.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$6.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$7.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$8.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$9.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$InBoxMessages.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl$TemplateContextAction.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapModuleImpl.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapUtils$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapUtils$MapUtil$ArrayUtil.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapUtils$MapUtil.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/CleverTapUtils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/clevertap/react/NativeCleverTapModuleSpec.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -14
- package/android/build/intermediates/merged_java_res/debug/feature-clevertap-react-native.jar +0 -0
- package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -5786
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/aar/clevertap-react-native-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -17
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/clevertap-react-native_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapApplication.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapCustomTemplates$templatePresenter$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapCustomTemplates.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapEvent$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapEvent.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapEventEmitter$Buffer$items$2.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapEventEmitter$Buffer.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapEventEmitter.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapListenerProxy.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapPackage.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/CleverTapRnAPI.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/Constants.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/clevertap/react/ErrorMessages.class +0 -0
- package/android/local.properties +0 -8
- /package/{android/build/intermediates/annotations_typedef_file/debug/typedefs.txt → .claude/worktrees/ecstatic-goldberg/android/.gradle/8.5/dependencies-accessors/gc.properties} +0 -0
|
@@ -0,0 +1,2139 @@
|
|
|
1
|
+
package com.clevertap.react;
|
|
2
|
+
|
|
3
|
+
import static com.clevertap.react.CleverTapUtils.convertObjectToWritableMap;
|
|
4
|
+
import static com.clevertap.react.CleverTapUtils.getWritableArrayFromDisplayUnitList;
|
|
5
|
+
import static com.clevertap.react.Constants.FCM;
|
|
6
|
+
import static com.clevertap.react.Constants.REACT_MODULE_NAME;
|
|
7
|
+
|
|
8
|
+
import android.annotation.SuppressLint;
|
|
9
|
+
import android.location.Location;
|
|
10
|
+
import android.net.Uri;
|
|
11
|
+
import android.os.Build.VERSION;
|
|
12
|
+
import android.os.Build.VERSION_CODES;
|
|
13
|
+
import android.os.Bundle;
|
|
14
|
+
import android.os.Handler;
|
|
15
|
+
import android.util.Log;
|
|
16
|
+
|
|
17
|
+
import androidx.annotation.NonNull;
|
|
18
|
+
import androidx.annotation.RequiresApi;
|
|
19
|
+
|
|
20
|
+
import com.clevertap.android.sdk.CTInboxStyleConfig;
|
|
21
|
+
import com.clevertap.android.sdk.CleverTapAPI;
|
|
22
|
+
import com.clevertap.android.sdk.Logger;
|
|
23
|
+
import com.clevertap.android.sdk.UTMDetail;
|
|
24
|
+
import com.clevertap.android.sdk.displayunits.model.CleverTapDisplayUnit;
|
|
25
|
+
import com.clevertap.android.sdk.events.EventDetail;
|
|
26
|
+
import com.clevertap.android.sdk.featureFlags.CTFeatureFlagsController;
|
|
27
|
+
import com.clevertap.android.sdk.inapp.CTLocalInApp;
|
|
28
|
+
import com.clevertap.android.sdk.inapp.callbacks.FetchInAppsCallback;
|
|
29
|
+
import com.clevertap.android.sdk.inapp.customtemplates.CustomTemplateContext;
|
|
30
|
+
import com.clevertap.android.sdk.inbox.CTInboxMessage;
|
|
31
|
+
import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
|
|
32
|
+
import com.clevertap.android.sdk.product_config.CTProductConfigController;
|
|
33
|
+
import com.clevertap.android.sdk.pushnotification.PushType;
|
|
34
|
+
import com.clevertap.android.sdk.usereventlogs.UserEventLog;
|
|
35
|
+
import com.clevertap.android.sdk.variables.CTVariableUtils;
|
|
36
|
+
import com.clevertap.android.sdk.variables.Var;
|
|
37
|
+
import com.clevertap.android.sdk.variables.callbacks.FetchVariablesCallback;
|
|
38
|
+
import com.clevertap.android.sdk.variables.callbacks.VariableCallback;
|
|
39
|
+
import com.clevertap.android.sdk.variables.callbacks.VariablesChangedCallback;
|
|
40
|
+
import com.facebook.react.bridge.Arguments;
|
|
41
|
+
import com.facebook.react.bridge.Callback;
|
|
42
|
+
import com.facebook.react.bridge.Promise;
|
|
43
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
44
|
+
import com.facebook.react.bridge.ReactContext;
|
|
45
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
46
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
47
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
48
|
+
import com.facebook.react.bridge.ReadableType;
|
|
49
|
+
import com.facebook.react.bridge.WritableArray;
|
|
50
|
+
import com.facebook.react.bridge.WritableMap;
|
|
51
|
+
|
|
52
|
+
import org.json.JSONArray;
|
|
53
|
+
import org.json.JSONException;
|
|
54
|
+
import org.json.JSONObject;
|
|
55
|
+
|
|
56
|
+
import java.text.SimpleDateFormat;
|
|
57
|
+
import java.util.ArrayList;
|
|
58
|
+
import java.util.List;
|
|
59
|
+
import java.util.Date;
|
|
60
|
+
import java.util.HashMap;
|
|
61
|
+
import java.util.Iterator;
|
|
62
|
+
import java.util.Locale;
|
|
63
|
+
import java.util.Map;
|
|
64
|
+
|
|
65
|
+
import javax.annotation.Nullable;
|
|
66
|
+
|
|
67
|
+
public class CleverTapModuleImpl {
|
|
68
|
+
|
|
69
|
+
private static final String TAG = REACT_MODULE_NAME;
|
|
70
|
+
|
|
71
|
+
@SuppressWarnings("FieldCanBeLocal")
|
|
72
|
+
private enum InBoxMessages {
|
|
73
|
+
ALL(0),
|
|
74
|
+
UNREAD(1);
|
|
75
|
+
|
|
76
|
+
private final int value;
|
|
77
|
+
|
|
78
|
+
InBoxMessages(final int newValue) {
|
|
79
|
+
value = newValue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private static Uri sLaunchUri;
|
|
85
|
+
|
|
86
|
+
public static Map<String, Object> variables = new HashMap<>();
|
|
87
|
+
|
|
88
|
+
public static void setInitialUri(final Uri uri) {
|
|
89
|
+
sLaunchUri = uri;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private final ReactApplicationContext context;
|
|
93
|
+
|
|
94
|
+
private CleverTapAPI mCleverTap;
|
|
95
|
+
|
|
96
|
+
public CleverTapModuleImpl(ReactApplicationContext reactContext) {
|
|
97
|
+
this.context = reactContext;
|
|
98
|
+
enableEventEmitter(reactContext);
|
|
99
|
+
getCleverTapAPI();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public Map<String, Object> getClevertapConstants() {
|
|
103
|
+
Map<String, Object> constants = new HashMap<>();
|
|
104
|
+
for (CleverTapEvent event : CleverTapEvent.values()) {
|
|
105
|
+
constants.put(event.getEventName(), event.getEventName());
|
|
106
|
+
}
|
|
107
|
+
constants.put(FCM, FCM);
|
|
108
|
+
return constants;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@SuppressLint("RestrictedApi")
|
|
112
|
+
public void setLibrary(String libName, int libVersion) {
|
|
113
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
114
|
+
if (cleverTap != null) {
|
|
115
|
+
cleverTap.setCustomSdkVersion(libName, libVersion);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public void setLocale(String locale) {
|
|
121
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
122
|
+
if (cleverTap != null) {
|
|
123
|
+
cleverTap.setLocale(locale);
|
|
124
|
+
} else {
|
|
125
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public void activate() {
|
|
130
|
+
CTProductConfigController productConfigController = getCtProductConfigController();
|
|
131
|
+
if (productConfigController == null) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
productConfigController.activate();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
//Custom Push Notification
|
|
139
|
+
public void createNotification(ReadableMap extras) {
|
|
140
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
141
|
+
if (clevertap == null) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
JSONObject extrasJsonObject;
|
|
145
|
+
try {
|
|
146
|
+
extrasJsonObject = jsonObjectFromReadableMap(extras);
|
|
147
|
+
Bundle bundle = new Bundle();
|
|
148
|
+
for (Iterator<String> entry = extrasJsonObject.keys(); entry.hasNext(); ) {
|
|
149
|
+
String key = entry.next();
|
|
150
|
+
String str = extrasJsonObject.optString(key);
|
|
151
|
+
bundle.putString(key, str);
|
|
152
|
+
}
|
|
153
|
+
CleverTapAPI.createNotification(this.context, bundle);
|
|
154
|
+
} catch (JSONException e) {
|
|
155
|
+
e.printStackTrace();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@RequiresApi(api = VERSION_CODES.O)
|
|
160
|
+
public void createNotificationChannel(String channelId, String channelName, String channelDescription,
|
|
161
|
+
int importance, boolean showBadge) {
|
|
162
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
163
|
+
if (clevertap == null || channelId == null || channelName == null || channelDescription == null) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
CleverTapAPI.createNotificationChannel(this.context, channelId, channelName, channelDescription, importance,
|
|
167
|
+
showBadge);
|
|
168
|
+
Log.i(TAG, "Notification Channel " + channelName + " created");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@RequiresApi(api = VERSION_CODES.O)
|
|
172
|
+
public void createNotificationChannelGroup(String groupId, String groupName) {
|
|
173
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
174
|
+
if (clevertap == null || groupId == null || groupName == null) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
CleverTapAPI.createNotificationChannelGroup(this.context, groupId, groupName);
|
|
178
|
+
Log.i(TAG, "Notification Channel Group " + groupName + " created");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@RequiresApi(api = VERSION_CODES.O)
|
|
182
|
+
public void createNotificationChannelWithGroupId(String channelId, String channelName, String channelDescription,
|
|
183
|
+
int importance, String groupId, boolean showBadge) {
|
|
184
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
185
|
+
if (clevertap == null || channelId == null || channelName == null || channelDescription == null
|
|
186
|
+
|| groupId == null) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
CleverTapAPI.createNotificationChannel(this.context, channelId, channelName, channelDescription, importance,
|
|
190
|
+
groupId, showBadge);
|
|
191
|
+
Log.i(TAG, "Notification Channel " + channelName + " with Group Id " + groupId + " created");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@RequiresApi(api = VERSION_CODES.O)
|
|
195
|
+
public void createNotificationChannelWithGroupIdAndSound(String channelId, String channelName,
|
|
196
|
+
String channelDescription, int importance, String groupId, boolean showBadge, String sound) {
|
|
197
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
198
|
+
if (clevertap == null || channelId == null || channelName == null || channelDescription == null
|
|
199
|
+
|| groupId == null || sound == null) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
CleverTapAPI.createNotificationChannel(this.context, channelId, channelName, channelDescription, importance,
|
|
203
|
+
groupId, showBadge, sound);
|
|
204
|
+
Log.i(TAG, "Notification Channel " + channelName + " with Group Id " + groupId + " and sound file " + sound
|
|
205
|
+
+ " created");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@RequiresApi(api = VERSION_CODES.O)
|
|
209
|
+
public void createNotificationChannelWithSound(String channelId, String channelName, String channelDescription,
|
|
210
|
+
int importance, boolean showBadge, String sound) {
|
|
211
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
212
|
+
if (clevertap == null || channelId == null || channelName == null || channelDescription == null
|
|
213
|
+
|| sound == null) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
CleverTapAPI.createNotificationChannel(this.context, channelId, channelName, channelDescription, importance,
|
|
217
|
+
showBadge, sound);
|
|
218
|
+
Log.i(TAG, "Notification Channel " + channelName + " with sound file " + sound + " created");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@RequiresApi(api = VERSION_CODES.O)
|
|
223
|
+
public void deleteNotificationChannel(String channelId) {
|
|
224
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
225
|
+
if (clevertap == null || channelId == null) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
CleverTapAPI.deleteNotificationChannel(this.context, channelId);
|
|
229
|
+
Log.i(TAG, "Notification Channel Id " + channelId + " deleted");
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@RequiresApi(api = VERSION_CODES.O)
|
|
233
|
+
public void deleteNotificationChannelGroup(String groupId) {
|
|
234
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
235
|
+
if (clevertap == null || groupId == null) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
CleverTapAPI.deleteNotificationChannelGroup(this.context, groupId);
|
|
239
|
+
Log.i(TAG, "Notification Channel Group Id " + groupId + " deleted");
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//Push permission methods
|
|
243
|
+
public void promptForPushPermission(boolean showFallbackSettings) {
|
|
244
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
245
|
+
if (cleverTap != null) {
|
|
246
|
+
cleverTap.promptForPushPermission(showFallbackSettings);
|
|
247
|
+
} else {
|
|
248
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public void promptPushPrimer(ReadableMap localInAppConfig) {
|
|
253
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
254
|
+
if (cleverTap != null) {
|
|
255
|
+
JSONObject jsonObject = localInAppConfigFromReadableMap(localInAppConfig);
|
|
256
|
+
cleverTap.promptPushPrimer(jsonObject);
|
|
257
|
+
} else {
|
|
258
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
public void isPushPermissionGranted(final Callback callback) {
|
|
263
|
+
final CleverTapAPI clevertap = getCleverTapAPI();
|
|
264
|
+
if (clevertap != null) {
|
|
265
|
+
boolean isPushPermissionGranted = clevertap.isPushPermissionGranted();
|
|
266
|
+
callbackWithErrorAndResult(callback, null, isPushPermissionGranted);
|
|
267
|
+
} else {
|
|
268
|
+
String error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
269
|
+
callbackWithErrorAndResult(callback, error, null);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
public void disablePersonalization() {
|
|
274
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
275
|
+
if (clevertap == null) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
clevertap.disablePersonalization();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
public void enableDeviceNetworkInfoReporting(boolean value) {
|
|
282
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
283
|
+
if (clevertap == null) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
clevertap.enableDeviceNetworkInfoReporting(value);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
public void enablePersonalization() {
|
|
290
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
291
|
+
if (clevertap == null) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
clevertap.enablePersonalization();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
public void getUserEventLog(String eventName, Callback callback) {
|
|
299
|
+
String error = null;
|
|
300
|
+
WritableMap result = null;
|
|
301
|
+
|
|
302
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
303
|
+
if (clevertap != null) {
|
|
304
|
+
UserEventLog eventLog = clevertap.getUserEventLog(eventName);
|
|
305
|
+
result = eventLogToWritableMap(eventLog);
|
|
306
|
+
} else {
|
|
307
|
+
error = "CleverTap not initialized";
|
|
308
|
+
}
|
|
309
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
public void getUserEventLogCount(String eventName, Callback callback) {
|
|
313
|
+
String error = null;
|
|
314
|
+
int result = -1;
|
|
315
|
+
|
|
316
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
317
|
+
if (clevertap != null) {
|
|
318
|
+
result = clevertap.getUserEventLogCount(eventName);
|
|
319
|
+
} else {
|
|
320
|
+
error = "CleverTap not initialized";
|
|
321
|
+
}
|
|
322
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
public void getUserLastVisitTs(Callback callback) {
|
|
326
|
+
String error = null;
|
|
327
|
+
double result = -1;
|
|
328
|
+
|
|
329
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
330
|
+
if (clevertap != null) {
|
|
331
|
+
result = clevertap.getUserLastVisitTs();
|
|
332
|
+
} else {
|
|
333
|
+
error = "CleverTap not initialized";
|
|
334
|
+
}
|
|
335
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
public void getUserAppLaunchCount(Callback callback) {
|
|
339
|
+
String error = null;
|
|
340
|
+
int result = -1;
|
|
341
|
+
|
|
342
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
343
|
+
if (clevertap != null) {
|
|
344
|
+
result = clevertap.getUserAppLaunchCount();
|
|
345
|
+
} else {
|
|
346
|
+
error = "CleverTap not initialized";
|
|
347
|
+
}
|
|
348
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
public void getUserEventLogHistory(Callback callback) {
|
|
352
|
+
String error = null;
|
|
353
|
+
WritableMap result = null;
|
|
354
|
+
|
|
355
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
356
|
+
if (clevertap != null) {
|
|
357
|
+
Map<String, UserEventLog> history = clevertap.getUserEventLogHistory();
|
|
358
|
+
result = eventLogHistoryToWritableMap(history);
|
|
359
|
+
} else {
|
|
360
|
+
error = "CleverTap not initialized";
|
|
361
|
+
}
|
|
362
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@Deprecated(since = "3.2.0")
|
|
366
|
+
public void eventGetDetail(String eventName, Callback callback) {
|
|
367
|
+
String error = null;
|
|
368
|
+
WritableMap result = null;
|
|
369
|
+
|
|
370
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
371
|
+
if (clevertap != null) {
|
|
372
|
+
EventDetail detail = clevertap.getDetails(eventName);
|
|
373
|
+
result = eventDetailToWritableMap(detail);
|
|
374
|
+
} else {
|
|
375
|
+
error = "CleverTap not initialized";
|
|
376
|
+
}
|
|
377
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
@Deprecated(since = "3.2.0")
|
|
382
|
+
public void eventGetFirstTime(String eventName, Callback callback) {
|
|
383
|
+
String error = null;
|
|
384
|
+
int result = -1;
|
|
385
|
+
|
|
386
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
387
|
+
if (clevertap != null) {
|
|
388
|
+
result = clevertap.getFirstTime(eventName);
|
|
389
|
+
} else {
|
|
390
|
+
error = "CleverTap not initialized";
|
|
391
|
+
}
|
|
392
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
@Deprecated(since = "3.2.0")
|
|
396
|
+
public void eventGetLastTime(String eventName, Callback callback) {
|
|
397
|
+
String error = null;
|
|
398
|
+
int result = -1;
|
|
399
|
+
|
|
400
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
401
|
+
if (clevertap != null) {
|
|
402
|
+
result = clevertap.getLastTime(eventName);
|
|
403
|
+
} else {
|
|
404
|
+
error = "CleverTap not initialized";
|
|
405
|
+
}
|
|
406
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
@Deprecated(since = "3.2.0")
|
|
410
|
+
public void eventGetOccurrences(String eventName, Callback callback) {
|
|
411
|
+
String error = null;
|
|
412
|
+
int result = -1;
|
|
413
|
+
|
|
414
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
415
|
+
if (clevertap != null) {
|
|
416
|
+
result = clevertap.getCount(eventName);
|
|
417
|
+
} else {
|
|
418
|
+
error = "CleverTap not initialized";
|
|
419
|
+
}
|
|
420
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
public void fetch() {
|
|
424
|
+
CTProductConfigController productConfigController = getCtProductConfigController();
|
|
425
|
+
if (productConfigController == null) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
productConfigController.fetch();
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
public void fetchAndActivate() {
|
|
433
|
+
CTProductConfigController productConfigController = getCtProductConfigController();
|
|
434
|
+
if (productConfigController == null) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
productConfigController.fetchAndActivate();
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
public void fetchWithMinimumFetchIntervalInSeconds(int interval) {
|
|
442
|
+
CTProductConfigController productConfigController = getCtProductConfigController();
|
|
443
|
+
if (productConfigController == null) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
productConfigController.fetch(interval);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
public void getAllDisplayUnits(Callback callback) {
|
|
451
|
+
String error = null;
|
|
452
|
+
WritableArray result = Arguments.createArray();
|
|
453
|
+
|
|
454
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
455
|
+
if (cleverTap != null) {
|
|
456
|
+
result = getWritableArrayFromDisplayUnitList(cleverTap.getAllDisplayUnits());
|
|
457
|
+
} else {
|
|
458
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
459
|
+
}
|
|
460
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
public void getBoolean(String key, Callback callback) {
|
|
464
|
+
String error = null;
|
|
465
|
+
Boolean result = null;
|
|
466
|
+
|
|
467
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
468
|
+
if (cleverTap != null) {
|
|
469
|
+
CTProductConfigController productConfigController = cleverTap.productConfig();
|
|
470
|
+
if (productConfigController != null) {
|
|
471
|
+
result = productConfigController.getBoolean(key);
|
|
472
|
+
} else {
|
|
473
|
+
error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED;
|
|
474
|
+
}
|
|
475
|
+
} else {
|
|
476
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
477
|
+
}
|
|
478
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
public void getDisplayUnitForId(String unitID, Callback callback) {
|
|
482
|
+
String error = null;
|
|
483
|
+
WritableMap result = null;
|
|
484
|
+
|
|
485
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
486
|
+
if (cleverTap != null) {
|
|
487
|
+
CleverTapDisplayUnit displayUnit = cleverTap.getDisplayUnitForId(unitID);
|
|
488
|
+
if (displayUnit != null && displayUnit.getJsonObject() != null) {
|
|
489
|
+
result = convertObjectToWritableMap(displayUnit.getJsonObject());
|
|
490
|
+
}
|
|
491
|
+
} else {
|
|
492
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
493
|
+
}
|
|
494
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
public void getDouble(String key, Callback callback) {
|
|
498
|
+
String error = null;
|
|
499
|
+
Double result = null;
|
|
500
|
+
|
|
501
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
502
|
+
if (cleverTap != null) {
|
|
503
|
+
CTProductConfigController productConfigController = cleverTap.productConfig();
|
|
504
|
+
if (productConfigController != null) {
|
|
505
|
+
result = productConfigController.getDouble(key);
|
|
506
|
+
} else {
|
|
507
|
+
error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED;
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
511
|
+
}
|
|
512
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
@Deprecated(since = "3.2.0")
|
|
516
|
+
public void getEventHistory(Callback callback) {
|
|
517
|
+
String error = null;
|
|
518
|
+
WritableMap result = null;
|
|
519
|
+
|
|
520
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
521
|
+
if (clevertap != null) {
|
|
522
|
+
Map<String, EventDetail> history = clevertap.getHistory();
|
|
523
|
+
result = eventHistoryToWritableMap(history);
|
|
524
|
+
} else {
|
|
525
|
+
error = "CleverTap not initialized";
|
|
526
|
+
}
|
|
527
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
public void getFeatureFlag(String name, Boolean defaultValue, Callback callback) {
|
|
531
|
+
String error = null;
|
|
532
|
+
Boolean result = null;
|
|
533
|
+
|
|
534
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
535
|
+
if (cleverTap != null) {
|
|
536
|
+
CTFeatureFlagsController featureFlagsController = cleverTap.featureFlag();
|
|
537
|
+
if (featureFlagsController != null) {
|
|
538
|
+
result = featureFlagsController.get(name, defaultValue);
|
|
539
|
+
} else {
|
|
540
|
+
error = ErrorMessages.FF_NOT_INITIALIZED;
|
|
541
|
+
}
|
|
542
|
+
} else {
|
|
543
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
544
|
+
}
|
|
545
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
public void getAllInboxMessages(Callback callback) {
|
|
549
|
+
getInboxMessages(callback, InBoxMessages.ALL);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
public void getInboxMessageCount(Callback callback) {
|
|
553
|
+
|
|
554
|
+
String error = null;
|
|
555
|
+
int result = -1;
|
|
556
|
+
|
|
557
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
558
|
+
if (cleverTap != null) {
|
|
559
|
+
result = cleverTap.getInboxMessageCount();
|
|
560
|
+
} else {
|
|
561
|
+
error = "CleverTap not initialized";
|
|
562
|
+
}
|
|
563
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
public void getInboxMessageForId(String messageId, Callback callback) {
|
|
567
|
+
String error = null;
|
|
568
|
+
WritableMap result = null;
|
|
569
|
+
|
|
570
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
571
|
+
if (cleverTap != null) {
|
|
572
|
+
CTInboxMessage inboxMessage = cleverTap.getInboxMessageForId(messageId);
|
|
573
|
+
|
|
574
|
+
if (inboxMessage != null && inboxMessage.getData() != null) {
|
|
575
|
+
result = convertObjectToWritableMap(inboxMessage.getData());
|
|
576
|
+
}
|
|
577
|
+
} else {
|
|
578
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
579
|
+
}
|
|
580
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
public void getInboxMessageUnreadCount(Callback callback) {
|
|
584
|
+
String error = null;
|
|
585
|
+
int result = -1;
|
|
586
|
+
|
|
587
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
588
|
+
if (cleverTap != null) {
|
|
589
|
+
result = cleverTap.getInboxMessageUnreadCount();
|
|
590
|
+
} else {
|
|
591
|
+
error = "CleverTap not initialized";
|
|
592
|
+
}
|
|
593
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
public void deleteInboxMessageForId(String messageId) {
|
|
597
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
598
|
+
if (cleverTap != null) {
|
|
599
|
+
cleverTap.deleteInboxMessage(messageId);
|
|
600
|
+
} else {
|
|
601
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
public void getUnreadInboxMessages(Callback callback) {
|
|
606
|
+
getInboxMessages(callback, InBoxMessages.UNREAD);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
//App Inbox methods
|
|
611
|
+
public void initializeInbox() {
|
|
612
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
613
|
+
if (cleverTap != null) {
|
|
614
|
+
cleverTap.initializeInbox();
|
|
615
|
+
Log.e(TAG, "initializeInbox Called");
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
public void markReadInboxMessageForId(String messageId) {
|
|
620
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
621
|
+
if (cleverTap != null) {
|
|
622
|
+
cleverTap.markReadInboxMessage(messageId);
|
|
623
|
+
} else {
|
|
624
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
public void markReadInboxMessagesForIDs(final ReadableArray messageIDs) {
|
|
629
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
630
|
+
if (cleverTap != null) {
|
|
631
|
+
cleverTap.markReadInboxMessagesForIDs(arrayListStringFromReadableArray(messageIDs));
|
|
632
|
+
} else {
|
|
633
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
public void deleteInboxMessagesForIDs(final ReadableArray messageIDs) {
|
|
638
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
639
|
+
if (cleverTap != null) {
|
|
640
|
+
cleverTap.deleteInboxMessagesForIDs(arrayListStringFromReadableArray(messageIDs));
|
|
641
|
+
} else {
|
|
642
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
public void pushInboxNotificationClickedEventForId(String messageId) {
|
|
647
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
648
|
+
if (cleverTap != null) {
|
|
649
|
+
cleverTap.pushInboxNotificationClickedEvent(messageId);
|
|
650
|
+
} else {
|
|
651
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
public void pushInboxNotificationViewedEventForId(String messageId) {
|
|
656
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
657
|
+
if (cleverTap != null) {
|
|
658
|
+
cleverTap.pushInboxNotificationViewedEvent(messageId);
|
|
659
|
+
} else {
|
|
660
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
public void showInbox(ReadableMap styleConfig) {
|
|
665
|
+
CTInboxStyleConfig inboxStyleConfig = styleConfigFromReadableMap(styleConfig);
|
|
666
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
667
|
+
if (cleverTap != null) {
|
|
668
|
+
cleverTap.showAppInbox(inboxStyleConfig);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
public void dismissInbox() {
|
|
673
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
674
|
+
if (cleverTap != null) {
|
|
675
|
+
cleverTap.dismissAppInbox();
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
public void getInitialUrl(Callback callback) {
|
|
680
|
+
String error = null;
|
|
681
|
+
String url = null;
|
|
682
|
+
|
|
683
|
+
if (sLaunchUri == null) {
|
|
684
|
+
error = "CleverTap InitialUrl is null";
|
|
685
|
+
} else {
|
|
686
|
+
url = sLaunchUri.toString();
|
|
687
|
+
}
|
|
688
|
+
callbackWithErrorAndResult(callback, error, url);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
public void getLastFetchTimeStampInMillis(Callback callback) {
|
|
692
|
+
String error = null;
|
|
693
|
+
String result = null;
|
|
694
|
+
|
|
695
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
696
|
+
if (cleverTap != null) {
|
|
697
|
+
CTProductConfigController productConfigController = cleverTap.productConfig();
|
|
698
|
+
if (productConfigController != null) {
|
|
699
|
+
result = String.valueOf(productConfigController.getLastFetchTimeStampInMillis());
|
|
700
|
+
} else {
|
|
701
|
+
error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED;
|
|
702
|
+
}
|
|
703
|
+
} else {
|
|
704
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
705
|
+
}
|
|
706
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
public void getString(String key, Callback callback) {
|
|
710
|
+
String error = null;
|
|
711
|
+
String result = null;
|
|
712
|
+
|
|
713
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
714
|
+
if (cleverTap != null) {
|
|
715
|
+
CTProductConfigController productConfigController = cleverTap.productConfig();
|
|
716
|
+
if (productConfigController != null) {
|
|
717
|
+
result = productConfigController.getString(key);
|
|
718
|
+
} else {
|
|
719
|
+
error = ErrorMessages.PRODUCTCONFIG_NOT_INITIALIZED;
|
|
720
|
+
}
|
|
721
|
+
} else {
|
|
722
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
723
|
+
}
|
|
724
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
public void onUserLogin(ReadableMap profile) {
|
|
728
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
729
|
+
if (clevertap == null) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
Map<String, Object> finalProfile = profileFromReadableMap(profile);
|
|
734
|
+
clevertap.onUserLogin(finalProfile);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
public void profileAddMultiValue(String value, String key) {
|
|
738
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
739
|
+
if (clevertap == null) {
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
clevertap.addMultiValueForKey(key, value);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
public void profileAddMultiValues(ReadableArray values, String key) {
|
|
746
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
747
|
+
if (clevertap == null) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
|
|
751
|
+
clevertap.addMultiValuesForKey(key, finalValues);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
public void profileGetCleverTapAttributionIdentifier(Callback callback) {
|
|
755
|
+
String error = null;
|
|
756
|
+
String result = null;
|
|
757
|
+
|
|
758
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
759
|
+
if (clevertap != null) {
|
|
760
|
+
result = clevertap.getCleverTapAttributionIdentifier();
|
|
761
|
+
} else {
|
|
762
|
+
error = "CleverTap not initialized";
|
|
763
|
+
}
|
|
764
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
public void profileGetCleverTapID(Callback callback) {
|
|
768
|
+
String error = null;
|
|
769
|
+
String result = null;
|
|
770
|
+
|
|
771
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
772
|
+
if (clevertap != null) {
|
|
773
|
+
result = clevertap.getCleverTapID();
|
|
774
|
+
} else {
|
|
775
|
+
error = "CleverTap not initialized";
|
|
776
|
+
}
|
|
777
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
public void getCleverTapID(final Callback callback) {
|
|
781
|
+
final CleverTapAPI clevertap = getCleverTapAPI();
|
|
782
|
+
if (clevertap != null) {
|
|
783
|
+
clevertap.getCleverTapID(new OnInitCleverTapIDListener() {
|
|
784
|
+
@Override
|
|
785
|
+
public void onInitCleverTapID(final String cleverTapID) {
|
|
786
|
+
// Callback on main thread
|
|
787
|
+
callbackWithErrorAndResult(callback, null, cleverTapID);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
});
|
|
791
|
+
} else {
|
|
792
|
+
String error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
793
|
+
callbackWithErrorAndResult(callback, error, null);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
public void profileGetProperty(String propertyName, Callback callback) {
|
|
798
|
+
String error = null;
|
|
799
|
+
Object result = null;
|
|
800
|
+
|
|
801
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
802
|
+
if (clevertap != null) {
|
|
803
|
+
Object value = clevertap.getProperty(propertyName);
|
|
804
|
+
// Handle JSONArray for multi-values, otherwise everything should be primitive or String
|
|
805
|
+
if (value instanceof JSONArray) {
|
|
806
|
+
JSONArray valueArray = (JSONArray) value;
|
|
807
|
+
WritableArray writableArray = Arguments.createArray();
|
|
808
|
+
for (int i = 0; i < valueArray.length(); i++) {
|
|
809
|
+
try {
|
|
810
|
+
writableArray.pushString(valueArray.get(i).toString());
|
|
811
|
+
} catch (JSONException e) {
|
|
812
|
+
//no-op
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
result = writableArray;
|
|
816
|
+
} else {
|
|
817
|
+
result = value;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
} else {
|
|
821
|
+
error = "CleverTap not initialized";
|
|
822
|
+
}
|
|
823
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
public void profileRemoveMultiValue(String value, String key) {
|
|
827
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
828
|
+
if (clevertap == null) {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
clevertap.removeMultiValueForKey(key, value);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
public void profileRemoveMultiValues(ReadableArray values, String key) {
|
|
835
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
836
|
+
if (clevertap == null) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
|
|
840
|
+
clevertap.removeMultiValuesForKey(key, finalValues);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
public void profileRemoveValueForKey(String key) {
|
|
844
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
845
|
+
if (clevertap == null) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
clevertap.removeValueForKey(key);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
public void profileSet(ReadableMap profile) {
|
|
852
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
853
|
+
if (clevertap == null) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
Map<String, Object> finalProfile = profileFromReadableMap(profile);
|
|
858
|
+
clevertap.pushProfile(finalProfile);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
public void profileSetMultiValues(ReadableArray values, String key) {
|
|
862
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
863
|
+
if (clevertap == null) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
ArrayList<String> finalValues = arrayListStringFromReadableArray(values);
|
|
867
|
+
clevertap.setMultiValuesForKey(key, finalValues);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
public void pushDisplayUnitClickedEventForID(String unitID) {
|
|
871
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
872
|
+
if (cleverTap != null) {
|
|
873
|
+
cleverTap.pushDisplayUnitClickedEventForID(unitID);
|
|
874
|
+
} else {
|
|
875
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
public void pushDisplayUnitViewedEventForID(String unitID) {
|
|
880
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
881
|
+
if (cleverTap != null) {
|
|
882
|
+
cleverTap.pushDisplayUnitViewedEventForID(unitID);
|
|
883
|
+
} else {
|
|
884
|
+
Log.e(TAG, ErrorMessages.CLEVERTAP_NOT_INITIALIZED);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
public void pushInstallReferrer(String source, String medium, String campaign) {
|
|
889
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
890
|
+
if (clevertap == null) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
clevertap.pushInstallReferrer(source, medium, campaign);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
public void recordChargedEvent(ReadableMap details, ReadableArray items) {
|
|
897
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
898
|
+
if (clevertap == null || details == null) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
HashMap<String, Object> finalDetails = eventPropsFromReadableMap(details, Object.class);
|
|
903
|
+
|
|
904
|
+
ArrayList<HashMap<String, Object>> finalItems = new ArrayList<>();
|
|
905
|
+
|
|
906
|
+
if (items != null) {
|
|
907
|
+
for (int i = 0; i < items.size(); i++) {
|
|
908
|
+
try {
|
|
909
|
+
HashMap<String, Object> item = eventPropsFromReadableMap(items.getMap(i), Object.class);
|
|
910
|
+
finalItems.add(item);
|
|
911
|
+
} catch (Throwable t) {
|
|
912
|
+
Log.e(TAG, t.getLocalizedMessage());
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
try {
|
|
918
|
+
clevertap.pushChargedEvent(finalDetails, finalItems);
|
|
919
|
+
} catch (Throwable t) {
|
|
920
|
+
Log.e(TAG, t.getLocalizedMessage());
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
public void recordEvent(String eventName, ReadableMap props) {
|
|
925
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
926
|
+
if (clevertap == null) {
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
Map<String, Object> finalProps = eventPropsFromReadableMap(props, Object.class);
|
|
931
|
+
|
|
932
|
+
if (finalProps == null) {
|
|
933
|
+
clevertap.pushEvent(eventName);
|
|
934
|
+
} else {
|
|
935
|
+
clevertap.pushEvent(eventName, finalProps);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
public void recordScreenView(String screenName) {
|
|
940
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
941
|
+
if (clevertap == null) {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
try {
|
|
945
|
+
clevertap.recordScreen(screenName);
|
|
946
|
+
} catch (NullPointerException npe) {
|
|
947
|
+
Log.e(TAG, "Something went wrong in native SDK!");
|
|
948
|
+
npe.printStackTrace();
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
public void registerForPush() {
|
|
953
|
+
// no-op in Android
|
|
954
|
+
Log.i(TAG, "CleverTap.registerForPush is a no-op in Android");
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
public void reset() {
|
|
958
|
+
CTProductConfigController productConfigController = getCtProductConfigController();
|
|
959
|
+
if (productConfigController == null) {
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
productConfigController.reset();
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
@Deprecated(since = "3.2.0")
|
|
967
|
+
public void sessionGetPreviousVisitTime(Callback callback) {
|
|
968
|
+
String error = null;
|
|
969
|
+
int result = -1;
|
|
970
|
+
|
|
971
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
972
|
+
if (clevertap != null) {
|
|
973
|
+
result = clevertap.getPreviousVisitTime();
|
|
974
|
+
} else {
|
|
975
|
+
error = "CleverTap not initialized";
|
|
976
|
+
}
|
|
977
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
public void sessionGetScreenCount(Callback callback) {
|
|
981
|
+
String error = null;
|
|
982
|
+
int result = -1;
|
|
983
|
+
|
|
984
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
985
|
+
if (clevertap != null) {
|
|
986
|
+
result = clevertap.getScreenCount();
|
|
987
|
+
} else {
|
|
988
|
+
error = "CleverTap not initialized";
|
|
989
|
+
}
|
|
990
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
public void sessionGetTimeElapsed(Callback callback) {
|
|
994
|
+
String error = null;
|
|
995
|
+
int result = -1;
|
|
996
|
+
|
|
997
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
998
|
+
if (clevertap != null) {
|
|
999
|
+
result = clevertap.getTimeElapsed();
|
|
1000
|
+
} else {
|
|
1001
|
+
error = "CleverTap not initialized";
|
|
1002
|
+
}
|
|
1003
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
@Deprecated(since = "3.2.0")
|
|
1007
|
+
public void sessionGetTotalVisits(Callback callback) {
|
|
1008
|
+
String error = null;
|
|
1009
|
+
int result = -1;
|
|
1010
|
+
|
|
1011
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
1012
|
+
if (clevertap != null) {
|
|
1013
|
+
result = clevertap.getTotalVisits();
|
|
1014
|
+
} else {
|
|
1015
|
+
error = "CleverTap not initialized";
|
|
1016
|
+
}
|
|
1017
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
public void sessionGetUTMDetails(Callback callback) {
|
|
1021
|
+
String error = null;
|
|
1022
|
+
WritableMap result = null;
|
|
1023
|
+
|
|
1024
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
1025
|
+
if (clevertap != null) {
|
|
1026
|
+
UTMDetail details = clevertap.getUTMDetails();
|
|
1027
|
+
result = utmDetailsToWritableMap(details);
|
|
1028
|
+
} else {
|
|
1029
|
+
error = "CleverTap not initialized";
|
|
1030
|
+
}
|
|
1031
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
public void setDebugLevel(int level) {
|
|
1035
|
+
CleverTapAPI.setDebugLevel(level);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
public void setDefaultsMap(ReadableMap map) {
|
|
1039
|
+
CTProductConfigController productConfigController = getCtProductConfigController();
|
|
1040
|
+
if (productConfigController == null) {
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
HashMap<String, Object> finalMap = eventPropsFromReadableMap(map, Object.class);
|
|
1045
|
+
productConfigController.setDefaults(finalMap);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
public void setLocation(double latitude, double longitude) {
|
|
1049
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
1050
|
+
if (clevertap == null) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
final Location location = new Location("CleverTapReact");
|
|
1054
|
+
location.setLatitude(latitude);
|
|
1055
|
+
location.setLongitude(longitude);
|
|
1056
|
+
clevertap.setLocation(location);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
public void setMinimumFetchIntervalInSeconds(int interval) {
|
|
1060
|
+
CTProductConfigController productConfigController = getCtProductConfigController();
|
|
1061
|
+
if (productConfigController == null) {
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
productConfigController.setMinimumFetchIntervalInSeconds(interval);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
//Sets the SDK to offline mode
|
|
1069
|
+
public void setOffline(boolean value) {
|
|
1070
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
1071
|
+
if (clevertap == null) {
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
clevertap.setOffline(value);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
public void setOptOut(boolean userOptOut, Boolean allowSystemEvents) {
|
|
1078
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
1079
|
+
if (clevertap == null) {
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
if (allowSystemEvents != null) {
|
|
1084
|
+
clevertap.setOptOut(userOptOut, allowSystemEvents);
|
|
1085
|
+
} else {
|
|
1086
|
+
clevertap.setOptOut(userOptOut);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
public void pushRegistrationToken(String token, ReadableMap type) {
|
|
1091
|
+
Logger.v("pushRegistrationToken called with: token = [" + token + "], type = [" + type + "]");
|
|
1092
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
1093
|
+
if (clevertap == null || token == null || type == null) {
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
PushType pushType = pushTypeFromReadableMap(type);
|
|
1098
|
+
if (pushType != null) {
|
|
1099
|
+
clevertap.pushRegistrationToken(token, pushType, true);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
public void setFCMPushTokenAsString(String token) {
|
|
1104
|
+
Logger.v("setFCMPushTokenAsString called with: token = [" + token + "]");
|
|
1105
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
1106
|
+
if (clevertap == null || token == null) {
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
clevertap.pushFcmRegistrationId(token, true);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
// Increment/Decrement Operator
|
|
1113
|
+
public void profileIncrementValueForKey(Double value, String key) {
|
|
1114
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1115
|
+
if (cleverTap != null) {
|
|
1116
|
+
cleverTap.incrementValue(key, value);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
public void profileDecrementValueForKey(Double value, String key) {
|
|
1121
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1122
|
+
if (cleverTap != null) {
|
|
1123
|
+
cleverTap.decrementValue(key, value);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// InApp Controls
|
|
1128
|
+
public void suspendInAppNotifications() {
|
|
1129
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1130
|
+
if (cleverTap != null) {
|
|
1131
|
+
cleverTap.suspendInAppNotifications();
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
public void discardInAppNotifications() {
|
|
1136
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1137
|
+
if (cleverTap != null) {
|
|
1138
|
+
cleverTap.discardInAppNotifications();
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
public void discardInAppNotifications(Boolean dismissInAppIfVisible) {
|
|
1143
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1144
|
+
if (cleverTap != null) {
|
|
1145
|
+
if (dismissInAppIfVisible != null) {
|
|
1146
|
+
cleverTap.discardInAppNotifications(dismissInAppIfVisible);
|
|
1147
|
+
} else {
|
|
1148
|
+
cleverTap.discardInAppNotifications();
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
public void resumeInAppNotifications() {
|
|
1154
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1155
|
+
if (cleverTap != null) {
|
|
1156
|
+
cleverTap.resumeInAppNotifications();
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
public void customTemplateSetDismissed(String templateName, Promise promise) {
|
|
1161
|
+
resolveWithTemplateContext(templateName, promise, templateContext -> {
|
|
1162
|
+
templateContext.setDismissed();
|
|
1163
|
+
return null;
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
public void customTemplateSetPresented(String templateName, Promise promise) {
|
|
1168
|
+
resolveWithTemplateContext(templateName, promise, templateContext -> {
|
|
1169
|
+
templateContext.setPresented();
|
|
1170
|
+
return null;
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
public void customTemplateRunAction(String templateName, String argName, Promise promise) {
|
|
1175
|
+
resolveWithTemplateContext(
|
|
1176
|
+
templateName,
|
|
1177
|
+
promise,
|
|
1178
|
+
customTemplateContext -> {
|
|
1179
|
+
if (customTemplateContext instanceof CustomTemplateContext.TemplateContext) {
|
|
1180
|
+
((CustomTemplateContext.TemplateContext) customTemplateContext).triggerActionArgument(argName, null);
|
|
1181
|
+
}
|
|
1182
|
+
return null;
|
|
1183
|
+
}
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
public void customTemplateGetStringArg(String templateName, String argName, Promise promise) {
|
|
1188
|
+
resolveWithTemplateContext(
|
|
1189
|
+
templateName,
|
|
1190
|
+
promise,
|
|
1191
|
+
templateContext -> templateContext.getString(argName)
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
public void customTemplateGetNumberArg(String templateName, String argName, Promise promise) {
|
|
1196
|
+
resolveWithTemplateContext(
|
|
1197
|
+
templateName,
|
|
1198
|
+
promise,
|
|
1199
|
+
templateContext -> templateContext.getDouble(argName)
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
public void customTemplateGetBooleanArg(String templateName, String argName, Promise promise) {
|
|
1204
|
+
resolveWithTemplateContext(
|
|
1205
|
+
templateName,
|
|
1206
|
+
promise,
|
|
1207
|
+
templateContext -> templateContext.getBoolean(argName)
|
|
1208
|
+
);
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
public void customTemplateGetFileArg(String templateName, String argName, Promise promise) {
|
|
1212
|
+
resolveWithTemplateContext(
|
|
1213
|
+
templateName,
|
|
1214
|
+
promise,
|
|
1215
|
+
templateContext -> templateContext.getFile(argName)
|
|
1216
|
+
);
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
public void customTemplateGetObjectArg(String templateName, String argName, Promise promise) {
|
|
1220
|
+
resolveWithTemplateContext(
|
|
1221
|
+
templateName,
|
|
1222
|
+
promise,
|
|
1223
|
+
templateContext -> {
|
|
1224
|
+
Map<String, Object> mapArg = templateContext.getMap(argName);
|
|
1225
|
+
if (mapArg != null) {
|
|
1226
|
+
return CleverTapUtils.MapUtil.toWritableMap(mapArg);
|
|
1227
|
+
} else {
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
public void customTemplateContextToString(String templateName, Promise promise) {
|
|
1235
|
+
resolveWithTemplateContext(
|
|
1236
|
+
templateName,
|
|
1237
|
+
promise,
|
|
1238
|
+
templateContext -> templateContext.toString()
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
public void syncCustomTemplates() {
|
|
1243
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1244
|
+
if (cleverTap != null) {
|
|
1245
|
+
cleverTap.syncRegisteredInAppTemplates();
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
public void variants(final Callback callback) {
|
|
1250
|
+
WritableArray result = null;
|
|
1251
|
+
String error = null;
|
|
1252
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1253
|
+
if (cleverTap != null) {
|
|
1254
|
+
List<Map<String, Object>> variantsList = cleverTap.variants();
|
|
1255
|
+
result = variantsToWritableArray(variantsList);
|
|
1256
|
+
} else {
|
|
1257
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
1258
|
+
}
|
|
1259
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
private void resolveWithTemplateContext(String templateName, Promise promise, TemplateContextAction action) {
|
|
1263
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1264
|
+
if (cleverTap != null) {
|
|
1265
|
+
CustomTemplateContext templateContext = cleverTap.getActiveContextForTemplate(templateName);
|
|
1266
|
+
if (templateContext != null) {
|
|
1267
|
+
promise.resolve(action.execute(templateContext));
|
|
1268
|
+
} else {
|
|
1269
|
+
promise.reject("CustomTemplateError", "Custom template: " + templateName + " is not currently being presented");
|
|
1270
|
+
}
|
|
1271
|
+
} else {
|
|
1272
|
+
promise.reject("CustomTemplateError", "CleverTap is not initialized");
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
@FunctionalInterface
|
|
1277
|
+
private interface TemplateContextAction {
|
|
1278
|
+
Object execute(CustomTemplateContext context);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/**************************************************
|
|
1282
|
+
* Product Experience Remote Config methods starts
|
|
1283
|
+
*************************************************/
|
|
1284
|
+
public void syncVariables() {
|
|
1285
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1286
|
+
if (cleverTap != null) {
|
|
1287
|
+
cleverTap.syncVariables();
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
public void syncVariablesinProd(boolean isProduction, Callback callback) {
|
|
1292
|
+
Log.i(TAG, "CleverTap syncVariablesinProd is no-op in Android");
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
public void fetchVariables() {
|
|
1296
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1297
|
+
if (cleverTap != null) {
|
|
1298
|
+
cleverTap.fetchVariables();
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
public void defineVariables(ReadableMap object) {
|
|
1303
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1304
|
+
if (cleverTap != null) {
|
|
1305
|
+
for (Map.Entry<String, Object> entry : object.toHashMap().entrySet()) {
|
|
1306
|
+
String key = entry.getKey();
|
|
1307
|
+
Object value = entry.getValue();
|
|
1308
|
+
variables.put(key, cleverTap.defineVariable(key, value));
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
public void defineFileVariable(String name) {
|
|
1314
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1315
|
+
if (cleverTap != null) {
|
|
1316
|
+
variables.put(name, cleverTap.defineFileVariable(name));
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
public void fetchVariables(final Callback callback) {
|
|
1321
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1322
|
+
if (cleverTap != null) {
|
|
1323
|
+
cleverTap.fetchVariables(new FetchVariablesCallback() {
|
|
1324
|
+
@Override
|
|
1325
|
+
public void onVariablesFetched(final boolean isSuccess) {
|
|
1326
|
+
callbackWithErrorAndResult(callback, null, isSuccess);
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
} else {
|
|
1330
|
+
String error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
1331
|
+
callbackWithErrorAndResult(callback, error, null);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
public void getVariable(String key, final Callback callback) {
|
|
1336
|
+
String error = null;
|
|
1337
|
+
Object result = null;
|
|
1338
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1339
|
+
if (cleverTap != null) {
|
|
1340
|
+
try {
|
|
1341
|
+
result = getVariableValue(key);
|
|
1342
|
+
} catch (IllegalArgumentException e) {
|
|
1343
|
+
error = e.getLocalizedMessage();
|
|
1344
|
+
}
|
|
1345
|
+
} else {
|
|
1346
|
+
error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
1347
|
+
}
|
|
1348
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
public void getVariables(final Callback callback) {
|
|
1352
|
+
callbackWithErrorAndResult(callback, null, getVariablesValues());
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
public void onValueChanged(final String name) {
|
|
1356
|
+
if (variables.containsKey(name)) {
|
|
1357
|
+
|
|
1358
|
+
Var<Object> var = (Var<Object>) variables.get(name);
|
|
1359
|
+
if (var != null) {
|
|
1360
|
+
var.addValueChangedCallback(new VariableCallback<Object>() {
|
|
1361
|
+
@Override
|
|
1362
|
+
public void onValueChanged(final Var<Object> variable) {
|
|
1363
|
+
WritableMap result = null;
|
|
1364
|
+
try {
|
|
1365
|
+
result = getVariableValueAsWritableMap(name);
|
|
1366
|
+
} catch (IllegalArgumentException e) {
|
|
1367
|
+
Log.e(TAG, e.getLocalizedMessage());
|
|
1368
|
+
}
|
|
1369
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ON_VALUE_CHANGED, result);
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
} else {
|
|
1373
|
+
Log.d(TAG, "Variable value with name = " + name + " contains null value. Not setting onValueChanged callback.");
|
|
1374
|
+
}
|
|
1375
|
+
} else {
|
|
1376
|
+
Log.e(TAG, "Variable name = " + name + " does not exist. Make sure you set variable first.");
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
public void onFileValueChanged(final String name) {
|
|
1381
|
+
if (variables.containsKey(name)) {
|
|
1382
|
+
|
|
1383
|
+
Var<Object> var = (Var<Object>) variables.get(name);
|
|
1384
|
+
if (var != null) {
|
|
1385
|
+
var.addFileReadyHandler(new VariableCallback<Object>() {
|
|
1386
|
+
@Override
|
|
1387
|
+
public void onValueChanged(final Var<Object> variable) {
|
|
1388
|
+
WritableMap result = null;
|
|
1389
|
+
try {
|
|
1390
|
+
result = getVariableValueAsWritableMap(name);
|
|
1391
|
+
} catch (IllegalArgumentException e) {
|
|
1392
|
+
Log.e(TAG, e.getLocalizedMessage());
|
|
1393
|
+
}
|
|
1394
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ON_FILE_VALUE_CHANGED, result);
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
} else {
|
|
1398
|
+
Log.d(TAG, "File variable object with name = " + name + " contains null value. Not setting onFileValueChanged callback.");
|
|
1399
|
+
}
|
|
1400
|
+
} else {
|
|
1401
|
+
Log.e(TAG, "File variable name = " + name + " does not exist. Make sure you set file variable first.");
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
public void onVariablesChanged() {
|
|
1406
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1407
|
+
if (cleverTap != null) {
|
|
1408
|
+
cleverTap.addVariablesChangedCallback(new VariablesChangedCallback() {
|
|
1409
|
+
@Override
|
|
1410
|
+
public void variablesChanged() {
|
|
1411
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ON_VARIABLES_CHANGED, getVariablesValues());
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
public void onOneTimeVariablesChanged() {
|
|
1418
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1419
|
+
if (cleverTap != null) {
|
|
1420
|
+
cleverTap.addOneTimeVariablesChangedCallback(new VariablesChangedCallback() {
|
|
1421
|
+
@Override
|
|
1422
|
+
public void variablesChanged() {
|
|
1423
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ON_ONE_TIME_VARIABLES_CHANGED, getVariablesValues());
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
public void onVariablesChangedAndNoDownloadsPending() {
|
|
1430
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1431
|
+
if (cleverTap != null) {
|
|
1432
|
+
cleverTap.onVariablesChangedAndNoDownloadsPending(new VariablesChangedCallback() {
|
|
1433
|
+
@Override
|
|
1434
|
+
public void variablesChanged() {
|
|
1435
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ON_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING,
|
|
1436
|
+
getVariablesValues());
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
public void onceVariablesChangedAndNoDownloadsPending() {
|
|
1443
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1444
|
+
if (cleverTap != null) {
|
|
1445
|
+
cleverTap.onceVariablesChangedAndNoDownloadsPending(new VariablesChangedCallback() {
|
|
1446
|
+
@Override
|
|
1447
|
+
public void variablesChanged() {
|
|
1448
|
+
sendEvent(CleverTapEvent.CLEVERTAP_ONCE_VARIABLES_CHANGED_AND_NO_DOWNLOADS_PENDING,
|
|
1449
|
+
getVariablesValues());
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
/************************************************
|
|
1456
|
+
* Product Experience Remote Config methods ends
|
|
1457
|
+
************************************************/
|
|
1458
|
+
|
|
1459
|
+
public void clearInAppResources(final boolean expiredOnly) {
|
|
1460
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1461
|
+
if (cleverTap != null) {
|
|
1462
|
+
cleverTap.clearInAppResources(expiredOnly);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
public void fetchInApps(final Callback callback) {
|
|
1467
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1468
|
+
if (cleverTap != null) {
|
|
1469
|
+
cleverTap.fetchInApps(new FetchInAppsCallback() {
|
|
1470
|
+
@Override
|
|
1471
|
+
public void onInAppsFetched(final boolean isSuccess) {
|
|
1472
|
+
callbackWithErrorAndResult(callback, null, isSuccess);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
} else {
|
|
1476
|
+
String error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED;
|
|
1477
|
+
callbackWithErrorAndResult(callback, error, null);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
public void onEventListenerAdded(String eventName) {
|
|
1482
|
+
CleverTapEvent event = CleverTapEvent.fromName(eventName);
|
|
1483
|
+
if (event == null) {
|
|
1484
|
+
Log.e(TAG, "Event listener added for unsupported event " + eventName);
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
// disable the buffering for the specified event as it already has attached listener and
|
|
1488
|
+
// flush all buffered events
|
|
1489
|
+
CleverTapEventEmitter.INSTANCE.disableBuffer(event);
|
|
1490
|
+
CleverTapEventEmitter.INSTANCE.flushBuffer(event);
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
private void enableEventEmitter(ReactContext reactContext) {
|
|
1494
|
+
CleverTapEventEmitter.INSTANCE.setReactContext(reactContext);
|
|
1495
|
+
// disable buffers after a delay in order to give some time for event listeners to attach
|
|
1496
|
+
// and receive initially buffered events. After that all buffers will be cleared and disabled
|
|
1497
|
+
// and events will continue to be sent immediately.
|
|
1498
|
+
new Handler().postDelayed(() -> CleverTapEventEmitter.INSTANCE.resetAllBuffers(false), 5000);
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/**
|
|
1502
|
+
* result must be primitive, String or com.facebook.react.bridge.WritableArray/WritableMap
|
|
1503
|
+
* see https://github.com/facebook/react-native/issues/3101#issuecomment-143954448
|
|
1504
|
+
*/
|
|
1505
|
+
private void callbackWithErrorAndResult(Callback callback, String error, Object result) {
|
|
1506
|
+
if (callback == null) {
|
|
1507
|
+
Log.i(TAG, "CleverTap callback is null");
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
try {
|
|
1511
|
+
callback.invoke(error, result);
|
|
1512
|
+
} catch (Throwable t) {
|
|
1513
|
+
Log.e(TAG, t.getLocalizedMessage());
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
private Object getVariableValue(String name) {
|
|
1518
|
+
if (variables.containsKey(name)) {
|
|
1519
|
+
Var<?> variable = (Var<?>) variables.get(name);
|
|
1520
|
+
Object variableValue = variable.value();
|
|
1521
|
+
Object value;
|
|
1522
|
+
switch (variable.kind()) {
|
|
1523
|
+
case CTVariableUtils.DICTIONARY:
|
|
1524
|
+
value = CleverTapUtils.MapUtil.toWritableMap((Map<String, Object>) variableValue);
|
|
1525
|
+
break;
|
|
1526
|
+
default:
|
|
1527
|
+
value = variableValue;
|
|
1528
|
+
}
|
|
1529
|
+
return value;
|
|
1530
|
+
}
|
|
1531
|
+
throw new IllegalArgumentException(
|
|
1532
|
+
"Variable name = " + name + " does not exist. Make sure you set variable first.");
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
private WritableMap getVariableValueAsWritableMap(String name) {
|
|
1536
|
+
if (variables.containsKey(name)) {
|
|
1537
|
+
Var<?> variable = (Var<?>) variables.get(name);
|
|
1538
|
+
Object variableValue = variable.value();
|
|
1539
|
+
return CleverTapUtils.MapUtil.addValue(name, variable.value());
|
|
1540
|
+
}
|
|
1541
|
+
throw new IllegalArgumentException(
|
|
1542
|
+
"Variable name = " + name + " does not exist.");
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
private WritableMap getVariablesValues() {
|
|
1546
|
+
WritableMap writableMap = Arguments.createMap();
|
|
1547
|
+
for (Map.Entry<String, Object> entry : variables.entrySet()) {
|
|
1548
|
+
String key = entry.getKey();
|
|
1549
|
+
Var<?> variable = (Var<?>) entry.getValue();
|
|
1550
|
+
|
|
1551
|
+
WritableMap variableWritableMap = CleverTapUtils.MapUtil.addValue(key, variable.value());
|
|
1552
|
+
writableMap.merge(variableWritableMap);
|
|
1553
|
+
}
|
|
1554
|
+
return writableMap;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
private boolean checkKitkatVersion(String methodName) {
|
|
1558
|
+
if (VERSION.SDK_INT < VERSION_CODES.KITKAT) {
|
|
1559
|
+
Log.e(TAG, "Call requires API level 19 (current min is " + VERSION.SDK_INT + "):" + methodName);
|
|
1560
|
+
return false;
|
|
1561
|
+
}
|
|
1562
|
+
return true;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
private PushType pushTypeFromReadableMap(ReadableMap readableMap) {
|
|
1566
|
+
String type = readableMap.getString("type");
|
|
1567
|
+
String prefKey = readableMap.getString("prefKey");
|
|
1568
|
+
|
|
1569
|
+
if (type == null || prefKey == null) {
|
|
1570
|
+
return null;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
return new PushType(
|
|
1574
|
+
type,
|
|
1575
|
+
prefKey,
|
|
1576
|
+
readableMap.getString("className"),
|
|
1577
|
+
readableMap.getString("messagingSDKClassName"));
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
@SuppressWarnings("SameParameterValue")
|
|
1581
|
+
private <T> HashMap<String, T> eventPropsFromReadableMap(ReadableMap propsMap, Class<T> tClass) {
|
|
1582
|
+
if (propsMap == null) {
|
|
1583
|
+
return null;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
HashMap<String, T> props = new HashMap<>();
|
|
1587
|
+
|
|
1588
|
+
ReadableMapKeySetIterator iterator = propsMap.keySetIterator();
|
|
1589
|
+
|
|
1590
|
+
while (iterator.hasNextKey()) {
|
|
1591
|
+
try {
|
|
1592
|
+
String key = iterator.nextKey();
|
|
1593
|
+
ReadableType readableType = propsMap.getType(key);
|
|
1594
|
+
|
|
1595
|
+
if (readableType == ReadableType.String) {
|
|
1596
|
+
props.put(key, tClass.cast(propsMap.getString(key)));
|
|
1597
|
+
} else if (readableType == ReadableType.Boolean) {
|
|
1598
|
+
props.put(key, tClass.cast(propsMap.getBoolean(key)));
|
|
1599
|
+
} else if (readableType == ReadableType.Number) {
|
|
1600
|
+
try {
|
|
1601
|
+
props.put(key, tClass.cast(propsMap.getDouble(key)));
|
|
1602
|
+
} catch (Throwable t) {
|
|
1603
|
+
try {
|
|
1604
|
+
props.put(key, tClass.cast(propsMap.getInt(key)));
|
|
1605
|
+
} catch (Throwable t1) {
|
|
1606
|
+
Log.e(TAG, "Unhandled ReadableType.Number from ReadableMap");
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
} else if (readableType == ReadableType.Map) {
|
|
1610
|
+
try {
|
|
1611
|
+
ReadableMap nestedMap = propsMap.getMap(key);
|
|
1612
|
+
if (nestedMap != null) {
|
|
1613
|
+
props.put(key, tClass.cast(CleverTapUtils.MapUtil.toMap(nestedMap)));
|
|
1614
|
+
}
|
|
1615
|
+
} catch (Throwable t) {
|
|
1616
|
+
Log.e(TAG, "Unhandled ReadableType.Map from ReadableMap");
|
|
1617
|
+
}
|
|
1618
|
+
} else if (readableType == ReadableType.Array) {
|
|
1619
|
+
try {
|
|
1620
|
+
ReadableArray nestedArray = propsMap.getArray(key);
|
|
1621
|
+
if (nestedArray != null) {
|
|
1622
|
+
props.put(key, tClass.cast(CleverTapUtils.MapUtil.ArrayUtil.toArray(nestedArray)));
|
|
1623
|
+
}
|
|
1624
|
+
} catch (Throwable t) {
|
|
1625
|
+
Log.e(TAG, "Unhandled ReadableType.Array from ReadableMap");
|
|
1626
|
+
}
|
|
1627
|
+
} else {
|
|
1628
|
+
Log.e(TAG, "Unhandled event property ReadableType");
|
|
1629
|
+
}
|
|
1630
|
+
} catch (Throwable t) {
|
|
1631
|
+
Log.e(TAG, t.getLocalizedMessage());
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
return props;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
private void initCtInstance(CleverTapAPI clevertap) {
|
|
1638
|
+
clevertap.setLibrary("React-Native");
|
|
1639
|
+
CleverTapListenerProxy.INSTANCE.attachToInstance(clevertap);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
private CleverTapAPI getCleverTapAPI() {
|
|
1643
|
+
if (mCleverTap == null) {
|
|
1644
|
+
CleverTapAPI clevertap = CleverTapAPI.getDefaultInstance(this.context);
|
|
1645
|
+
if (clevertap != null) {
|
|
1646
|
+
initCtInstance(clevertap);
|
|
1647
|
+
}
|
|
1648
|
+
mCleverTap = clevertap;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
return mCleverTap;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
public void setInstanceWithAccountId(String accountId) {
|
|
1655
|
+
if (mCleverTap == null || !accountId.equals(mCleverTap.getAccountId())) {
|
|
1656
|
+
CleverTapAPI cleverTap = CleverTapAPI.getGlobalInstance(this.context, accountId);
|
|
1657
|
+
if (cleverTap != null) {
|
|
1658
|
+
initCtInstance(cleverTap);
|
|
1659
|
+
mCleverTap = cleverTap;
|
|
1660
|
+
Log.i(TAG, "CleverTap instance changed for accountId " + accountId);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
private CTProductConfigController getCtProductConfigController() {
|
|
1666
|
+
CleverTapAPI clevertap = getCleverTapAPI();
|
|
1667
|
+
if (clevertap == null) {
|
|
1668
|
+
return null;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
return clevertap.productConfig();
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
private void getInboxMessages(Callback callback, InBoxMessages type) {
|
|
1675
|
+
String error = null;
|
|
1676
|
+
ArrayList<CTInboxMessage> inboxMessages = new ArrayList<>();
|
|
1677
|
+
WritableArray result = Arguments.createArray();
|
|
1678
|
+
|
|
1679
|
+
CleverTapAPI cleverTap = getCleverTapAPI();
|
|
1680
|
+
if (cleverTap != null) {
|
|
1681
|
+
|
|
1682
|
+
if (type == InBoxMessages.ALL) {
|
|
1683
|
+
inboxMessages = cleverTap.getAllInboxMessages();
|
|
1684
|
+
} else if (type == InBoxMessages.UNREAD) {
|
|
1685
|
+
inboxMessages = cleverTap.getUnreadInboxMessages();
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
for (CTInboxMessage message : inboxMessages) {
|
|
1689
|
+
if (message != null && message.getData() != null) {
|
|
1690
|
+
result.pushMap(convertObjectToWritableMap(message.getData()));
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
} else {
|
|
1694
|
+
error = "CleverTap not initialized";
|
|
1695
|
+
}
|
|
1696
|
+
callbackWithErrorAndResult(callback, error, result);
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
private HashMap<String, Object> profileFromReadableMap(ReadableMap profileMap) {
|
|
1700
|
+
if (profileMap == null) {
|
|
1701
|
+
return null;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
HashMap<String, Object> profile = new HashMap<>();
|
|
1705
|
+
|
|
1706
|
+
ReadableMapKeySetIterator iterator = profileMap.keySetIterator();
|
|
1707
|
+
|
|
1708
|
+
while (iterator.hasNextKey()) {
|
|
1709
|
+
try {
|
|
1710
|
+
String key = iterator.nextKey();
|
|
1711
|
+
ReadableType readableType = profileMap.getType(key);
|
|
1712
|
+
|
|
1713
|
+
if ("DOB".equals(key) && (readableType == ReadableType.String) && !profileMap.getString(key).startsWith("$D_")) {
|
|
1714
|
+
String dob = profileMap.getString(key);
|
|
1715
|
+
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
|
|
1716
|
+
try {
|
|
1717
|
+
Date date = format.parse(dob);
|
|
1718
|
+
profile.put(key, date);
|
|
1719
|
+
} catch (Throwable t) {
|
|
1720
|
+
Log.e(TAG, t.getLocalizedMessage());
|
|
1721
|
+
}
|
|
1722
|
+
} else if (readableType == ReadableType.String) {
|
|
1723
|
+
profile.put(key, profileMap.getString(key));
|
|
1724
|
+
} else if (readableType == ReadableType.Boolean) {
|
|
1725
|
+
profile.put(key, profileMap.getBoolean(key));
|
|
1726
|
+
} else if (readableType == ReadableType.Number) {
|
|
1727
|
+
try {
|
|
1728
|
+
profile.put(key, profileMap.getDouble(key));
|
|
1729
|
+
} catch (Throwable t) {
|
|
1730
|
+
try {
|
|
1731
|
+
profile.put(key, profileMap.getInt(key));
|
|
1732
|
+
} catch (Throwable t1) {
|
|
1733
|
+
Log.e(TAG, "Unhandled ReadableType.Number from ReadableMap");
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
} else if (readableType == ReadableType.Array) {
|
|
1737
|
+
try {
|
|
1738
|
+
profile.put(key, arrayListStringFromReadableArray(profileMap.getArray(key)));
|
|
1739
|
+
} catch (Throwable t) {
|
|
1740
|
+
Log.e(TAG, "Unhandled ReadableType.Array from ReadableMap");
|
|
1741
|
+
}
|
|
1742
|
+
} else if (readableType == ReadableType.Map) {
|
|
1743
|
+
try {
|
|
1744
|
+
ReadableMap nestedMap = profileMap.getMap(key);
|
|
1745
|
+
if (nestedMap != null) {
|
|
1746
|
+
profile.put(key, CleverTapUtils.MapUtil.toMap(nestedMap));
|
|
1747
|
+
}
|
|
1748
|
+
} catch (Throwable t) {
|
|
1749
|
+
Log.e(TAG, "Unhandled ReadableType.Map from ReadableMap");
|
|
1750
|
+
}
|
|
1751
|
+
} else {
|
|
1752
|
+
Log.e(TAG, "Unhandled profile property ReadableType");
|
|
1753
|
+
}
|
|
1754
|
+
} catch (Throwable t) {
|
|
1755
|
+
Log.e(TAG, t.getLocalizedMessage());
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
return profile;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
private void sendEvent(@NonNull CleverTapEvent eventName, @Nullable Object params) {
|
|
1762
|
+
CleverTapEventEmitter.INSTANCE.emit(eventName, params);
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* retrieves the localInAppConfig from the given ReadableMap.
|
|
1767
|
+
*
|
|
1768
|
+
* @param readableMap - the map config, received from the host application
|
|
1769
|
+
* @return the Json of the localInAppConfig
|
|
1770
|
+
*/
|
|
1771
|
+
private JSONObject localInAppConfigFromReadableMap(ReadableMap readableMap) {
|
|
1772
|
+
if (readableMap == null) {
|
|
1773
|
+
return null;
|
|
1774
|
+
}
|
|
1775
|
+
CTLocalInApp.InAppType inAppType = null;
|
|
1776
|
+
String titleText = null, messageText = null, positiveBtnText = null, negativeBtnText = null,
|
|
1777
|
+
backgroundColor = null, btnBorderColor = null, titleTextColor = null, messageTextColor = null,
|
|
1778
|
+
btnTextColor = null, imageUrl = null, btnBackgroundColor = null, btnBorderRadius = null, altText = null;
|
|
1779
|
+
boolean fallbackToSettings = false, followDeviceOrientation = false;
|
|
1780
|
+
|
|
1781
|
+
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
1782
|
+
while (iterator.hasNextKey()) {
|
|
1783
|
+
try {
|
|
1784
|
+
String configKey = iterator.nextKey();
|
|
1785
|
+
ReadableType readableType = readableMap.getType(configKey);
|
|
1786
|
+
if ("inAppType".equals(configKey) && readableType == ReadableType.String) {
|
|
1787
|
+
inAppType = inAppTypeFromString(readableMap.getString(configKey));
|
|
1788
|
+
}
|
|
1789
|
+
if ("titleText".equals(configKey) && readableType == ReadableType.String) {
|
|
1790
|
+
titleText = readableMap.getString(configKey);
|
|
1791
|
+
}
|
|
1792
|
+
if ("messageText".equals(configKey) && readableType == ReadableType.String) {
|
|
1793
|
+
messageText = readableMap.getString(configKey);
|
|
1794
|
+
}
|
|
1795
|
+
if ("followDeviceOrientation".equals(configKey) && readableType == ReadableType.Boolean) {
|
|
1796
|
+
followDeviceOrientation = readableMap.getBoolean(configKey);
|
|
1797
|
+
}
|
|
1798
|
+
if ("positiveBtnText".equals(configKey) && readableType == ReadableType.String) {
|
|
1799
|
+
positiveBtnText = readableMap.getString(configKey);
|
|
1800
|
+
}
|
|
1801
|
+
if ("negativeBtnText".equals(configKey) && readableType == ReadableType.String) {
|
|
1802
|
+
negativeBtnText = readableMap.getString(configKey);
|
|
1803
|
+
}
|
|
1804
|
+
if ("fallbackToSettings".equals(configKey) && readableType == ReadableType.Boolean) {
|
|
1805
|
+
fallbackToSettings = readableMap.getBoolean(configKey);
|
|
1806
|
+
}
|
|
1807
|
+
if ("backgroundColor".equals(configKey) && readableType == ReadableType.String) {
|
|
1808
|
+
backgroundColor = readableMap.getString(configKey);
|
|
1809
|
+
}
|
|
1810
|
+
if ("btnBorderColor".equals(configKey) && readableType == ReadableType.String) {
|
|
1811
|
+
btnBorderColor = readableMap.getString(configKey);
|
|
1812
|
+
}
|
|
1813
|
+
if ("titleTextColor".equals(configKey) && readableType == ReadableType.String) {
|
|
1814
|
+
titleTextColor = readableMap.getString(configKey);
|
|
1815
|
+
}
|
|
1816
|
+
if ("messageTextColor".equals(configKey) && readableType == ReadableType.String) {
|
|
1817
|
+
messageTextColor = readableMap.getString(configKey);
|
|
1818
|
+
}
|
|
1819
|
+
if ("btnTextColor".equals(configKey) && readableType == ReadableType.String) {
|
|
1820
|
+
btnTextColor = readableMap.getString(configKey);
|
|
1821
|
+
}
|
|
1822
|
+
if ("imageUrl".equals(configKey) && readableType == ReadableType.String) {
|
|
1823
|
+
imageUrl = readableMap.getString(configKey);
|
|
1824
|
+
}
|
|
1825
|
+
if ("altText".equals(configKey) && readableType == ReadableType.String) {
|
|
1826
|
+
altText = readableMap.getString(configKey);
|
|
1827
|
+
}
|
|
1828
|
+
if ("btnBackgroundColor".equals(configKey) && readableType == ReadableType.String) {
|
|
1829
|
+
btnBackgroundColor = readableMap.getString(configKey);
|
|
1830
|
+
}
|
|
1831
|
+
if ("btnBorderRadius".equals(configKey) && readableType == ReadableType.String) {
|
|
1832
|
+
btnBorderRadius = readableMap.getString(configKey);
|
|
1833
|
+
}
|
|
1834
|
+
} catch (Throwable t) {
|
|
1835
|
+
Log.e(TAG, "invalid parameters in push primer config" + t.getLocalizedMessage());
|
|
1836
|
+
return null;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
//creates the builder instance of localInApp with all the required parameters
|
|
1841
|
+
CTLocalInApp.Builder.Builder6 builderWithRequiredParams = getLocalInAppBuilderWithRequiredParam(
|
|
1842
|
+
inAppType, titleText, messageText, followDeviceOrientation, positiveBtnText, negativeBtnText
|
|
1843
|
+
);
|
|
1844
|
+
|
|
1845
|
+
//adds the optional parameters to the builder instance
|
|
1846
|
+
if (backgroundColor != null) {
|
|
1847
|
+
builderWithRequiredParams.setBackgroundColor(backgroundColor);
|
|
1848
|
+
}
|
|
1849
|
+
if (btnBorderColor != null) {
|
|
1850
|
+
builderWithRequiredParams.setBtnBorderColor(btnBorderColor);
|
|
1851
|
+
}
|
|
1852
|
+
if (titleTextColor != null) {
|
|
1853
|
+
builderWithRequiredParams.setTitleTextColor(titleTextColor);
|
|
1854
|
+
}
|
|
1855
|
+
if (messageTextColor != null) {
|
|
1856
|
+
builderWithRequiredParams.setMessageTextColor(messageTextColor);
|
|
1857
|
+
}
|
|
1858
|
+
if (btnTextColor != null) {
|
|
1859
|
+
builderWithRequiredParams.setBtnTextColor(btnTextColor);
|
|
1860
|
+
}
|
|
1861
|
+
if (imageUrl != null) {
|
|
1862
|
+
builderWithRequiredParams.setImageUrl(imageUrl, altText);
|
|
1863
|
+
}
|
|
1864
|
+
if (btnBackgroundColor != null) {
|
|
1865
|
+
builderWithRequiredParams.setBtnBackgroundColor(btnBackgroundColor);
|
|
1866
|
+
}
|
|
1867
|
+
if (btnBorderRadius != null) {
|
|
1868
|
+
builderWithRequiredParams.setBtnBorderRadius(btnBorderRadius);
|
|
1869
|
+
}
|
|
1870
|
+
builderWithRequiredParams.setFallbackToSettings(fallbackToSettings);
|
|
1871
|
+
|
|
1872
|
+
JSONObject localInAppConfig = builderWithRequiredParams.build();
|
|
1873
|
+
Log.i(TAG, "LocalInAppConfig for push primer prompt: " + localInAppConfig);
|
|
1874
|
+
return localInAppConfig;
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
/**
|
|
1878
|
+
* Creates an instance of the {@link CTLocalInApp.Builder.Builder6} with the required parameters.
|
|
1879
|
+
*
|
|
1880
|
+
* @return the {@link CTLocalInApp.Builder.Builder6} instance
|
|
1881
|
+
*/
|
|
1882
|
+
private CTLocalInApp.Builder.Builder6 getLocalInAppBuilderWithRequiredParam(CTLocalInApp.InAppType inAppType,
|
|
1883
|
+
String titleText,
|
|
1884
|
+
String messageText,
|
|
1885
|
+
boolean followDeviceOrientation,
|
|
1886
|
+
String positiveBtnText,
|
|
1887
|
+
String negativeBtnText) {
|
|
1888
|
+
//throws exception if any of the required parameter is missing
|
|
1889
|
+
if (inAppType == null || titleText == null || messageText == null || positiveBtnText == null
|
|
1890
|
+
|| negativeBtnText == null) {
|
|
1891
|
+
throw new IllegalArgumentException("mandatory parameters are missing in push primer config");
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
CTLocalInApp.Builder builder = CTLocalInApp.builder();
|
|
1895
|
+
return builder.setInAppType(inAppType)
|
|
1896
|
+
.setTitleText(titleText)
|
|
1897
|
+
.setMessageText(messageText)
|
|
1898
|
+
.followDeviceOrientation(followDeviceOrientation)
|
|
1899
|
+
.setPositiveBtnText(positiveBtnText)
|
|
1900
|
+
.setNegativeBtnText(negativeBtnText);
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
//returns InAppType type from the given string
|
|
1904
|
+
private CTLocalInApp.InAppType inAppTypeFromString(String inAppType) {
|
|
1905
|
+
if (inAppType == null) {
|
|
1906
|
+
return null;
|
|
1907
|
+
}
|
|
1908
|
+
switch (inAppType) {
|
|
1909
|
+
case "half-interstitial":
|
|
1910
|
+
return CTLocalInApp.InAppType.HALF_INTERSTITIAL;
|
|
1911
|
+
case "alert":
|
|
1912
|
+
return CTLocalInApp.InAppType.ALERT;
|
|
1913
|
+
default:
|
|
1914
|
+
return null;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
private CTInboxStyleConfig styleConfigFromReadableMap(ReadableMap styleConfig) {
|
|
1919
|
+
if (styleConfig == null) {
|
|
1920
|
+
return new CTInboxStyleConfig();
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
CTInboxStyleConfig ctInboxStyleConfig = new CTInboxStyleConfig();
|
|
1924
|
+
ReadableMapKeySetIterator iterator = styleConfig.keySetIterator();
|
|
1925
|
+
while (iterator.hasNextKey()) {
|
|
1926
|
+
try {
|
|
1927
|
+
String styleConfigKey = iterator.nextKey();
|
|
1928
|
+
ReadableType readableType = styleConfig.getType(styleConfigKey);
|
|
1929
|
+
if ("navBarTitle".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1930
|
+
String navBarTitle = styleConfig.getString(styleConfigKey);
|
|
1931
|
+
ctInboxStyleConfig.setNavBarTitle(navBarTitle);
|
|
1932
|
+
}
|
|
1933
|
+
if ("navBarTitleColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1934
|
+
String navBarTitleColor = styleConfig.getString(styleConfigKey);
|
|
1935
|
+
ctInboxStyleConfig.setNavBarTitleColor(navBarTitleColor);
|
|
1936
|
+
}
|
|
1937
|
+
if ("navBarColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1938
|
+
String navBarColor = styleConfig.getString(styleConfigKey);
|
|
1939
|
+
ctInboxStyleConfig.setNavBarColor(navBarColor);
|
|
1940
|
+
}
|
|
1941
|
+
if ("inboxBackgroundColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1942
|
+
String inboxBackgroundColor = styleConfig.getString(styleConfigKey);
|
|
1943
|
+
ctInboxStyleConfig.setInboxBackgroundColor(inboxBackgroundColor);
|
|
1944
|
+
}
|
|
1945
|
+
if ("backButtonColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1946
|
+
String backButtonColor = styleConfig.getString(styleConfigKey);
|
|
1947
|
+
ctInboxStyleConfig.setBackButtonColor(backButtonColor);
|
|
1948
|
+
}
|
|
1949
|
+
if ("unselectedTabColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1950
|
+
String unselectedTabColor = styleConfig.getString(styleConfigKey);
|
|
1951
|
+
ctInboxStyleConfig.setUnselectedTabColor(unselectedTabColor);
|
|
1952
|
+
}
|
|
1953
|
+
if ("selectedTabColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1954
|
+
String selectedTabColor = styleConfig.getString(styleConfigKey);
|
|
1955
|
+
ctInboxStyleConfig.setSelectedTabColor(selectedTabColor);
|
|
1956
|
+
}
|
|
1957
|
+
if ("selectedTabIndicatorColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1958
|
+
String selectedTabIndicatorColor = styleConfig.getString(styleConfigKey);
|
|
1959
|
+
ctInboxStyleConfig.setSelectedTabIndicatorColor(selectedTabIndicatorColor);
|
|
1960
|
+
}
|
|
1961
|
+
if ("tabBackgroundColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1962
|
+
String tabBackgroundColor = styleConfig.getString(styleConfigKey);
|
|
1963
|
+
ctInboxStyleConfig.setTabBackgroundColor(tabBackgroundColor);
|
|
1964
|
+
}
|
|
1965
|
+
if ("tabs".equals(styleConfigKey) && readableType == ReadableType.Array) {
|
|
1966
|
+
try {
|
|
1967
|
+
ArrayList<String> tabsList = arrayListStringFromReadableArray(
|
|
1968
|
+
styleConfig.getArray(styleConfigKey));
|
|
1969
|
+
ctInboxStyleConfig.setTabs(tabsList);
|
|
1970
|
+
} catch (Throwable t) {
|
|
1971
|
+
Log.e(TAG, "Unhandled ReadableType.Array from ReadableMap");
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
if ("noMessageText".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1976
|
+
String noMessageTitle = styleConfig.getString(styleConfigKey);
|
|
1977
|
+
ctInboxStyleConfig.setNoMessageViewText(noMessageTitle);
|
|
1978
|
+
}
|
|
1979
|
+
if ("noMessageTextColor".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1980
|
+
String noMessageTitleColor = styleConfig.getString(styleConfigKey);
|
|
1981
|
+
ctInboxStyleConfig.setNoMessageViewTextColor(noMessageTitleColor);
|
|
1982
|
+
}
|
|
1983
|
+
if ("firstTabTitle".equals(styleConfigKey) && readableType == ReadableType.String) {
|
|
1984
|
+
String firstTabTitle = styleConfig.getString(styleConfigKey);
|
|
1985
|
+
ctInboxStyleConfig.setFirstTabTitle(firstTabTitle);
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
} catch (Throwable t) {
|
|
1989
|
+
Log.e(TAG, t.getLocalizedMessage());
|
|
1990
|
+
return new CTInboxStyleConfig();
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
return ctInboxStyleConfig;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
private static ArrayList<String> arrayListStringFromReadableArray(ReadableArray readableArray) {
|
|
1997
|
+
ArrayList<String> array = new ArrayList<>();
|
|
1998
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
1999
|
+
switch (readableArray.getType(i)) {
|
|
2000
|
+
case Null:
|
|
2001
|
+
break;
|
|
2002
|
+
case Boolean:
|
|
2003
|
+
array.add(String.valueOf(readableArray.getBoolean(i)));
|
|
2004
|
+
break;
|
|
2005
|
+
case Number:
|
|
2006
|
+
array.add(String.valueOf(readableArray.getDouble(i)));
|
|
2007
|
+
break;
|
|
2008
|
+
case String:
|
|
2009
|
+
array.add(readableArray.getString(i));
|
|
2010
|
+
break;
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
return array;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
public static WritableArray variantsToWritableArray(List<Map<String, Object>> variantsList) {
|
|
2017
|
+
WritableArray result = Arguments.createArray();
|
|
2018
|
+
if (variantsList != null) {
|
|
2019
|
+
result = CleverTapUtils.MapUtil.ArrayUtil.toWritableArray(new ArrayList<>(variantsList));
|
|
2020
|
+
}
|
|
2021
|
+
return result;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
private static WritableMap eventLogToWritableMap(UserEventLog eventLog) {
|
|
2025
|
+
WritableMap ret = Arguments.createMap();
|
|
2026
|
+
|
|
2027
|
+
if (eventLog != null) {
|
|
2028
|
+
ret.putString("eventName", eventLog.getEventName());
|
|
2029
|
+
ret.putString("normalizedEventName", eventLog.getNormalizedEventName());
|
|
2030
|
+
ret.putDouble("firstTime", eventLog.getFirstTs());
|
|
2031
|
+
ret.putDouble("lastTime", eventLog.getLastTs());
|
|
2032
|
+
ret.putInt("count", eventLog.getCountOfEvents());
|
|
2033
|
+
ret.putString("deviceID", eventLog.getDeviceID());
|
|
2034
|
+
}
|
|
2035
|
+
return ret;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
private static WritableMap eventLogHistoryToWritableMap(Map<String, UserEventLog> history) {
|
|
2039
|
+
WritableMap ret = Arguments.createMap();
|
|
2040
|
+
|
|
2041
|
+
if (history != null) {
|
|
2042
|
+
for (String key : history.keySet()) {
|
|
2043
|
+
ret.putMap(key, eventLogToWritableMap(history.get(key)));
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
return ret;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
@Deprecated(since = "3.2.0")
|
|
2050
|
+
private static WritableMap eventDetailToWritableMap(EventDetail details) {
|
|
2051
|
+
WritableMap ret = Arguments.createMap();
|
|
2052
|
+
|
|
2053
|
+
if (details != null) {
|
|
2054
|
+
ret.putString("name", details.getName());
|
|
2055
|
+
ret.putInt("firstTime", details.getFirstTime());
|
|
2056
|
+
ret.putInt("lastTime", details.getLastTime());
|
|
2057
|
+
ret.putInt("count", details.getCount());
|
|
2058
|
+
}
|
|
2059
|
+
return ret;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
@Deprecated(since = "3.2.0")
|
|
2063
|
+
private static WritableMap eventHistoryToWritableMap(Map<String, EventDetail> history) {
|
|
2064
|
+
WritableMap ret = Arguments.createMap();
|
|
2065
|
+
|
|
2066
|
+
if (history != null) {
|
|
2067
|
+
for (String key : history.keySet()) {
|
|
2068
|
+
ret.putMap(key, eventDetailToWritableMap(history.get(key)));
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
return ret;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
private static JSONArray jsonArrayFromReadableArray(ReadableArray readableArray) throws JSONException {
|
|
2075
|
+
JSONArray array = new JSONArray();
|
|
2076
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
2077
|
+
switch (readableArray.getType(i)) {
|
|
2078
|
+
case Null:
|
|
2079
|
+
break;
|
|
2080
|
+
case Boolean:
|
|
2081
|
+
array.put(readableArray.getBoolean(i));
|
|
2082
|
+
break;
|
|
2083
|
+
case Number:
|
|
2084
|
+
array.put(readableArray.getDouble(i));
|
|
2085
|
+
break;
|
|
2086
|
+
case String:
|
|
2087
|
+
array.put(readableArray.getString(i));
|
|
2088
|
+
break;
|
|
2089
|
+
case Map:
|
|
2090
|
+
array.put(jsonObjectFromReadableMap(readableArray.getMap(i)));
|
|
2091
|
+
break;
|
|
2092
|
+
case Array:
|
|
2093
|
+
array.put(jsonArrayFromReadableArray(readableArray.getArray(i)));
|
|
2094
|
+
break;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return array;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
private static JSONObject jsonObjectFromReadableMap(ReadableMap readableMap) throws JSONException {
|
|
2101
|
+
JSONObject object = new JSONObject();
|
|
2102
|
+
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
2103
|
+
while (iterator.hasNextKey()) {
|
|
2104
|
+
String key = iterator.nextKey();
|
|
2105
|
+
switch (readableMap.getType(key)) {
|
|
2106
|
+
case Null:
|
|
2107
|
+
object.put(key, JSONObject.NULL);
|
|
2108
|
+
break;
|
|
2109
|
+
case Boolean:
|
|
2110
|
+
object.put(key, readableMap.getBoolean(key));
|
|
2111
|
+
break;
|
|
2112
|
+
case Number:
|
|
2113
|
+
object.put(key, readableMap.getDouble(key));
|
|
2114
|
+
break;
|
|
2115
|
+
case String:
|
|
2116
|
+
object.put(key, readableMap.getString(key));
|
|
2117
|
+
break;
|
|
2118
|
+
case Map:
|
|
2119
|
+
object.put(key, jsonObjectFromReadableMap(readableMap.getMap(key)));
|
|
2120
|
+
break;
|
|
2121
|
+
case Array:
|
|
2122
|
+
object.put(key, jsonArrayFromReadableArray(readableMap.getArray(key)));
|
|
2123
|
+
break;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
return object;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
private static WritableMap utmDetailsToWritableMap(UTMDetail details) {
|
|
2130
|
+
WritableMap ret = Arguments.createMap();
|
|
2131
|
+
|
|
2132
|
+
if (details != null) {
|
|
2133
|
+
ret.putString("campaign", details.getCampaign());
|
|
2134
|
+
ret.putString("source", details.getSource());
|
|
2135
|
+
ret.putString("medium", details.getMedium());
|
|
2136
|
+
}
|
|
2137
|
+
return ret;
|
|
2138
|
+
}
|
|
2139
|
+
}
|