Mobile integration
Android SDK Integration
In this section you will find information on how to integrate the MobSur SDK in your native Android application.
Prerequisites
- AndroidX
- Min SDK version: 21
Installation Guide
- Download the latest release from our repository.
- Extract it and get the mobsur.aar file from there.
- Place it into the app/libs/ directory of your Android application.
- Add the file to the dependencies in the build.gradle file:
dependencies {
//..
implementation files('libs/mobsur.aar')
//..
}
- Add the dependencies required for Retrofit2 in the build.gradle file:
dependencies {
//..
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
//..
}
- Sync your grade dependencies.
Integration Guide
Import the package:
import io.edentechlabs.survey.sdk.MobSur
Initialize the SDK and set the fragment manager:
The user id is defined by you and it is used to distinguish different users, answering the surveys.
//appId can be taken from https://app.mobsur.com/user/apps
MobSur.setup(applicationContext, "appId", "userId")
MobSur.setFragmentManager(supportFragmentManager)
App ID!
You can get the App ID from the MobSur Dashboard.
More information is available here
Trigger an event. For example on button click:
val button = findViewById(R.id.button) as Button
button.setOnClickListener {
MobSur.event("myevent")
}
If you need to change the userId or you do not know it during initialization, use the updateUserId method:
MobSur.updateUserId("newUserId")
Sample project:
A sample project can be found in our GitHub repository.