PolarSleepApi
public protocol PolarSleepApi
Protocol defining methods to get Polar Sleep Data
-
getSleepRecordingState(identifier:AsynchronoustimeoutMs: ) Get sleep recording state
Requires
Requires SDK feature(s):PolarBleSdkFeature.feature_polar_sleep_dataThrows
timeout(description:)if timeout is exceeded before state is received.Declaration
Swift
func getSleepRecordingState(identifier: String, timeoutMs: UInt64) async throws -> BoolParameters
identifierThe Polar device ID or BT address
timeoutMsTimeout in milliseconds while waiting for the first sleep recording state event
Return Value
AnyPublisher emitting a single Bool value indicating if sleep recording is ongoing
-
Declaration
Swift
func observeSleepRecordingState(identifier: String) -> AsyncThrowingStream<[Bool], Error>Return Value
Publisher stream of Bool values indicating if sleep recording is ongoing
-
stopSleepRecording(identifier:Asynchronous) Declaration
Swift
func stopSleepRecording(identifier: String) async throwsReturn Value
Publisher stream
-
getSleep(identifier:AsynchronousfromDate: toDate: ) Declaration
Swift
func getSleep(identifier: String, fromDate: Date, toDate: Date) async throws -> [PolarSleepData.PolarSleepAnalysisResult]Return Value
Publisher emitting an array of
PolarSleepDatafor the specified period. -
getSleepData(identifier:Default implementation, asynchronousfromDate: toDate: ) - Deprecated: Use
getSleep(identifier:fromDate:toDate:)instead.
Default Implementation
Declaration
Swift
@available(*, deprecated, renamed: "getSleep(identifier:fromDate:toDate:﹚") func getSleepData(identifier: String, fromDate: Date, toDate: Date) async throws -> [PolarSleepData.PolarSleepAnalysisResult] - Deprecated: Use
-
getSleepRecordingState(identifier:Extension method, asynchronous) Get sleep recording state with default timeout of 30 seconds.
Declaration
Swift
func getSleepRecordingState(identifier: String) async throws -> Bool