Add and initialize the OpenWeb Android SDK

Add the OpenWeb SDK to your Android app

To add a Conversation to your app, you must import the OpenWeb Android SDK and then configure your project.


27262726

Implementation

  1. From within Android Studio, open your app.

  1. In the project build.gradle file, add the JitPack repository: https://jitpack.io.
allprojects {
    repositories {
        ...
      maven { url "https://jitpack.io" }
    }
}

  1. In the app build.gradle file, add the com.github.SpotIM.spotim-android-sdk:spotim-sdk:1.15.1 and androidx.multidex:multidex:2.0.1 dependencies.

📘

Be sure to use the correct code sample below. For Android 12 and above, a dependency constraint is required.

dependencies {
    ...
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.github.SpotIM.spotim-android-sdk:spotim-sdk:1.15.1'
        constraints {
        implementation('androidx.work:work-runtime:2.7.1') {
            because '''androidx.work:work-runtime:2.1.0 pulled from
                           play-services-ads has a bug using PendingIntent without
                           FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
                           targeting S+.
                '''
    }
}
dependencies {
    ...
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.github.SpotIM.spotim-android-sdk:spotim-sdk:1.13.0'
}

  1. Also in the app build.gradle file, set minSdkVersion to 19 or greater. If you set minSdkVersion to 19 - 20, you must also set multiDexEnabled true.
android {
    defaultConfig {
        ...
        minSdkVersion 19
        multiDexEnabled true
    }

  1. In the AndroidManifest.xml file, add the permissions to use the Internet and to enable users to add images to comments from a camera or photo library.
<manifest ... >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    ...
</manifest>

  1. In onCreate() of the application class, initialize the OpenWeb SDK with your Spot_ID. You can also initialize the OpenWeb SDK with a callback. The callback indicates if the initialization has been successful.
SpotIm.init(
    this,
    "SPOT_ID"
)
SpotIm.init(
    this,
    "SPOT_ID",
    object: SpotVoidCallback {
        override fun onSuccess(fragment: Fragment) {
            // All good...
        }

        override fun onFailure(exception: SpotException) {
            when(exception) {
                is SPServerErrorException -> { } // do something
                is SPNoInternetConnectionException -> { } // do something
                is SPSdkDisabeledException -> { } // do something
                else -> { } // do something 
            }
        }
    }
)


Next Step
Did this page help you?