Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HKWorkoutSession isn't keeping app at front of Apple Watch

It has been stated that an app running a HKWorkoutSession will have special privileges over other watchOS 2 apps, so when a user looks at their Apple Watch, it will go to the view showing running a workout rather than the watch face.

Currently, on both my device and simulator, this is not the case. If I start a HKWorkoutSession and then leave for 5 minutes and then interact with either the Apple Watch, or the Watch Simulator, it presents the watch face.

If I then open my app, it appears to have been frozen, rather than terminated (which is what I imagine happens to other apps). As the UI will update when I need receive a response in my query.updateHandler. Also if I set it to provide haptic feedback every time my query.updateHandler receives a new HKQuantitySample it will do so, so the app must be running in the background in some form.

Has anyone else noticed this behaviour, and am I doing anything wrong, or expecting something I shouldn't?

Here is how I start my HKWorkoutSession:

    self.workoutSession = HKWorkoutSession(activityType: HKWorkoutActivityType.Other, locationType: HKWorkoutSessionLocationType.Indoor)

        self.healthStore.startWorkoutSession(self.workoutSession) {
            success, error in

            if error != nil {
                print("startWorkoutSession \(error)\n")
                self.printLabel.setText("startWorkoutSession \(error)")
                self.printLabel.setTextColor(UIColor.redColor())
            }
like image 546
William Robinson Avatar asked Jul 04 '15 19:07

William Robinson


People also ask

How do I keep apps on top of Apple Watch?

You can choose the Return to App setting by tapping the app in Return to Clock, either on your iPhone or on your Apple Watch. If the Return to App setting is available for that app, you'll see a Return to App slider. Toggle the Return to App option to On to keep the app open on your Watch as long as it's active.

Why is my app not showing on my Apple Watch?

If you can't find an app On your Apple Watch, apps appear on your Home screen. Press the Digital Crown to see the Home screen. If you don't see an app on the Home screen, you can see a list of apps that you bought and redownload them.

How do I get all the apps to show on my Apple Watch?

Swipe left on the app, then tap X. Switch from the Dock to the Home Screen: Scroll to the bottom of the Dock, then tap All Apps.


1 Answers

We're seeing that too, for the moment we've made sure 'opens last activity' is configured.

When the UI is active we start a dispatch_timer to request and process data in 1 second intervals.

Make sure you do any significant processing using the NSUserProcessInfo method though and pause the dispatch_timers whenever you are no longer active. You'll get crashes otherwise.

like image 128
earltedly Avatar answered Sep 30 '22 02:09

earltedly