diff --git a/build.gradle b/build.gradle index b028ccf..1aa2942 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.4.1' + classpath 'com.android.tools.build:gradle:7.4.2' classpath 'com.mparticle:android-kit-plugin:' + project.version classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } @@ -48,6 +48,6 @@ allprojects { } dependencies { - api 'com.apptentive:apptentive-kit-android:6.7.0' + api 'com.apptentive:apptentive-kit-android:6.9.0' testImplementation 'io.mockk:mockk:1.13.3' } diff --git a/src/main/kotlin/com/mparticle/kits/ApptentiveKitUtils.kt b/src/main/kotlin/com/mparticle/kits/ApptentiveKitUtils.kt index c18f3ac..557c428 100644 --- a/src/main/kotlin/com/mparticle/kits/ApptentiveKitUtils.kt +++ b/src/main/kotlin/com/mparticle/kits/ApptentiveKitUtils.kt @@ -2,8 +2,12 @@ package com.mparticle.kits import android.content.BroadcastReceiver import android.content.Context +import android.content.Context.RECEIVER_EXPORTED +import android.content.Context.RECEIVER_NOT_EXPORTED import android.content.Intent import android.content.IntentFilter +import android.os.Build +import android.util.Log import apptentive.com.android.feedback.Apptentive import apptentive.com.android.feedback.ApptentiveActivityInfo import com.mparticle.MParticle @@ -12,18 +16,27 @@ import com.mparticle.MParticle object ApptentiveKitUtils { @JvmStatic fun registerApptentiveActivityContext(callback: ApptentiveActivityInfo) { + val broadcastReceiver = object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + if (intent.action?.startsWith(MParticle.ServiceProviders.BROADCAST_ACTIVE) == true) { + Apptentive.registerApptentiveActivityInfoCallback(callback) + } + } + } if (MParticle.getInstance()?.isKitActive(MParticle.ServiceProviders.APPTENTIVE) == true) { Apptentive.registerApptentiveActivityInfoCallback(callback) + Log.d("ApptentiveKitUtils", "registerApptentiveActivityContext: kit is active") } else { - val filter = - IntentFilter(MParticle.ServiceProviders.BROADCAST_ACTIVE + MParticle.ServiceProviders.APPTENTIVE); - callback.getApptentiveActivityInfo()?.registerReceiver(object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - if (intent.action?.startsWith(MParticle.ServiceProviders.BROADCAST_ACTIVE) == true) { - Apptentive.registerApptentiveActivityInfoCallback(callback) - } + val filter = IntentFilter(MParticle.ServiceProviders.BROADCAST_ACTIVE + MParticle.ServiceProviders.APPTENTIVE) + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) { + callback.getApptentiveActivityInfo() + ?.registerReceiver(broadcastReceiver, filter, RECEIVER_EXPORTED) + Log.d("ApptentiveKitUtils", "registerApptentiveActivityContext: kit is active SDK 33+") + } else { + callback.getApptentiveActivityInfo() + ?.registerReceiver(broadcastReceiver, filter) + Log.d("ApptentiveKitUtils", "registerApptentiveActivityContext: kit is active SDK < 33") } - }, filter) } } }