SDK Integration

The Gamely SDK library can be integrated into any Android project by following the steps mentioned in the sections below. SDK handles the artifacts remotely and resolves the dependencies at the build level in the integrating environment. This is JitPack-based private artifacts library.

1. Add Authentication Token

The authentication token identifies the validity of dependent packages in the integrating environment.
Add the following line in the gradle.properties file of your Android application to add a token:

authToken= token_value // <onmobile team share you offline>

2. Authenticate Maven Build Signatures

If your project uses Gradle 7 and above and RepositoriesModes as RepositoriesMode.FAIL_ON_PROJECT_REPOS or RepositoriesMode.PREFER_SETTINGS, add it your settings.gradle

dependencyResolutionManagement {
    repositoriesMode.set(your_repository_mode)
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://jitpack.io"
            credentials { username authToken }
        }
    }
}

If your project uses Gradle 6 and below or RepositoriesModes as RepositoriesMode.PREFER_PROJECT, add it to your root build.gradle at the end of repositories: authToken added in the gradle.properties

allprojects {
    repositories {
        google()
        maven {
            url https://jitpack.io
            credentials { username authToken }
        }
     }
  }

Once you've updated your build.gradle/settings.gradle file, sync your project in File -> Sync Project with Gradle Files.

The Android build environment will now validate the authentication token and download the dependencies.

3. Installation

We publish the SDK to mavenCentral as an AAR file. Just declare it as a dependency in your build.gradle file

implementation 'org.bitbucket.onmobile-rbtsdk.gamelysdkandroid:gamelysdk:$version$'

Onmobile team share you the latest path/version details of the SDK

4. Configurations Dependencies

Gamely SDK module has dependencies with the following third-party libraries.

dependencies {
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.3'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.3'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

    implementation platform('com.google.firebase:firebase-bom:32.1.1') //required for referral only
    implementation 'com.google.firebase:firebase-analytics-ktx' //required for referral only
    implementation 'com.google.firebase:firebase-dynamic-links-ktx' //required for referral only
}

Note:
There is no need to add the above dependencies.
In case the project also uses some or any of the above dependencies and libraries then exclude those by adding below lines along with

implementation 'org.bitbucket.onmobile-rbtsdk:latest_version'
{exclude group: ‘com.x.y’ , module: ‘module X’}

implementation 'org.bitbucket.onmobile-rbtsdk:gamelysdkandroid:gamelysdk:latest_version'
{exclude group: 'androidx.appcompat', module: ' appcompat'}

This step is…If your app is…
Requiredusing a different version of AppCompat library.SDK will use the same version of library in the app.
Not requirednot using AppCompat library.
Not requiredusing the same version of AppCompat library. Android OS will keep only one version of library for both app and SDK.

5. Initialize SDK

You can do SDK initialization in the application/activity class

 val gamelySDKClient = GamelySdkClient.Builder(this)
            .setUserId("unique user id value") //Mandatory
            .setApiKey("api key value")//Mandatory
            .setLocale(GamelyLocale.ENGLISH)//Optional
            .setUpEnvironment(Environment.STAGING)//Optional, default: Environment.PRODUCTION
            .setInitListener(iSdkInitListener)//Optional
            .build()
GamelySdkClient gamelySDKClient = new GamelySdkClient.Builder(this)
        .setUserId("unique user id value") // Mandatory
        .setApiKey("api key value") // Mandatory
        .setLocale(GamelyLocale.ENGLISH) // Optional
        .setUpEnvironment(Environment.STAGING) // Optional, default: Environment.PRODUCTION
        .setInitListener(iSdkInitListener) // Optional
        .build();
ParameterDescription
ApiKeyMandatory : Client's unique API Key will be shared by onmobile
LocaleOptional : User selected locale like ENGLISH, BANGLA etc. Refer GamelyLocale
EnvironmentOptional : This facilitates client to test sdk in seperate environment.Default is PRODUCTION. Refer Environment
InitListenerOptional : This listener is used to identify the reason behind failure in sdk intialization. Refer ISdkInitListener

Copyright

©2022 OnMobile Global Limited All Rights Reserved.