Skip to content

sabil-io/sabil-android-sdk

Repository files navigation

Quick start

Use the Sabil APIs in your Android app to manage user devices with ease.

Installation

  1. Add the JitPack repository to your build file
    allprojects {
         repositories {
             ...
             maven { url 'https://jitpack.io' }
         }
     }
  2. Add the dependency
    dependencies { implementation 'com.github.sabil-io:sabil-android-sdk:2.0.11' }
    

Usage

  1. Configure the SDK as soon as your app launches.

    // REQUIRED
    Sabil.configure(this, "<#client id#>")
  2. Attach the device to the user or identify the device without a user.

    // Set this as soon as the user ID is available and attach the device.
    Sabil.userId = "<#user id#>"
    Sabil.attach(supportFragmentManager) {
     Toast.makeText(this, "Attached. Device Id -> ${Sabil.deviceId}", Toast.LENGTH_LONG).show()
    }

    If the user can perform actions on your app without login, use the identify method instead. Both attach and identify accept metadata

    Sabil.identify {
     Log.d("Sabil", "Device identified. Identity: ${it?.identity}")
    }

    Ensure you call the attach or identify when the app enters the foreground state as well.

  3. (Optional) Implement the callbacks. These are useful depending on your use-case. For account sharing prevention, for example, you should implement the onCurrentDeviceLogout and onLimitExceeded callbacks.

    Sabil.onLogoutCurrentDevice = {
            // logout the current device
        }
    
        Sabil.onLimitExceeded = {
            // the user has too many devices using their account
        }

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages