UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Extended WK Session Help...

Forums > watchOS

I'm a newbie to iOS and watchOS dev, but I have built an app in SwiftUI that is running on both platforms and I am trying to get WKExtendedRuntimeSession behaving as expected. I have added the Extended Mode for the WK extension and have selected Mindfullness which I understood would allow the app to stay active until dismissed or timed out (1hr).

In the view that I want to keep running I initailized a session

var session = WKExtendedRuntimeSession()

and start it when the view appears

.onAppear() { // Start the session object. self.session.start() ... }

and of course invalidate whenever the user quits

 session.invalidate()

 but the behavior seems to be the same with the app going into a background mode after about 10 secs and then if I raise my wrist the animation and sounds are still playing along with the countadown timer but I was expecting it to stay alive until either the user qiut or the timer ran out.  

 Am I missing something here?  Is there a way to debug this since I don't really know if the session is actually working or if I am misunderstanding how this is supposed to work.  Any help will be greatly appreciated...

5      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.