Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    This week in AI updates: GitHub Copilot SDK, Claude’s new constitution, and more (January 23, 2026)

    January 25, 2026

    Ambient-air power start-up secures £2m seed round funding

    January 25, 2026

    Today’s NYT Connections Hints, Answers for Jan. 25 #959

    January 25, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»swift – iOS Safari Web Extension: Communication with Apple Watch App fails
    iOS Development

    swift – iOS Safari Web Extension: Communication with Apple Watch App fails

    big tee tech hubBy big tee tech hubJanuary 11, 2026013 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    swift – iOS Safari Web Extension: Communication with Apple Watch App fails
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I am building an iOS app that includes a Safari Web Extension and a companion Apple Watch App.
    My goal is simple: When the user taps the button in the Safari Extension popup, I want to send a message (e.g., the current timestamp) to the Apple Watch.

    The Setup:

    • iOS 26.2 / Xcode 26.2

    • Target 1: iOS Main App (activates WCSession successfully).

    • Target 2: Safari Web Extension (Manifest V3, using SafariWebExtensionHandler).

    • Target 3: Watch App.

    The Problem:
    While WatchConnectivity works perfectly from the main iOS App, it fails immediately when called from the SafariWebExtensionHandler. It seems like the extension process is sandboxed in a way that prevents it from connecting to the Watch Connectivity Daemon (com.apple.wcd).

    The Trigger (JavaScript):
    The Swift logic is triggered via Native Messaging from the extension’s popup (popup.js) when the user taps a button. I have the “nativeMessaging” permission enabled in my manifest.json.

    // popup.js
    browser.runtime.sendNativeMessage({ message: "sendTime" }, function(response) {
        console.log("Response from Swift:", response);
    });
    

    The Code (Extension Handler):
    I am using a Singleton to manage the session to avoid race conditions during the short lifecycle of the extension.

    import SafariServices
    import WatchConnectivity
    import os.log
    
    class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling, WCSessionDelegate {
    
        func beginRequest(with context: NSExtensionContext) {
            // ... extracting message from JS ...
            
            if WCSession.isSupported() {
                let session = WCSession.default
                session.delegate = self
                session.activate() // <--- FAILS HERE
            }
        }
        
        func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
            if activationState == .activated {
                session.transferUserInfo(["time": "12:00"])
            }
        }
        
        // ... other delegate stubs ...
    }
    

    The Logs:
    The logs clearly show an XPC interruption immediately after trying to connect to com.apple.wcd. It retries 5 times and then fails.

    WatchTestExt Extension  ... [0x1030d0640] activating connection: mach=true ... name=com.apple.wcd
    WatchTestExt Extension  ... [0x1030d0640] Re-initialization successful; calling out to event handler with XPC_ERROR_CONNECTION_INTERRUPTED
    WatchTestExt Extension  ... -[WCSession xpcConnectionInterrupted]
    WatchTestExt Extension  ... -[WCSession activateSession]_block_invoke sessionReadyForInitialStateWithCompletionHandler failed due to NSXPCConnectionInterrupted
    ...
    WatchTestExt Extension  ... -[WCXPCManager onqueue_retryConnectIfNecessary] failed to reconnect to daemon (5 attempts)
    

    What I have tried:

    1. Direct Communication: Using sendMessage and transferUserInfo directly from the Extension. Result: NSXPCConnectionInterrupted.

    2. App Groups (Relay):

      • I successfully implemented a relay using App Groups (UserDefaults(suiteName: …)).

      • The Extension writes the data to the shared group.

      • The Main iOS App observes the UserDefaults (via KVO or Darwin Notifications) and sends the data to the Watch.

      • Issue: This only works if the iOS Main App is running in the background. If the user force-quits the main app (or iOS suspends it aggressively), the relay stops working because the Extension cannot wake up the Main App.

    My Question:
    Is it technically possible for a Safari Web Extension on iOS to communicate directly with WatchConnectivity? Or is this a hard sandbox limitation by Apple?

    If it is a hard limitation, is there any way for a Safari Extension to wake up its parent iOS App in the background to perform the transfer, even if the parent app has been killed?



    Source link

    app Apple Communication extension Fails iOS Safari Swift Watch Web
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – Why does my page scroll up when I tap on a button?

    January 25, 2026

    Your iPhone is out of space again—This app fixes that for $20

    January 24, 2026

    swift – iOS suspends app after BLE discovery even though I start Always-authorized location udpates

    January 24, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    This week in AI updates: GitHub Copilot SDK, Claude’s new constitution, and more (January 23, 2026)

    January 25, 2026

    Ambient-air power start-up secures £2m seed round funding

    January 25, 2026

    Today’s NYT Connections Hints, Answers for Jan. 25 #959

    January 25, 2026

    How Data-Driven Third-Party Logistics (3PL) Providers Are Transforming Modern Supply Chains

    January 25, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    This week in AI updates: GitHub Copilot SDK, Claude’s new constitution, and more (January 23, 2026)

    January 25, 2026

    Ambient-air power start-up secures £2m seed round funding

    January 25, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.