diff --git a/.gitmodules b/.gitmodules
index f0a156f04..38f43a924 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -19,9 +19,6 @@
[submodule "kits/foresee-kit"]
path = kits/foresee-kit
url = git@github.com:mparticle-integrations/mparticle-android-integration-foresee.git
-[submodule "kits/iterable-kit"]
- path = kits/iterable-kit
- url = git@github.com:mparticle-integrations/mparticle-android-integration-iterable.git
[submodule "kits/onetrust-kit"]
path = kits/onetrust-kit
url = git@github.com:mparticle-integrations/mparticle-android-integration-onetrust.git
diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml
index fceb7427b..a6d96a97c 100644
--- a/.trunk/trunk.yaml
+++ b/.trunk/trunk.yaml
@@ -68,11 +68,14 @@ lint:
- "**/gradlew"
- scripts/install-start-emulator.sh
- kits/adjust/adjust-5/**
+ - kits/adobe/adobe-5/**
+ - kits/adobemedia/adobemedia-5/**
- kits/apptentive/apptentive-6/**
- kits/appsflyer/appsflyer-6/**
- kits/apptimize/apptimize-3/**
- kits/braze/braze-38/**
- kits/clevertap/clevertap-7/**
+ - kits/iterable/iterable-3/**
- kits/ga/ga-23/**
- kits/ga4/ga4-23/**
- kits/kochava/kochava-5/**
@@ -80,8 +83,6 @@ lint:
- kits/rokt/rokt/**
- kits/localytics/localytics-6/**
- kits/rokt/rokt/**
- - kits/adobe/adobe-5/**
- - kits/adobemedia/adobemedia-5/**
actions:
enabled:
- trunk-announce
diff --git a/kits/iterable-kit b/kits/iterable-kit
deleted file mode 160000
index c94c7ab09..000000000
--- a/kits/iterable-kit
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit c94c7ab09be031bd6103ddb6480d6453755e1c1e
diff --git a/kits/iterable/iterable-3/README.md b/kits/iterable/iterable-3/README.md
new file mode 100644
index 000000000..a5b9d9c14
--- /dev/null
+++ b/kits/iterable/iterable-3/README.md
@@ -0,0 +1,27 @@
+## Iterable Kit Integration
+
+This repository contains the [Iterable](https://www.iterable.com/) integration for the [mParticle Android SDK](https://github.com/mParticle/mparticle-android-sdk).
+
+mParticle's Iterable integration is predominantly server-side. This kit is an optional add-on to handle Iterable deep links.
+
+
+### Adding the integration
+
+1. Add the kit dependency to your app's build.gradle:
+
+ ```groovy
+ dependencies {
+ implementation 'com.mparticle:android-iterable-kit:5+'
+ }
+ ```
+
+2. Follow the mParticle Android SDK [quick-start](https://github.com/mParticle/mparticle-android-sdk), then rebuild and launch your app, and verify that you see `"Iterable detected"` in the output of `adb logcat`.
+3. Reference mParticle's integration docs below to enable the integration.
+
+### Documentation
+
+[Iterable Integration Docs](https://docs.mparticle.com/integrations/iterable/audience/)
+
+### License
+
+[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
diff --git a/kits/iterable/iterable-3/build.gradle b/kits/iterable/iterable-3/build.gradle
new file mode 100644
index 000000000..0b2da8940
--- /dev/null
+++ b/kits/iterable/iterable-3/build.gradle
@@ -0,0 +1,61 @@
+buildscript {
+ ext.kotlin_version = '2.0.20'
+ if (!project.hasProperty('version') || project.version.equals('unspecified') || project.version.toString().contains('beta')) {
+ project.version = '+'
+ }
+
+ repositories {
+ google()
+ mavenLocal()
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:8.1.4'
+ classpath 'com.mparticle:android-kit-plugin:' + project.version
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+
+plugins {
+ id "org.sonarqube" version "3.5.0.2730"
+ id "org.jlleitschuh.gradle.ktlint" version "13.0.0"
+}
+
+sonarqube {
+ properties {
+ property "sonar.projectKey", "mparticle-android-integration-iterable"
+ property "sonar.organization", "mparticle"
+ property "sonar.host.url", "https://sonarcloud.io"
+ }
+}
+
+apply plugin: 'org.jlleitschuh.gradle.ktlint'
+apply plugin: 'kotlin-android'
+apply plugin: 'com.mparticle.kit'
+
+android {
+ namespace 'com.mparticle.kits.iterable'
+ buildFeatures {
+ buildConfig = true
+ }
+ defaultConfig {
+ minSdkVersion 21
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
+ kotlinOptions {
+ jvmTarget = '17'
+ }
+ testOptions {
+ unitTests.all {
+ jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED']
+ }
+ }
+}
+
+dependencies {
+ api 'com.iterable:iterableapi:3.5.10'
+}
diff --git a/kits/iterable/iterable-3/consumer-proguard.pro b/kits/iterable/iterable-3/consumer-proguard.pro
new file mode 100644
index 000000000..2a90e0f4c
--- /dev/null
+++ b/kits/iterable/iterable-3/consumer-proguard.pro
@@ -0,0 +1 @@
+# TODO: Add rules to exclude your SDK classes from proguard in implementing apps
\ No newline at end of file
diff --git a/kits/iterable/iterable-3/gradle.properties b/kits/iterable/iterable-3/gradle.properties
new file mode 100644
index 000000000..edb1202c3
--- /dev/null
+++ b/kits/iterable/iterable-3/gradle.properties
@@ -0,0 +1,4 @@
+android.enableJetifier=true
+android.useAndroidX=true
+org.gradle.daemon=true
+org.gradle.jvmargs=-Xmx2560m
\ No newline at end of file
diff --git a/kits/iterable/iterable-3/gradle/wrapper/gradle-wrapper.jar b/kits/iterable/iterable-3/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..41d9927a4
Binary files /dev/null and b/kits/iterable/iterable-3/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/kits/iterable/iterable-3/gradle/wrapper/gradle-wrapper.properties b/kits/iterable/iterable-3/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..e1bef7e87
--- /dev/null
+++ b/kits/iterable/iterable-3/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/kits/iterable/iterable-3/gradlew b/kits/iterable/iterable-3/gradlew
new file mode 100755
index 000000000..1b6c78733
--- /dev/null
+++ b/kits/iterable/iterable-3/gradlew
@@ -0,0 +1,234 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/kits/iterable/iterable-3/gradlew.bat b/kits/iterable/iterable-3/gradlew.bat
new file mode 100644
index 000000000..107acd32c
--- /dev/null
+++ b/kits/iterable/iterable-3/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/kits/iterable/iterable-3/libs/testutils.aar b/kits/iterable/iterable-3/libs/testutils.aar
new file mode 100644
index 000000000..cf49b4189
Binary files /dev/null and b/kits/iterable/iterable-3/libs/testutils.aar differ
diff --git a/kits/iterable/iterable-3/settings.gradle.kts b/kits/iterable/iterable-3/settings.gradle.kts
new file mode 100644
index 000000000..9fbabbf34
--- /dev/null
+++ b/kits/iterable/iterable-3/settings.gradle.kts
@@ -0,0 +1,2 @@
+rootProject.name = "android-iterable-kit"
+include(":")
diff --git a/kits/iterable/iterable-3/src/main/AndroidManifest.xml b/kits/iterable/iterable-3/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..e3ecde421
--- /dev/null
+++ b/kits/iterable/iterable-3/src/main/AndroidManifest.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/kits/iterable/iterable-3/src/main/kotlin/com/iterable/iterableapi/IterableConfigHelper.kt b/kits/iterable/iterable-3/src/main/kotlin/com/iterable/iterableapi/IterableConfigHelper.kt
new file mode 100644
index 000000000..28fd44323
--- /dev/null
+++ b/kits/iterable/iterable-3/src/main/kotlin/com/iterable/iterableapi/IterableConfigHelper.kt
@@ -0,0 +1,21 @@
+package com.iterable.iterableapi
+
+object IterableConfigHelper {
+ fun createConfigBuilderFromIterableConfig(config: IterableConfig?): IterableConfig.Builder {
+ val builder = IterableConfig.Builder()
+ if (config != null) {
+ builder.apply {
+ setPushIntegrationName(config.pushIntegrationName)
+ setUrlHandler(config.urlHandler)
+ setCustomActionHandler(config.customActionHandler)
+ setAutoPushRegistration(config.autoPushRegistration)
+ setCheckForDeferredDeeplink(config.checkForDeferredDeeplink)
+ setLogLevel(config.logLevel)
+ setInAppHandler(config.inAppHandler)
+ setInAppDisplayInterval(config.inAppDisplayInterval)
+ setAllowedProtocols(config.allowedProtocols)
+ }
+ }
+ return builder
+ }
+}
diff --git a/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/IterableDeviceIdHelper.kt b/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/IterableDeviceIdHelper.kt
new file mode 100644
index 000000000..9eadf0c08
--- /dev/null
+++ b/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/IterableDeviceIdHelper.kt
@@ -0,0 +1,35 @@
+package com.mparticle.kits
+
+import android.content.Context
+import androidx.annotation.WorkerThread
+
+internal object IterableDeviceIdHelper {
+ @WorkerThread
+ fun getGoogleAdId(context: Context?): String? {
+ try {
+ val advertisingIdClient =
+ Class
+ .forName("com.google.android.gms.ads.identifier.AdvertisingIdClient")
+ val getAdvertisingInfo =
+ advertisingIdClient.getMethod(
+ "getAdvertisingIdInfo",
+ Context::class.java,
+ )
+ val advertisingInfo = getAdvertisingInfo.invoke(null, context)
+ val isLimitAdTrackingEnabled =
+ advertisingInfo.javaClass.getMethod(
+ "isLimitAdTrackingEnabled",
+ )
+ val limitAdTrackingEnabled =
+ isLimitAdTrackingEnabled
+ .invoke(advertisingInfo) as Boolean
+ val getId = advertisingInfo.javaClass.getMethod("getId")
+ val advertisingId = getId.invoke(advertisingInfo) as String
+ if (!limitAdTrackingEnabled) {
+ return advertisingId
+ }
+ } catch (ignored: Exception) {
+ }
+ return null
+ }
+}
diff --git a/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/IterableKit.kt b/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/IterableKit.kt
new file mode 100644
index 000000000..693f202f8
--- /dev/null
+++ b/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/IterableKit.kt
@@ -0,0 +1,261 @@
+package com.mparticle.kits
+
+import android.app.Activity
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import android.util.Log
+import com.google.firebase.messaging.RemoteMessage
+import com.iterable.iterableapi.BuildConfig
+import com.iterable.iterableapi.IterableApi
+import com.iterable.iterableapi.IterableConfig
+import com.iterable.iterableapi.IterableConfigHelper
+import com.iterable.iterableapi.IterableConstants
+import com.iterable.iterableapi.IterableFirebaseMessagingService
+import com.iterable.iterableapi.IterableHelper.IterableActionHandler
+import com.mparticle.AttributionResult
+import com.mparticle.MParticle
+import com.mparticle.MParticle.IdentityType
+import com.mparticle.identity.MParticleUser
+import com.mparticle.kits.KitIntegration.ActivityListener
+import com.mparticle.kits.KitIntegration.ApplicationStateListener
+import com.mparticle.kits.KitIntegration.IdentityListener
+import com.mparticle.kits.KitIntegration.PushListener
+import com.mparticle.kits.iterable.Future
+
+class IterableKit :
+ KitIntegration(),
+ ActivityListener,
+ ApplicationStateListener,
+ IdentityListener,
+ PushListener {
+ private val previousLinks: MutableSet = HashSet()
+ private var mpidEnabled = false
+
+ override fun onKitCreate(
+ settings: Map,
+ context: Context,
+ ): List {
+ checkForAttribution()
+ val userIdField = settings[SETTING_USER_ID_FIELD]
+ mpidEnabled = userIdField != null && userIdField == IDENTITY_MPID
+ val configBuilder =
+ IterableConfigHelper.createConfigBuilderFromIterableConfig(
+ customConfig,
+ )
+ settings[SETTING_GCM_INTEGRATION_NAME]?.let { configBuilder.setPushIntegrationName(it) }
+ settings[SETTING_API_KEY]?.let {
+ IterableApi.initialize(context, it, configBuilder.build())
+ }
+ initIntegrationAttributes()
+ return emptyList()
+ }
+
+ override fun getName(): String = NAME
+
+ override fun setOptOut(optedOut: Boolean): List = emptyList()
+
+ private fun initIntegrationAttributes() {
+ val integrationAttributes = HashMap()
+ integrationAttributes[INTEGRATION_ATTRIBUTE_SDK_VERSION] =
+ BuildConfig.ITERABLE_SDK_VERSION
+ setIntegrationAttributes(integrationAttributes)
+ }
+
+ private fun checkForAttribution() {
+ val activityRef = kitManager.currentActivity
+ if (activityRef != null) {
+ val activity = activityRef.get()
+ if (activity != null) {
+ val currentLink = activity.intent.dataString
+ if (!currentLink.isNullOrEmpty() && !previousLinks.contains(currentLink)
+ ) {
+ previousLinks.add(currentLink)
+ val clickCallback =
+ IterableActionHandler { result ->
+ if (!KitUtils.isEmpty(result)) {
+ val attributionResult = AttributionResult().setLink(result)
+ attributionResult.serviceProviderId = configuration.kitId
+ kitManager.onResult(attributionResult)
+ }
+ }
+ IterableApi.getInstance().getAndTrackDeepLink(currentLink, clickCallback)
+ }
+ }
+ }
+ }
+
+ override fun onActivityCreated(
+ activity: Activity,
+ bundle: Bundle?,
+ ): List = emptyList()
+
+ override fun onActivityStarted(activity: Activity): List = emptyList()
+
+ override fun onActivityResumed(activity: Activity): List = emptyList()
+
+ override fun onActivityPaused(activity: Activity): List = emptyList()
+
+ override fun onActivityStopped(activity: Activity): List = emptyList()
+
+ override fun onActivitySaveInstanceState(
+ activity: Activity,
+ bundle: Bundle?,
+ ): List = emptyList()
+
+ override fun onActivityDestroyed(activity: Activity): List = emptyList()
+
+ override fun onApplicationForeground() {
+ checkForAttribution()
+ }
+
+ override fun onApplicationBackground() {}
+
+ override fun onIdentifyCompleted(
+ mParticleUser: MParticleUser,
+ filteredIdentityApiRequest: FilteredIdentityApiRequest,
+ ) {
+ updateIdentity(mParticleUser)
+ }
+
+ override fun onLoginCompleted(
+ mParticleUser: MParticleUser,
+ filteredIdentityApiRequest: FilteredIdentityApiRequest,
+ ) {
+ updateIdentity(mParticleUser)
+ }
+
+ override fun onLogoutCompleted(
+ mParticleUser: MParticleUser,
+ filteredIdentityApiRequest: FilteredIdentityApiRequest,
+ ) {
+ updateIdentity(mParticleUser)
+ }
+
+ override fun onModifyCompleted(
+ mParticleUser: MParticleUser,
+ filteredIdentityApiRequest: FilteredIdentityApiRequest,
+ ) {
+ }
+
+ override fun onUserIdentified(mParticleUser: MParticleUser) {
+ updateIdentity(mParticleUser)
+ }
+
+ private fun isEmpty(string: String?): Boolean = string == null || "" == string
+
+ private fun getUserId(mParticleUser: MParticleUser): Future =
+ Future.runAsync {
+ var id: String? = null
+ if (mpidEnabled) {
+ if (mParticleUser.id != 0L) {
+ id = mParticleUser.id.toString()
+ }
+ } else {
+ id = IterableDeviceIdHelper.getGoogleAdId(context)
+ if (isEmpty(id)) {
+ id = KitUtils.getAndroidID(context)
+ }
+ if (isEmpty(id)) {
+ val userIdentities = mParticleUser.userIdentities
+ id = userIdentities[IdentityType.CustomerId]
+ }
+ if (isEmpty(id)) {
+ id = MParticle.getInstance()?.Identity()?.deviceApplicationStamp
+ }
+ }
+ id
+ }
+
+ private fun String?.getPlaceholderEmail(): String? = this?.let { "$it@placeholder.email" }
+
+ private fun handleOnSuccess(
+ userId: String?,
+ mParticleUser: MParticleUser,
+ ) {
+ if (prefersUserId) {
+ IterableApi.getInstance().setUserId(userId)
+ } else {
+ val userIdentities = mParticleUser.userIdentities
+ val mpEmail = userIdentities[IdentityType.Email]
+ val placeholderEmail = userId.getPlaceholderEmail()
+
+ val email =
+ if (!mpEmail.isNullOrEmpty()) {
+ mpEmail
+ } else if (!isEmpty(placeholderEmail)) {
+ placeholderEmail
+ } else {
+ null
+ }
+
+ IterableApi.getInstance().setEmail(email)
+ }
+ }
+
+ private fun updateIdentity(mParticleUser: MParticleUser) {
+ val userId = getUserId(mParticleUser)
+
+ userId
+ .onSuccess(
+ object : Future.SuccessCallback {
+ override fun onSuccess(userId: String?) {
+ handleOnSuccess(userId, mParticleUser)
+ return
+ }
+ },
+ ).onFailure(
+ object : Future.FailureCallback {
+ override fun onFailure(throwable: Throwable?) {
+ Log.e(ITERABLE_KIT_ERROR_TAG, ITERABLE_KIT_ERROR_MESSAGE, throwable)
+ }
+ },
+ )
+ }
+
+ override fun willHandlePushMessage(intent: Intent): Boolean {
+ val extras = intent.extras
+ return extras != null && extras.containsKey(IterableConstants.ITERABLE_DATA_KEY)
+ }
+
+ override fun onPushMessageReceived(
+ context: Context,
+ intent: Intent,
+ ) {
+ IterableFirebaseMessagingService.handleMessageReceived(
+ context,
+ RemoteMessage(intent.extras),
+ )
+ }
+
+ override fun onPushRegistration(
+ instanceId: String,
+ senderId: String,
+ ): Boolean {
+ IterableApi.getInstance().registerForPush()
+ return true
+ }
+
+ companion object {
+ var prefersUserId = false
+ private var customConfig: IterableConfig? = null
+ private const val SETTING_API_KEY = "apiKey"
+ private const val SETTING_GCM_INTEGRATION_NAME = "gcmIntegrationName"
+ private const val SETTING_USER_ID_FIELD = "userIdField"
+ private const val IDENTITY_CUSTOMER_ID = "customerId"
+ private const val IDENTITY_MPID = "mpid"
+ private const val INTEGRATION_ATTRIBUTE_KIT_VERSION_CODE = "Iterable.kitVersionCode"
+ private const val INTEGRATION_ATTRIBUTE_SDK_VERSION = "Iterable.sdkVersion"
+ private const val NAME = "Iterable"
+ private const val ITERABLE_KIT_ERROR_TAG = "IterableKit"
+ private const val ITERABLE_KIT_ERROR_MESSAGE = "Error while getting the placeholder email"
+
+ /**
+ * Set a custom config to be used when initializing Iterable SDK
+ * @param config `IterableConfig` instance with configuration data for Iterable SDK
+ */
+ fun setCustomConfig(config: IterableConfig?) {
+ customConfig = config
+ }
+ }
+}
diff --git a/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/iterable/Future.kt b/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/iterable/Future.kt
new file mode 100644
index 000000000..8c533e4d2
--- /dev/null
+++ b/kits/iterable/iterable-3/src/main/kotlin/com/mparticle/kits/iterable/Future.kt
@@ -0,0 +1,74 @@
+package com.mparticle.kits.iterable
+
+import android.os.Handler
+import android.os.Looper
+import java.util.concurrent.Callable
+import java.util.concurrent.Executors
+
+class Future private constructor(
+ callable: Callable,
+) {
+ private lateinit var callbackHandler: Handler
+ private val successCallbacks: MutableList> = ArrayList()
+ private val failureCallbacks: MutableList = ArrayList()
+
+ private fun handleSuccess(result: T) {
+ callbackHandler.post {
+ var callbacks: List>
+ synchronized(successCallbacks) { callbacks = ArrayList(successCallbacks) }
+ for (callback: SuccessCallback? in callbacks) {
+ callback?.onSuccess(result)
+ }
+ }
+ }
+
+ private fun handleFailure(t: Throwable) {
+ callbackHandler.post {
+ var callbacks: List
+ synchronized(failureCallbacks) { callbacks = ArrayList(failureCallbacks) }
+ for (callback: FailureCallback? in callbacks) {
+ callback?.onFailure(t)
+ }
+ }
+ }
+
+ fun onSuccess(successCallback: SuccessCallback): Future {
+ synchronized(successCallbacks) { successCallbacks.add(successCallback) }
+ return this
+ }
+
+ fun onFailure(failureCallback: FailureCallback): Future {
+ synchronized(failureCallbacks) { failureCallbacks.add(failureCallback) }
+ return this
+ }
+
+ interface SuccessCallback {
+ fun onSuccess(result: T)
+ }
+
+ interface FailureCallback {
+ fun onFailure(throwable: Throwable?)
+ }
+
+ companion object {
+ private val EXECUTOR = Executors.newCachedThreadPool()
+
+ fun runAsync(callable: Callable): Future = Future(callable)
+ }
+
+ init {
+ // Set up a Handler for the callback based on the current thread
+ var looper = Looper.myLooper()
+ looper?.let {
+ callbackHandler = Handler((it))
+ EXECUTOR.submit {
+ try {
+ val result = callable.call()
+ handleSuccess(result)
+ } catch (e: Exception) {
+ handleFailure(e)
+ }
+ } ?: { looper = Looper.getMainLooper() }
+ }
+ }
+}
diff --git a/kits/iterable/iterable-3/src/test/kotlin/com/mparticle/kits/IterableKitTests.kt b/kits/iterable/iterable-3/src/test/kotlin/com/mparticle/kits/IterableKitTests.kt
new file mode 100644
index 000000000..ed49eca8e
--- /dev/null
+++ b/kits/iterable/iterable-3/src/test/kotlin/com/mparticle/kits/IterableKitTests.kt
@@ -0,0 +1,33 @@
+package com.mparticle.kits
+
+import com.mparticle.MParticleOptions
+import org.junit.Assert
+import org.junit.Test
+import org.mockito.Mockito
+
+class IterableKitTests {
+ private val kit: KitIntegration
+ get() = IterableKit()
+
+ @Test
+ @Throws(Exception::class)
+ fun testGetName() {
+ val name = kit.name
+ Assert.assertTrue(!name.isNullOrEmpty())
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun testClassName() {
+ val options = Mockito.mock(MParticleOptions::class.java)
+ val factory = KitIntegrationFactory(options)
+ val integrations = factory.supportedKits.values
+ val className = kit.javaClass.name
+ for (integration in integrations) {
+ if (integration.name == className) {
+ return
+ }
+ }
+ Assert.fail("$className not found as a known integration.")
+ }
+}
diff --git a/settings-kits.gradle b/settings-kits.gradle
index ec2c3d1ed..77fce8e8c 100644
--- a/settings-kits.gradle
+++ b/settings-kits.gradle
@@ -18,7 +18,7 @@ include (
':kits:foresee-kit',
':kits:ga:ga-23',
':kits:ga4:ga4-23',
- ':kits:iterable-kit',
+ ':kits:iterable:iterable-3',
':kits:kochava:kochava-5',
':kits:localytics:localytics-6',
':kits:leanplum:leanplum-7',