Upgrade from 4x to 4.10

Updated

This page details changes from the previous major version of the SDK to this minor update, so you understand the development effort required to update your app and take advantage of the latest features.

What changed?

The changes in this update are mainly to align our APIs across different platforms. You should not experience changes to functionality or features.

Changes to initialization

CustomerIOBuilder is deprecated. You should use CustomerIOConfigBuilder instead.

Before

CustomerIOBuilder(
   applicationContext = this,
   // new credentials
   cdpApiKey = "your_cdp_api_key"
   migrationSiteId = "your_site_id"
).apply {
  // If you're in the EU, set Region.EU
   region(Region.US)
   addCustomerIOModule(
  ModuleMessagingInApp(
    // the in-app module now has its own configuration
     config = MessagingInAppModuleConfig.Builder(
        siteId = "your_site_id",
        region = Region.US
     ).setEventListener(InAppMessageEventListener()).build()
  )
   )
   addCustomerIOModule(ModuleMessagingPushFCM())
   build()
}

After

val builder = CustomerIOConfigBuilder(
applicationContext = this,
cdpApiKey = "your_cdp_api_key",
).region(Region.US)
// Add migrationSiteId only if you had it before
.migrationSiteId("your_site_id")
.addCustomerIOModule(
    ModuleMessagingInApp(
        // the in-app module now has its own configuration
        config = MessagingInAppModuleConfig.Builder(
            siteId = "your_site_id",
            region = Region.US
        ).setEventListener(InAppMessageEventListener()).build()
    )
)
.addCustomerIOModule(ModuleMessagingPushFCM())

CustomerIO.initialize(builder.build())

Changes when you track users, events, and screens

You’ll need to update the way you identify users and track events, including screen tracking.

Identifying a user

These variants of identify are deprecated:

  • identify(userId: String, traits: T) where traits are a generic type
  • identify(userId: String, traits: JsonObject)
  • identify(userId: String, traits: Traits, serializationStrategy: SerializationStrategy<Traits>) where traits are a generic type

You should use this instead:

  • identify(userId: String, traits: Map<String, Any?>)
CustomerIO.instance().identify(userId, mapOf("name" to "John Doe"))

Tracking an event

These variants of track are deprecated:

  • track(name: String, properties: T) where traits are a generic type
  • track(name: String, properties: JsonObject)
  • track(name: String, properties: Traits, serializationStrategy: SerializationStrategy<Traits>) where traits are a generic type

You should use this instead:

  • track(name: String, properties: Map<String, Any?>)
CustomerIO.instance().track("clicked_button", mapOf("button_name" to "Login"))

Screen tracking

These variants of screen are deprecated:

  • screen(title: String, properties: T) where traits are a generic type
  • screen(title: String, properties: JsonObject)
  • screen(title: String, properties: Traits, serializationStrategy: SerializationStrategy<Traits>) where traits are a generic type

You should use this instead:

  • screen(title: String, properties: Map<String, Any?>)
CustomerIO.instance().screen("Home", mapOf("login" to true))

Profile and device attribute changes

You’ll need to update the way you set profile and device attributes.

profileAttributes is deprecated

  • Getter has no replacement, the mobile SDK doesn’t expose the user’s profile attributes
  • Setter is replaced with setProfileAttributes(attributes: Map<String, Any>)
CustomerIO.instance().setProfileAttributes(mapOf("name" to "John Doe"))

deviceAttributes is deprecated

  • Getter has no replacement, the mobile SDK doesn’t expose the user’s device attributes
  • Setter is replaced with setDeviceAttributes(attributes: Map<String, Any>)
CustomerIO.instance().setDeviceAttributes(mapOf("device_id" to "1234567890"))
Copied to clipboard!
  Contents
Version
Is this page helpful?