Logo
Initialize SDK and get device details
To initialise the SDK add the below line of code with the public key you retrieved from Sense client panel. If you don't have a public key create new one and call that below function.
How to Install
toast-icon
Requirements
  1. Use Android 7.0 (API level 21) and above.
  2. Use Kotlin version 1.6.10 and above: example ext.kotlin_version = '1.6.10'
Note:If the application does not have the listed permissions, the values collected using those permissions will be ignored. To provide a valid device details, we recommend employing as much permission as possible based on your use-case.
  1. Maven Installation
    copy-icon
    copy-icon
    repositories {
        ...
        mavenCentral()
        maven { url 'https://mvnrepository.com/artifact/ai.gosense/android' }
        maven { url 'https://jitpack.io' }
    }
    Check out maven for latest version of maven versions.
  2. Add Dependency build.gradle file
    copy-icon
    copy-icon
    dependencies {
        implementation 'ai.gosense:device-security:0.0.7'
    }
    Sync Gradle to synchronize all the dependencies in your Android project.
  3. Import SDK
    copy-icon
    copy-icon
    import ai.gosense.devicesecurity.Sense
    import ai.gosense.devicesecurity.SenseConfig
    Sync Gradle to synchronize all the dependencies in your Android project.
  4. Initialize SDK
    Add the following line of code to initialize it with the api key you obtained from the Sense Client panel. If you don't have a api key create new one
    copy-icon
    copy-icon
    val config = SenseConfig(
        apiKey = "your API Key",
        senseInfo = false, // true or false
        allowGeoLocation = true, //true or false
        tag = "YOUR_TAG",
        // senseConfig.metaInfo = [
        //     "phone": "9xxxxxxxxx",
        //     "name": "xxxxxxxxxxx"
        // ] 
        // A collection of key-value pairs intended for storing supplementary data 
        // related to the request. The set supports up to 15 pairs, with each 
        // key and value limited to a maximum of 256 characters.
    )
    Sense.initSDK(activity, config)
    Sense Config Information
    • Sense Config InformationIf you pass senseInfo as true in above config means, it will return addtional Information like Request ID, First seen, Last seen, IP Address with SenseID. Otherwise it will return only SenseID and Request.
    • If you pass allowGeoLocation as true in above config means, it will return Device Location Information in Sense Details via our Server API.
  5. Get Device Details
    copy-icon
    copy-icon
    Sense.getSenseDetails(this)
    Use the below code to get the Device Details.
  6. Implement Listener
    Set and Implement our listener to receive the Callback details.
    copy-icon
    copy-icon
    Sense.getSenseDetails(object : Sense.SenseListener {
        override fun onSuccess(data: String) {
            // success callback 
        }
        override fun onFailure(message: String) {
            // failure callback
        }
    })
  7. Location Permission (optional)
    You have to add this permission in AndroidManifest.xml to get Device Location Information and to get Retrieve call state, Network state, Network information, Sim datas from READ_PHONE_STATE and READ_PRIVILEGED_PHONE_STATE.
    copy-icon
    copy-icon
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
    tools:ignore="ProtectedPermissions"/>
  8. Progurad Rules (Optional)
    If you encounter any problem in your integration related to Proguard, you can use add the below lines Proguard Rules.
    copy-icon
    copy-icon
    -keep,allowobfuscation,allowshrinking interface retrofit2.Call
    -keep,allowobfuscation,allowshrinking class retrofit2.Response
    -keep,allowobfuscation,allowshrinking class kotlin.coroutines.** { *; }
    -dontwarn ai.gosense.**
    -keep class ai.gosense.** {*;}
  9. Sample Program
    Here you can find the demonstration to do the integration.
    copy-icon
    copy-icon
    import ai.gosense.devicesecurity.Sense
    import ai.gosense.devicesecurity.SenseConfig
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val config = SenseConfig(
                apiKey = "your API Key",
                senseInfo = false, // true or false
                allowGeoLocation = true, //true or false
                tag = "YOUR_TAG",
                // senseConfig.metaInfo = [
                //     "phone": "9xxxxxxxxx",
                //     "name": "xxxxxxxxxxx"
                // ] 
                // A collection of key-value pairs intended for storing supplementary data related to the 
                 // request. The set supports up to 15 pairs, with each key and value 
                 // limited to a maximum of 256 characters.
            )
    
            //Initialize SDK
            Sense.initSDK(this, config)
    
            // Fetch device details
            getSenseDetails();
        }
        private fun getSenseDetails() {
            Sense.getSenseDetails(object : Sense.SenseListener {
                override fun onSuccess(data: String) {
                    // Handle success callback
                }
                override fun onFailure(message: String) {
                    // Handle failure callback
                }
            })
        }
    }