From 9c1e63e64b4a8c08d719c55a79e4ffd3011d788d Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 7 Nov 2026 17:18:50 +0100 Subject: [PATCH] fix(native): the watch bridge stays silent on an iPad The "watch" feature is offered only where WatchConnectivity is supported, so the UI never builds a watch snapshot on an iPad, and the phone's link neither activates a session nor stores or sends anything there. --- client/ios/App/App/TrekShellPlugin.swift | 10 +++++++++- client/ios/App/App/TrekWatchLink.swift | 10 ++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/client/ios/App/App/TrekShellPlugin.swift b/client/ios/App/App/TrekShellPlugin.swift index ec3b9b621..2a5f7a06d 100644 --- a/client/ios/App/App/TrekShellPlugin.swift +++ b/client/ios/App/App/TrekShellPlugin.swift @@ -55,7 +55,11 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr /// and a server can require a minimum (minNativeShellApi in /api/health/features). static let shellApi = 2 /// The native features by name, so the UI can turn each on by itself. - static let features: [String] = ["capabilities", "edgeBack", "tileCache", "biometricLock", "geolocation", "sharedFiles", "nativePush", "widgets", "liveActivity", "widgetTrips", "storeKit", "shareSheet", "wallet", "watch"] + /// "watch" only where WatchConnectivity is (an iPhone, not an iPad), so the UI never builds a snapshot for nothing. + static var features: [String] { + ["capabilities", "edgeBack", "tileCache", "biometricLock", "geolocation", "sharedFiles", "nativePush", "widgets", "liveActivity", "widgetTrips", "storeKit", "shareSheet", "wallet"] + + (TrekWatchLink.isAvailable ? ["watch"] : []) + } // MARK: - Shared booking documents @@ -144,6 +148,10 @@ public class TrekShellPlugin: CAPPlugin, CAPBridgedPlugin, ASWebAuthenticationPr /// Passes what the watch app shows (native/watch.ts builds it) on to the watch. @objc func setWatchSnapshot(_ call: CAPPluginCall) { + guard TrekWatchLink.isAvailable else { + call.resolve() + return + } guard let json = call.getString("json"), let data = json.data(using: .utf8) else { call.reject("json is required") return diff --git a/client/ios/App/App/TrekWatchLink.swift b/client/ios/App/App/TrekWatchLink.swift index 2ca2512c2..87d5e0228 100644 --- a/client/ios/App/App/TrekWatchLink.swift +++ b/client/ios/App/App/TrekWatchLink.swift @@ -23,8 +23,12 @@ final class TrekWatchLink: NSObject, WCSessionDelegate { /// The most WatchConnectivity carries in one application context, with room to spare. private let maxBytes = 60_000 + /// False on an iPad (and anything else without a paired watch): then this is + /// a no-op throughout, and the UI is not offered the feature at all. + static var isAvailable: Bool { WCSession.isSupported() } + func activate() { - guard WCSession.isSupported() else { return } + guard Self.isAvailable else { return } WCSession.default.delegate = self WCSession.default.activate() } @@ -32,6 +36,7 @@ final class TrekWatchLink: NSObject, WCSessionDelegate { // MARK: Snapshots to the watch func publish(_ json: Data) { + guard Self.isAvailable else { return } let data = withSmallCover(json) queue.async { UserDefaults.standard.set(data, forKey: self.snapshotKey) @@ -40,8 +45,9 @@ final class TrekWatchLink: NSObject, WCSessionDelegate { } private func send(_ data: Data) { + guard Self.isAvailable else { return } let session = WCSession.default - guard WCSession.isSupported(), session.activationState == .activated, session.isPaired, session.isWatchAppInstalled else { return } + guard session.activationState == .activated, session.isPaired, session.isWatchAppInstalled else { return } try? session.updateApplicationContext(["snapshot": data]) let digest = complicationDigest(data) if session.isComplicationEnabled, session.remainingComplicationUserInfoTransfers > 0,