These docs are for v1.0. Click to read the latest docs for v2.0.

AsleepConfig

1. Initialize Config

Asleep.initAsleepConfig()

Reset SDK.

initAsleepConfig(
    context: Context, 
    apiKey: String, 
    userId: String?, 
    baseUrl: String?, 
    callbackUrl: String?, 
    service: String?, 
    asleepConfigListener: Asleep.AsleepConfigListener
)
Parameter NameTypeDescription
contextContextEnter ApplicationContext
apiKeyStringEnter the value issued by Generate API key
userIdString?Enter null if there is no initial userId, and enter the userId that has been issued since
baseUrlString?If null, use the default value, enter the proxy server address
callbackUrlString?Enter the url of the server to receive sleep session analysis results
serviceString?your app name
asleepConfigListenerAsleepConfigListenerlistener to receive callback for userId

Asleep.ConfigListener

interface AsleepConfigListener {
    fun onSuccess(userId: String?, asleepConfig: AsleepConfig?)
    fun onFail(errorCode: Int, detail: String)
}
  • If success, onSuccess()is called.
Parameter NameTypeDescription
userIdString?Newly issued or entered userId
asleepConfigAsleepConfig?Required set value to use the SDK
  • If failure, onFail() is called.
Parameter NameTypeDescription
errorCodeIntAsleepErrorCode
detailStringerrorCode Message

2. Delete User

Asleep.deleteUser()

Delete all data of the user, including userId.

fun deleteUser(deleteUserIdListener: DeleteUserIdListener?)
Parameter NameTypeDescription
deleteUserIdListenerDeleteUserIdListener?listener to receive callback for deleted userId

Asleep.DeleteUserIdListener

interface DeleteUserIdListener {
    fun onSuccess(userId: String?)
    fun onFail(errorCode: Int, detail: String)
}
  • If success, onSuccess()is called.
Parameter NameTypeDescription
userIdString?deleted userId
  • If failure, onFail() is called.
Parameter NameTypeDescription
errorCodeIntSee AsleepErrorCode
detailStringerrorCode Message