简体   繁体   中英

How to avoid keeping watch app in front when using HKWorkoutSession?

I have developed an iPhone app with watch app for getting live stream of heart rate. As mentioned in many stackoverflow threads iOS get heart rate from Apple Watch in near real time , i have used HKWorkoutSession to get the updated heart rate and sending it to server (Workout session will always be active to get live stream of heart rate) .

The issue here is, this application always stays in front of watch app(which is the expected behaviour when we use HKWorkoutSession ). But i don't want this behaviour to happen, since the app only does the job of getting heart rate updates and sending it to server.

My app now sends the heart rate correctly to server even when the watch screen is off and when the app is in background since i have used Required background modes (Watch) in info.plist .

Is there any way that we can avoid this app being in front of watch face every-time the user opens the watch?

You cannot avoid making you app frontmost while in a workout session on watchOS. You should file a bug with Apple to request an API with the behavior you want for your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM