Back to All

How to fetch report immediately after scanning?

How long does it take for the sleep session to be processed after tracking is stopped? After stop tracking, I would like to show the last night summary how they slept. What is the best practice in doing so?


Thank you

Hi, Thunyapat.

After calling stopTracking() and receiving the didClose() callback indicating that the sleep session has ended, it generally takes about 2 to 10 seconds for the session to be processed, depending on the server's status.

As a best practice, we recommend waiting approximately 4 seconds after receiving the didClose() callback before requesting the report. When you receive the report, check the value of Report.session.state. If the state is CLOSED, it means the analysis is not yet complete. If the state is COMPLETE, the analysis has finished. (Refer to the documentation: https://docs-en.asleep.ai/docs/ios-reports#asleepmodelsession)

If the state is CLOSED, we recommend polling every 4 seconds until the state changes to COMPLETE.

Thanks.