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:
- Go to your Cheetah Digital Console.
- Go to the OAuthh Applications in Admin > Access > OAuth Applications.
- Look for the Android app with the following details:
- Scope: Member
- Platform: Android
- 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
-
Go To Android Studio New Project Minimum SDK - Select API 16: Android 4.1 or higher and create your new project
-
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" } } }
- Save and close the
build.gradle (Project: <your_project>)
file. -
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. - Download the dependencies.gradle file and place it on the root directory of your project.
-
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}"
-
In
Gradle Scripts | build.gradle (Module: app)
’s dependencies section, add the following code on the top:apply from: '../dependencies.gradle'
- Include additional dependencies based on the modules added using this link. Remember to remove duplicate dependencies.
-
You may also need to add the following resositories in your
build.gradle
orsettings.gradle
maven { url "https://jitpack.io" } maven { url "https://maven.google.com" }
- Build the project.
Updating Your Manifest
-
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>
-
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 itsonCreate
method. If you need to override theonCreate
method make sure to callsuper.onCreate()
.If you need to modify and configuration in the SDK, override the method
initializeSdk(boolean isDebugMode)
. See SDKConfig class for more information. - Make sure to rename the
<application>
tag in your Manifest to the custom Application created in Step 2. - 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 methodSdk.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