NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

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


 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...


Hacking with Swift is sponsored by Fernando Olivares

SPONSORED Would you describe yourself as knowledgeable, but struggling when you have to come up with your own code? Fernando Olivares has a new book containing iOS rules you can immediately apply to your coding habits to see dramatic improvements, while also teaching applied programming fundamentals seen in refactored code from published apps.

Try the book!

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

Reply to this topic…

You need to create an account or log in to reply.

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.