How to test handleActiveWorkoutRecovery?

I'm excited to implement `handleActiveWorkoutRecovery` as we have a lot of users who complain of lost data.


I have a couple of questions though:


1) How can I test this method and check we are restoring everything correctly?

2) Is it possible to restore the route builder?


Thanks in advance


Lewis

Hi


- Start your watch app on device with XCode

- Start the workout (HKWorkoutSession) from your watch app

- Stop the running app from XCode

After this your watch app should re-run by the watch because of the ongoing HKWorkoutSession.


Best regards


G.

Hi G


As it stands debugging watch apps on Xcode isn't a viable option as it's way to flakey.


That said, your comment pointed me in the right direction!


I was thinking that the app would have to crash, but after your comment I tried force quitting the watch app, and doing that is you need to do trigger handleActiveWorkoutRecovery 🙂


Thanks!

Is this broken in watchOS 6? I'm unable to get the app to relaunch where it worked in watchOS 5...

Are you able to trigger handleActiveWorkoutRecovery? For me its not getting triggered at all when the app crashes. Also how are you making it trigger ? Ive tried force quititng the app, stopping it via xcode and having a button trigger 'exit(0)'

Did anyone find a solution for this or an acknowledgement from Apple that this is indeed broken? Just created a SwiftUI watchOS app and ran into this issue.

Just call it directly.

// it appears handleActiveWorkoutRecovery isn't called, so we are updating the name, and calling it directly.
func checkForActiveWorkoutSession() {
    HealthStoreManager.shared.healthStore.recoverActiveWorkoutSession { (session, error) in
        if let session {
            Crashlytics.crashlytics().record(error: NSError(domain: "Workout Recovery", code: 00, userInfo: nil))
            WorkoutFactory.shared.restoreSession(session)
        }
    }
}
How to test handleActiveWorkoutRecovery?
 
 
Q