Sample App
Asleep Track SDK Sample App
We provide sample code and app that allow you to easily and quickly check the sleep monitoring service of Asleep Track on the client based on the latest SDK version, and the sample code supports Android Kotlin and iOS Swift.
1. Groundwork
1.1 Generate API Key
You need an API Key to use the Asleep Track SDK Sample App.
Please refer to this link Generate API Key for how to issue an API Key.
1.2 Sample App Location
- iOS Sample App Path: https://github.com/asleep-ai/asleep-sdk-ios-sampleapp-public
- Android Sample App Path: https://github.com/asleep-ai/asleep-sdk-android-sampleapp-public
2. How to use the iOS Sample App
2.1 Installation guide
- Enter the API Key you received in “yourKeyHere” of MainView.swit.
If you use Base URL and Callback URL, enter them in “baseUrl” and “callbackUrl” below.
struct MainView: View {
private let pastboard = UIPasteboard.general
@StateObject private var viewModel = MainView.ViewModel()
@AppStorage("sampleapp+apikey") private var apiKey = "yourKeyHere"
@AppStorage("sampleapp+userid") private var apiKey = ""
@AppStorage("sampleapp+baseurl") private var apiKey = "baseUrl"
@AppStorage("sampleapp+callbackurl") private var apiKey = "callbackUrl"
-
After building, installing, and running the Sample Code with the API Key applied, you will see the following first screen below.
2.2 User Guide
-
Start Measurement: If you press the "Start Tracking" button, a User ID will be automatically generated if you do not have one, and the measurement will start if you allow microphone permission.
-
Measuring: The screen during tracking looks like below.
- Start Time: This is the start time of the measurement.
- Uploaded Sequence: This is the order and cumulative measurement time of the uploaded audio data. The order and time are updated every time audio data is uploaded.
- Audio data upload occurs every 30 seconds.
- To get a valid sleep report, you need the first 20 minutes of measurement time (40 audio data uploads).
- If you press the "Stop Tracking" button, the measurement will end.
-
End measurement: When you end the measurement, the following screen will appear and you can check the session ID.
- Session ID: This is the unique ID of the session you created.
- If you press the "Start Tracking" button, a new sleep measurement will start, and if you press the Get Report button, you can check the report.
-
Check report: This is the page where you can check the report by pressing the "Get Report" button.
- Please check page Asleep Data Metics for the data shown in the report when requesting "Get Report" after the sleep stage monitoring is completed. You will not be able to see the statistical data before the analysis is complete.
3. How to use the Android Sample App
3.1 Installation guide
- Enter the api key in local.properties.
asleep_api_key="ApiKey" d
- If you want to use Base URL and Callback URL, enter them in “baseUrl” and “callbackUrl”.
Asleep.initAsleepConfig(
context = applicationContext,
apiKey = BuildConfig.ASLEEP_API_KEY,
userId = _userId,
baseUrl = null, // input "baseUrl"
callbackUrl = null, // input "callbackUrl"
service = "SampleApp",
object : Asleep.AsleepConfigListener{}))
-
After building, installing, and running the Sample Code with the API Key applied, you will see the following first screen below.
-
Battery optimization option is selectable.
3.2 User Guide
-
Start Measurement: If you press the "Start Tracking" button, a User ID will be automatically generated if you do not have one, and the measurement will start if you allow microphone and alarm permission settings.
- You need to see the microphone icon and the notification in the notification bar to confirm that the measurement is in progress.
-
Measuring: The screen during tracking looks like below.
- Start Time: This is the start time of the measurement.
- Uploaded Sequence: This is the order and cumulative measurement time of the uploaded audio data. The order and time are updated every time audio data is uploaded.
- Audio data upload occurs every 30 seconds.
- To get a valid sleep report, you need the first 20 minutes of measurement time (40 audio data uploads).
- If you press the "Stop Tracking" button, the measurement will end.
-
Measurement end and report confirmation: When the measurement is finished, the following screen appears, and you can check the real-time report results with the session ID.
- Session ID: This is the unique ID of the session you created.
- Real-time result report comes out after the measurement.
- This is a result in Closed state, and you need to click the "Get Report Again" button to check the result in Completed state for accurate result data.
-
Check Report: The page where you check the Completed report by clicking the "Get Report Again" button once more in the Closed session state is as follows.
- Results with a status of "Completed" are the final results available. No statistical data is available at any point in time when the sleep monitoring analysis is not complete.
- For the data shown in the report, check Data Metic 페이지.
4. How to check sleep analysis results
4.1 Check out the report in the sample app
Please refer to the description on the current page
- iOS Sample App: 2.2-4
- Android Sample App: 3.2-4
4.2 Check your sessions on the dashboard
- Log in to the Asleep dashboard with the account that created the API key.
- Find the Session ID you want to check in the "Session Tab" and check the sleep analysis results.
- Please check page Dashboard-Sessions for the description of the data you can see on the Session page.
Updated 8 months ago