Skip to content
Andrew Clunis edited this page Dec 13, 2022 · 27 revisions

Installation and Initialization

The Rover Campaigns SDK is a collection of Android libraries written in Kotlin. Instead of a single monolithic library, the Rover Campaigns SDK takes a modular approach, allowing you to include only the functionality relevant to your application. The SDK is 100% open-source and available on GitHub.

Note: The Rover Campaigns SDK is used in concert with the main Rover SDK. The main Rover SDK renders graphical Rover content (Experiences), while this SDK (Rover Campaigns) offers additional marketing automation and analytics functionality. You don't need to worry about setting up the main Rover SDK; that is largely done for you by the Campaigns SDK.

Note: If you currently have Rover 2.x already integrated into your app, please follow the 2.x to 3.x to Migration Guide.


Install the SDK

The first step is to add the library dependencies. We’ll start with a default installation, featuring all of the Rover libraries.

Ensure that you have Rover's maven repository added to the dependenciesrepositories block of your app-level build.gradle:

dependencies {
    // ...
    repositories {
        // ...
        maven {
            url "https://judoapp.github.io/judo-maven/maven"
        }
    }
}

Then add the following to your application-level build.gradle file (not the top level build.gradle, but rather your app-level one) in the dependencies block.

dependencies {
    // ...
    implementation "io.rover:sdk:3.8.2"
    implementation "io.rover.campaigns:core:3.11.0"
    implementation "io.rover.campaigns:notifications:3.11.0"
    implementation "io.rover.campaigns:experiences:3.11.0"
    implementation "io.rover.campaigns:location:3.11.0"
    implementation "io.rover.campaigns:debug:3.11.0"
}

It’s an a-la-carte selection; you can leave off modules (other than the first, core, which is always required) that you don’t need for your product. There are various reasons why you may not want to include all the Rover Campaigns libraries in your project. For instance, you can save method count and APK size by leaving off Rover Campaigns libraries that you don't need.


Initialization

In your app’s Application.onCreate method or anywhere else you prefer to put initialization logic (such as a dependency injection framework), call RoverCampaigns.initialize with the list of Assemblers:

RoverCampaigns.initialize(
    CoreAssembler(
        accountToken = "YOUR_SDK_TOKEN",
        application = this,
        urlSchemes = listOf("rv-myapp"),
        associatedDomains = listOf("myapp.rover.io")
    ),
    ExperiencesAssembler(),
    NotificationsAssembler(
        applicationContext = this,
        notificationCenterIntent = Intent(context, MyNotificationCenterActivity::class.java),
        smallIconResId = R.mipmap.my_small_icon,
        requestPushToken = { tokenCallback ->
            FirebaseMessaging.getInstance().token.addOnCompleteListener { task -> 
                if (task.isSuccessful) tokenCallback(task.result) 
            }
        }
    ),
    LocationAssembler(),
    DebugAssembler()
)

RoverCampaigns.installSaneGlobalHttpCache(application)

Note: The reasoning for the inclusion of RoverCampaigns.installSaneGlobalHttpCache() is that in order to keep its footprint small Rover uses Android’s built-in HTTP client, HttpsUrlConnection, and a characteristic of that HTTP client is that its cache must be enabled or disabled globally. Rover requires a working HTTP client cache, and so asks you to invoke this method here to explicitly install a cache to ensure that you are not surprised by Rover changing global configuration. Note that this will have no impact on the other components of your app if you use OkHttp/Retrofit or Volley.

Wherever you put it, you need to be certain that Rover is initialized before Android can dispatch an Intent to the app, such as a push notification or deep link open.

Don’t sweat the parameters for now; they’re in each section of the documentation for each module.