diff --git a/build.gradle b/build.gradle index 42beb7c..1f2fbb8 100644 --- a/build.gradle +++ b/build.gradle @@ -41,7 +41,7 @@ android { dependencies { compileOnly 'androidx.legacy:legacy-support-v4:1.0.0' - api 'com.urbanairship.android:urbanairship-core:16.9.0' + api 'com.urbanairship.android:urbanairship-core:17.7.1' testImplementation 'junit:junit:4.13.2' testImplementation files('libs/java-json.jar') } diff --git a/src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt b/src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt index 301db6f..dbe8d73 100644 --- a/src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt +++ b/src/main/kotlin/com/mparticle/kits/MParticleAutopilot.kt @@ -9,6 +9,7 @@ import com.urbanairship.AirshipConfigOptions import com.urbanairship.Autopilot import com.urbanairship.UAirship import com.urbanairship.channel.AirshipChannelListener +import com.urbanairship.push.PushNotificationStatus import com.urbanairship.util.UAStringUtil /** @@ -48,23 +49,17 @@ class MParticleAutopilot : Autopilot() { // Restore the last registration token val token = airship.pushManager.pushToken MParticlePushProvider.instance.setRegistrationToken(token) - airship.channel.addChannelListener(object : AirshipChannelListener { - override fun onChannelCreated(s: String) { - callChannelIdListener() - } + airship.channel.addChannelListener { callChannelIdListener() } - override fun onChannelUpdated(s: String) { - callChannelIdListener() - } + callChannelIdListener() + } - private fun callChannelIdListener() { - val channelIdListener = MParticle.getInstance() - ?.getKitInstance(MParticle.ServiceProviders.URBAN_AIRSHIP) - if (channelIdListener != null) { - (channelIdListener as ChannelIdListener).channelIdUpdated() - } - } - }) + fun callChannelIdListener() { + val channelIdListener = MParticle.getInstance() + ?.getKitInstance(MParticle.ServiceProviders.URBAN_AIRSHIP) + if (channelIdListener != null) { + (channelIdListener as ChannelIdListener).channelIdUpdated() + } } override fun allowEarlyTakeOff(context: Context): Boolean = false diff --git a/src/main/kotlin/com/mparticle/kits/UrbanAirshipKit.kt b/src/main/kotlin/com/mparticle/kits/UrbanAirshipKit.kt index 9440a5c..8a39bfd 100644 --- a/src/main/kotlin/com/mparticle/kits/UrbanAirshipKit.kt +++ b/src/main/kotlin/com/mparticle/kits/UrbanAirshipKit.kt @@ -1,26 +1,22 @@ package com.mparticle.kits import android.content.Context -import com.mparticle.kits.KitIntegration.CommerceListener -import com.urbanairship.Autopilot -import com.urbanairship.UAirship import android.content.Intent -import com.urbanairship.analytics.InstallReceiver -import com.urbanairship.push.PushMessage -import com.urbanairship.push.PushProviderBridge -import java.lang.Exception import com.mparticle.MPEvent -import com.urbanairship.analytics.CustomEvent -import com.mparticle.commerce.CommerceEvent -import java.util.LinkedList import com.mparticle.MParticle.IdentityType +import com.mparticle.commerce.CommerceEvent import com.mparticle.commerce.Product +import com.mparticle.kits.KitIntegration.CommerceListener +import com.urbanairship.Autopilot +import com.urbanairship.UAirship +import com.urbanairship.analytics.CustomEvent +import com.urbanairship.analytics.InstallReceiver import com.urbanairship.analytics.RetailEventTemplate import com.urbanairship.json.JsonValue -import java.util.HashSet +import com.urbanairship.push.PushMessage +import com.urbanairship.push.PushProviderBridge import java.math.BigDecimal -import java.util.ArrayList -import java.util.HashMap +import java.util.LinkedList /** * mParticle-Urban Airship Kit integration @@ -193,7 +189,7 @@ class UrbanAirshipKit : KitIntegration(), KitIntegration.PushListener, KitIntegr .apply() } if (identityType == configuration?.userIdField) { - UAirship.shared().namedUser.id = identity + UAirship.shared().contact.identify(identity) // Previously setting namedUser but now is immutable } } @@ -205,8 +201,8 @@ class UrbanAirshipKit : KitIntegration(), KitIntegration.PushListener, KitIntegr .removeIdentifier(airshipId) .apply() } - if (identityType == configuration?.userIdField) { - UAirship.shared().namedUser.id = null + if (identityType == configuration?.userIdField && UAirship.shared().contact.namedUserId != null) { + UAirship.shared().contact.reset() // Previously setting namedUser to null but now is immutable } }