Interface HKWorkoutSessionDelegate


  • public interface HKWorkoutSessionDelegate
    [@enum] HKWorkoutSessionStateDelegate This protocol should be implemented to be notified when a workout session's state changes. The methods on this protocol are called on an anonymous serial background queue. API-Since: 17.0
    • Method Detail

      • workoutSessionDidBeginActivityWithConfigurationDate

        default void workoutSessionDidBeginActivityWithConfigurationDate​(@NotNull
                                                                         @NotNull HKWorkoutSession workoutSession,
                                                                         @NotNull
                                                                         @NotNull HKWorkoutConfiguration workoutConfiguration,
                                                                         @NotNull
                                                                         @NotNull NSDate date)
        workoutSession:didBeginActivityWithConfiguration:date: This method is called whenever a new activity begins. Whenever a new workout activity begins, the new configuration would be passed to the session delegate via this method. Clients may use this data to create a workout activity to save when building an HKWorkout object. API-Since: 17.0
      • workoutSessionDidChangeToStateFromStateDate

        void workoutSessionDidChangeToStateFromStateDate​(@NotNull
                                                         @NotNull HKWorkoutSession workoutSession,
                                                         long toState,
                                                         long fromState,
                                                         @NotNull
                                                         @NotNull NSDate date)
        workoutSession:didChangeToState:fromState:date: This method is called when a workout session transitions to a new state. The date is provided to indicate when the state change actually happened. If your application is suspended then the delegate will receive this call once the application resumes, which may be much later than when the original state change ocurred.
      • workoutSessionDidDisconnectFromRemoteDeviceWithError

        default void workoutSessionDidDisconnectFromRemoteDeviceWithError​(@NotNull
                                                                          @NotNull HKWorkoutSession workoutSession,
                                                                          @Nullable
                                                                          @Nullable NSError error)
        workoutSession:didDisconnectFromRemoteDeviceWithError: This method is called when the session is disconnected from its remote counterpart. After this method is called for a mirrored workout session, it is no longer considered valid. API-Since: 17.0
      • workoutSessionDidEndActivityWithConfigurationDate

        default void workoutSessionDidEndActivityWithConfigurationDate​(@NotNull
                                                                       @NotNull HKWorkoutSession workoutSession,
                                                                       @NotNull
                                                                       @NotNull HKWorkoutConfiguration workoutConfiguration,
                                                                       @NotNull
                                                                       @NotNull NSDate date)
        workoutSession:didEndActivityWithConfiguration:date: This method is called whenever the current workout activity ends. Whenever a new workout activity ends, the new configuration would be passed to the session delegate via this method. Clients may use this data to create a workout activity to save when building an HKWorkout object. API-Since: 17.0
      • workoutSessionDidFailWithError

        void workoutSessionDidFailWithError​(@NotNull
                                            @NotNull HKWorkoutSession workoutSession,
                                            @NotNull
                                            @NotNull NSError error)
        workoutSession:didFailWithError: This method is called when an error occurs that stops a workout session. When the state of the workout session changes due to an error occurring, this method is always called before workoutSession:didChangeToState:fromState:date:.
      • workoutSessionDidGenerateEvent

        default void workoutSessionDidGenerateEvent​(@NotNull
                                                    @NotNull HKWorkoutSession workoutSession,
                                                    @NotNull
                                                    @NotNull HKWorkoutEvent event)
        workoutSession:didGenerateEvent: This method is called whenever the system generates a workout event. Whenever a workout event is generated, such as pause or resume detection, the event will be passed to the session delegate via this method. Clients may save the generated events to use when creating an HKWorkout object. API-Since: 10.0
      • workoutSessionDidReceiveDataFromRemoteWorkoutSession

        default void workoutSessionDidReceiveDataFromRemoteWorkoutSession​(@NotNull
                                                                          @NotNull HKWorkoutSession workoutSession,
                                                                          @NotNull
                                                                          @NotNull NSArray<? extends NSData> data)
        workoutSession:didReceiveDataFromRemoteWorkoutSession: This method is called when the session receives data from its remote counterpart. API-Since: 17.0