AsleepConfig

1. Initialize Config

Asleep.initAsleepConfig()

let apiKey: String = "YOUR_API_KEY"
let userId: String?
let baseUrl: URL?
let callbackUrl: URL?
let service: String?
let delegate: AsleepConfigDelegate = self

Asleep.initAsleepConfig(apiKey: apiKey,
                        userId: userId,
                        baseUrl: baseUrl,
                        callbackUrl: callbackUrl,
                        service: service,
                        delegate: self)
Property NameTypeDescription
apiKeyStringEnter the value obtained from the Generate API key
userIdString?When there is no initial userId, enter nil, and later input the received userId.
baseUrlURL?Enter the proxy server address. If nil, default base url is used.
callbackUrlURL?Enter the URL of the server to receive sleep session analysis results.
serviceService?Enter the app name
delegateAsleepConfigDelegateDelegate to receive results and errors

AsleepConfigDelegate

protocol AsleepConfigDelegate {
    func userDidJoin(userId: String, config: Asleep.Config)
    func didFailUserJoin(error: Asleep.AsleepError)
    func userDidDelete(userId: String)
}
  1. If success, userDidJoin() is called.

    Property NameTypeDescription
    userIdStringgenerated userId
    configAsleep.Configgenearated config
  2. If failure, didFailUserJoin() is called.

    Property NameTypeDescription
    errorAsleep.AsleepErrorError Codes
  3. userDidDelete()
    If success, all user data including the userId will be deleted.

    Property NameTypeDescription
    userIdStringDeleted userId

2. Delete User

Asleep.deleteUser()

var config: Asleep.Config? 
if let config {
		Asleep.deleteUser(config: config)
}
Property NameTypeDescription
configAsleep.ConfigEnter the Asleep.Config instance