Post

Replies

Boosts

Views

Activity

Can't add Widget Extension on WatchOS Target
I can't select my Companion App Target in the Selection Many for "Embed in" in the add Target File. It's a Companion App for a Flutter App. I add the target via File -> New -> Target -> WatchOS -> WidgetExtension The minimum version for the flutter project is iOS 14 and the watch watchOS 10. I tried readding my WatchTarget but it didn't work that time either. I made a dummy project with a default iOS App (No Flutter) and default WatchOS App and there I had the option to select my Companion Target. checking Configuration Intent also changes nothing for the outcome. I also tried adding one into another Runner (Flutter) Project with an Companion App and I run into the same Issue there.
0
0
346
Jul ’24
Is it possible to start an extendedRuntimeSession in background
I have a Companion Watch App for my iPhone App and communicate via the messages and applicationContext between the watch and the phone. If I start an Event at my iPhone and my watch is turned on the extendedRuntimeSession starts as it should. But as soon as my Watches Display is off or Im not in the App I can't start the extendedRuntimeSession, even though I receive it trough the applicationContext and I get the following errorMessage when trying to start the session in the background. -[CSLSSessionService startSession:completionWithExpirationDate:]_block_invoke session A76273B7-3E01-4333-920C-0614C1FAC5B0 encountered error Error Domain=com.apple.CarouselServices.SessionErrorDomain Code=12 "app not in required app state" UserInfo={NSLocalizedDescription=app not in required app state} Is Running is true Timer started/continuend -[SPApplicationDelegate appBeginWorkout:]_block_invoke:1334: Asked to start a workout, but WKExtensionDelegate <SwiftUI.ExtensionDelegate: 0x15d7c500> doesn't implement handleWorkoutConfiguration: Extended runtime session invalidated with reason: WKExtendedRuntimeSessionInvalidationReason(rawValue: -1), error: Optional(Error Domain=WKExtendedRuntimeSessionErrorDomain Code=3 "The app must be active and before applicationWillResignActive to start or schedule a WKExtendedRuntimeSession." UserInfo={NSLocalizedDescription=The app must be active and before applicationWillResignActive to start or schedule a WKExtendedRuntimeSession..}) I control and manage my session like this: class WatchViewModel: NSObject, ObservableObject { static let shared = WatchViewModel() var session: WCSession var extendedRuntimeSessionManager: ExtendedRuntimeSessionManager var lastMessage: [String: Any] = ["method": "none"] @Published var iOSIsReachable = false @Published var dataFromMessages = DataFromMessages() @Published var flextailCoordinates: FlextailCoordinates? init(session: WCSession = .default, extendedRuntimeSessionManager: ExtendedRuntimeSessionManager = ExtendedRuntimeSessionManager()) { NSLog("init start") self.session = session self.extendedRuntimeSessionManager = extendedRuntimeSessionManager super.init() self.session.delegate = self session.activate() NSLog("init done") } } class ExtendedRuntimeSessionManager: NSObject, WKExtendedRuntimeSessionDelegate, ObservableObject{ var extendedRuntimeSession: WKExtendedRuntimeSession? @Published var sessionIsActive = false override init() { super.init() setupExtendedRuntimeSession() } func setupExtendedRuntimeSession() { extendedRuntimeSession = WKExtendedRuntimeSession() extendedRuntimeSession?.delegate = self } func startExtendedRuntimeSession() { if sessionIsActive == false{ extendedRuntimeSession?.start() } else{ print("Already running extendedRuntimeSession") } } func stopExtendedRuntimeSession() { extendedRuntimeSession?.invalidate() sessionIsActive = false setupExtendedRuntimeSession() } // WKExtendedRuntimeSessionDelegate methods func extendedRuntimeSessionDidStart(_ extendedRuntimeSession: WKExtendedRuntimeSession) { print("Extended runtime session started") sessionIsActive = true } func extendedRuntimeSessionWillExpire(_ extendedRuntimeSession: WKExtendedRuntimeSession) { print("Extended runtime session will expire soon") } func extendedRuntimeSession(_ extendedRuntimeSession: WKExtendedRuntimeSession, didInvalidateWith reason: WKExtendedRuntimeSessionInvalidationReason, error: Error?) { print("Extended runtime session invalidated with reason: \(reason), error: \(String(describing: error))") sessionIsActive = false setupExtendedRuntimeSession() } } I tried sending it through the applicationContext but that didn't work, even though the message gets received and parsed as I want. The error specifically seems to be in the starting of an extendedRuntimeSession in the background.
1
0
441
Jul ’24