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 Name | Type | Description |
---|---|---|
apiKey | String | Enter the value obtained from the Generate API key |
userId | String? | When there is no initial userId, enter nil, and later input the received userId. |
baseUrl | URL? | Enter the proxy server address. If nil, default base url is used. |
callbackUrl | URL? | Enter the URL of the server to receive sleep session analysis results. |
service | Service? | Enter the app name |
delegate | AsleepConfigDelegate | Delegate to receive results and errors |
AsleepConfigDelegate
protocol AsleepConfigDelegate {
func userDidJoin(userId: String, config: Asleep.Config)
func didFailUserJoin(error: Asleep.AsleepError)
func userDidDelete(userId: String)
}
-
If success, userDidJoin() is called.
Property Name Type Description userId String generated userId config Asleep.Config genearated config -
If failure, didFailUserJoin() is called.
Property Name Type Description error Asleep.AsleepError Error Codes -
userDidDelete()
If success, all user data including the userId will be deleted.Property Name Type Description userId String Deleted userId
2. Delete User
Asleep.deleteUser()
var config: Asleep.Config?
if let config {
Asleep.deleteUser(config: config)
}
Property Name | Type | Description |
---|---|---|
config | Asleep.Config | Enter the Asleep.Config instance |
Updated over 1 year ago