Worksession not active in watch device

As per the documentation, the App to using HKworkoutsession continues to run inthe foreground. But I've noticed different behaviour in simulator and device.


In iPhone + Watch simulator, it seems to work as per the documentation. An active work out session seems to keep the watch App alive.


In iPhone + Watch device, the watch app seems to go into inactive state in 15-20 sec after the watch screen becomes inactive.

Here is how I am setting up the workout session

workoutSession = HKWorkoutSession(activityType: HKWorkoutActivityType.Running, locationType: HKWorkoutSessionLocationType.Indoor) HKHealthStore().startWorkoutSession(workoutSession)

Is anyone obverving the same behaviour? Does it seems like a beta bug?

Replies

I am having the same issue, but have been unable to find a solution. I had hoped that I wasn't the only one with this problem.

How did you find out the app becomes inactive? I would like to give a test as well.

I'm seeing the same issue with beta 5. The app becomes inactive once the screen goes black, so for instance I'm unable to use an NSTimer to notify user of a half point, as this is never called.

Same issue here. I'm using the GM version already. The documentation even states that when a workout is running, the app should remain on the foreground. Has anyone opened a radar?

Also using the GM, and I'm able to exhibit this in the simulator as well as on the device:

- Switch back to the home screen (or clock face)

- Lock the simulator

- Leave for a while (30 seconds seems to be enough)

- When you unlock the HKWorkoutSession is no longer running, and my delegate methods don't get called, even after the app restarts. If you try to stop the HKWorkoutSession, I get an error "Workout session is not current".

Interestingly, after updating to Xcode 7.0.1 and recompiling, this problem is no longer reproducible in the simulator using the above steps, and I've also not seen it on the device since either.


Has anyone else experienced the same behaviour, or seen the bug again after using Xcode 7.0.1?

OK, seen again on the device after using Xcode 7.0.1 😟

I think an NSTimer will not work even with a session. the app will remain in foreground but the OS will not let you run any code when the watch is asleep or user exists app.