Cheetah CES Docs Portal

Navigation
Home
GitHub
Email
Corporate Site

ANDROID SDK
Introduction
Getting Started
At a Glance: Using the Cheetah Loyalty Kits
Using the Sample Application
UI Customization
Android Kits Reference
Android Class Reference

Getting Started

Getting Access

Each Cheetah Digital powered app has a unique OAuth Application within the Cheetah Digital system. The OAuth app has a unique client id and client secret that you will use to access the Cheetah Digital APIs. To check your OAuth App do the following:

  1. Go to your Cheetah Digital Console.
  2. Go to the OAuthh Applications in Admin > Access > OAuth Applications.
  3. Look for the Android app with the following details:
    • Scope: Member
    • Platform: Android
  4. Open the details and obtain the Client ID and Client Secret which will be used in configuring the SDK. Take note of this when setting up your project in Android Studio.

Setting Up Android Studio

Cheetah Digital will provide you with the necessary Android libraries to create an app on top of the Cheetah Digital Platform. The libraries will depend on the plan that was purchased. A complete app can be created using the basic suite that will be provided. Additional modules can also be requested to make a more engaging and exciting application.

To use the Cheetah Digital Loyalty Kits, import the libraries provided and add them as build dependencies.

Create your project

  1. Go To Android Studio New Project Minimum SDK
  2. Select API 16: Android 4.1 or higher and create your new project
  3. Open the file Gradle Scripts | build.gradle (Project: <your_project>) and add the following to the buildscript section:

     repositories {
         jcenter()
         maven {
             url "https://s3.amazonaws.com/stellar-android"
         }
     }
    

    If your build configuration prefers settings repositories over project repositories, add the following to the settings.gradle

     dependencyResolutionManagement {
         repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
         repositories { 
             google()
             jcenter()
             mavenCentral()
             maven {
                 url = "https://s3.amazonaws.com/stellar-android"
             }
         }
     }
    
  4. Save and close the build.gradle (Project: <your_project>) file.
  5. Open the Gradle Scripts | build.gradle (Module: app) and add the following to the dependencies section:

    implementation 'com.cheetahdigital.android:corekit:<version>'
    

    Version number will be provided separately, please submit a request to your Cheetah Digital contact person.

    The corekit is the basic component that is required to start developing an app integrated with Cheetah Digital SDK for Android. Check out the component kits documentation for the rest of the available kits. Ask your program manager regarding the list of kits that are available for your plan as well as the version number to be used in the dependencies.

  6. Download the dependencies.gradle file and place it on the root directory of your project.
  7. In build.gradle (Project: <your_project>) add the following code inside the buildscript section:

     apply from: 'dependencies.gradle'
    

    add the dependencies section

     classpath "io.sentry:sentry-android-gradle-plugin:${versions.sentry}"
     classpath "com.android.tools.build:gradle:${versions.gradlePlugin}"
     classpath "com.google.gms:google-services:${versions.googleServices}"
    
  8. In Gradle Scripts | build.gradle (Module: app)’s dependencies section, add the following code on the top:

     apply from: '../dependencies.gradle'
    
  9. Include additional dependencies based on the modules added using this link. Remember to remove duplicate dependencies.
  10. You may also need to add the following resositories in your build.gradle or settings.gradle

    maven { url "https://jitpack.io" }
    maven { url "https://maven.google.com" }
    
  11. Build the project.

Updating Your Manifest

  1. Add the client id and client secret into your project’s string file.

     <string name="client_id">clientIDexample1234</string>
     <string name="client_secret">clientSecretExample1234</string>
    
  2. Create a custom Application class which extends the Cheetah Application class.

     public class MyApplication extends com.cheetahdigital.corekit.sdk.Application
    

    The corekit Application class automatically initializes the SDK in its onCreate method. If you need to override the onCreate method make sure to call super.onCreate().

    If you need to modify and configuration in the SDK, override the method initializeSdk(boolean isDebugMode). See SDKConfig class for more information.

  3. Make sure to rename the <application> tag in your Manifest to the custom Application created in Step 2.
  4. You can verify if SDK is already configured by calling Sdk.getInstance(). This is also the basis for different api calls so make sure to initialize SDK first, either by doing Step 3 or calling the method Sdk.initialize

Sample Application

You can download the sample Android Studio project to start up your development. This project includes the basics to create a Cheetah Digital powered app.

  • SDK Initilization using the Cheetah Application class
  • Login Screen extending the prebuilt Login UI
  • Login Screen using the SDK API calls
  • Upgrade Check implementation
    • Cheetah has provided a way to check if there are pending Upgrades on the App using the User-Agent string in the API calls. To provide an implementation for Upgrade Check, override the following method in your Application class:

        @Override
        	public LifeCycleHandler.UpgradeCheckListener getUpgradeCheckListener() {
          	if (mUpgradeCheckListener == null) {
              	mUpgradeCheckListener = new UpgradeCheckListener() {
                  	@Override
                  	protected void onUpgradeCheckFailed(String error) {
                      	// Log error
                      	Log.d("Upgrade Check", error);
                  	}
                };
          	}
          	return mUpgradeCheckListener;
        	}
      
  • Revoke Token implementation
    • This is an implicit intent added to the Manifest to indicate where the app will be redirected in case the Access Token used by the app has been invalidated
       <intent-filter>
              <action android:name="${applicationId}.REVOKED_TOKEN" />
              <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
      <intent-filter>
              <action android:name="${applicationId}.LOGIN" />
              <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
    

Next: At A Glance