Skip to content

Example Integration(s)

Pallab edited this page Mar 8, 2021 · 2 revisions

Adding dependencies

  • Add the following maven repository to the project dependency repositories:
maven {
    url "https://raw.github.com/somia/ninchat-sdk-android/master"
}

Example

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://raw.github.com/somia/ninchat-sdk-android/master"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
  • Then you need to add the following dependency to the project dependencies:
/*ninchat dependencies stuffs*/
implementation 'com.ninchat:sdk:0.6.1'

Example

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    /*ninchat dependencies stuffs*/
    implementation 'com.ninchat:sdk:0.6.1'
}

Gather configuration string(s)

In order to use ninchat we need ninchat configuration key, queue details and server address

Example

<string name="ninchat_server_address">api.ninchat.com</string>
<string name="ninchat_configuration_key">site/7f5b245900frk/7lir3jto00e3.json</string>
<string name="ninchat_queue">7lbr3h2v00cq</string>

Basic Integratation

ninchatConfiguration = NinchatConfiguration.Builder()
    .setUserName("Test Android client")
    .create()

val builder = NinchatSession.Builder(
    applicationContext, getString(R.string.ninchat_configuration_key))

    .setConfiguration(ninchatConfiguration)
    .setEventListener(eventListener)

val ninchatSession = builder.create()
ninchatSession.setServerAddress(getString(R.string.ninchat_server_address))
// no queue is specific
ninchatSession.start(this)
// if we want to use a specific queue instead of starting without a queue
// ninchatSession.start(this, 1024, getString(R.string.ninchat_queue));

Next

Clone this wiki locally