For AI agents: visit https://docs.asleep.ai/llms.txt for an index of all pages formatted in Markdown and endpoints in OpenAPI. Append .md to any documentation page URL to get its markdown version.
Kotlin
Asleep.initAsleepConfig(
context: Context,
apiKey: String,
userId: String?,
baseUrl: String?,
callbackUrl: String?,
service: String?,
asleepConfigListener: Asleep.AsleepConfigListener,
asleepLogger: AsleepLogger?
)
Parameter Name Type Description context Context applicationContext를 입력 apiKey String Generate API key 에서 발급받은 값을 입력userId String? 초기 userId가 없을 땐 null을 입력, 이후 발급받은 userId를 입력 baseUrl String? null이면 기본값을 사용, 프록시 서버의 url을 입력 callbackUrl String? 수면 세션 분석 결과를 받아올 서버의 url을 입력 service String? 앱 이름 asleepConfigListener AsleepConfigListener userId를 콜백 받을 수 있는 리스너 asleepLogger AsleepLogger? SDK의 log를 콜백 받을 수 있는 리스너
Kotlin
interface AsleepConfigListener {
fun onSuccess(userId: String?, asleepConfig: AsleepConfig?)
fun onFail(errorCode: Int, detail: String)
}
성공 시, onSuccess()가 호출됩니다.
Parameter Name Type Description userId String? 새로 발급 하거나 입력한 userId asleepConfig AsleepConfig? SDK를 사용하기 위해 필요한 설정값
Kotlin
interface AsleepLogger {
fun d(tag: String, msg: String, throwable: Throwable? = null)
fun e(tag: String, msg: String, throwable: Throwable? = null)
fun i(tag: String, msg: String, throwable: Throwable? = null)
fun w(tag: String, msg: String, throwable: Throwable? = null)
}
SDK 내부에서 d(debug), e(error), i(info), w(warn)이 각각 발생하였을 때 호출됩니다.
Parameter Name Type Description tag String "[Asleep SDK]" msg String log message throwable Throwable? SDK 실행 중 발생할 수 있는 문제를 나타내는 class
userId를 포함한 사용자의 모든 데이터를 삭제합니다.
Kotlin
fun deleteUser(deleteUserIdListener: DeleteUserIdListener?)
Parameter Name Type Description deleteUserIdListener DeleteUserIdListener? 삭제된 userId를 콜백 받을 수 있는 리스너
Kotlin
interface DeleteUserIdListener {
fun onSuccess(userId: String?)
fun onFail(errorCode: Int, detail: String)
}
성공 시, onSuccess()가 호출됩니다.
Parameter Name Type Description userId String? 삭제된 userId
포그라운드 서비스가 강제종료 된 후 재시작 되었을 때 종료되지 않은 세션이 존재하는지 체크합니다.
Kotlin
hasUnfinishedSession(context: Context): Boolean
Parameter Name Type Description context Context? applicationContext를 입력
포그라운드 서비스가 강제종료 된 후 재시작 되었을 때 이전에 저장된 asleepConfig를 가져옵니다.
Kotlin
getSavedAsleepConfig(context: Context, apiKey: String): AsleepConfig?
Parameter Name Type Description context Context? applicationContext를 입력 apiKey String Generate API key 에서 발급받은 값을 입력