watchOS 3, iOS 10 - WatchConnectivity session on paired device is not reachable

I'm seeing the following error when running my app on device (Apple Watch Series 1 running watchOS 3 + iPhone 6 running iOS 10.0.1) and also when I run on the simulator (Apple Watch Series 2 + iPhone 7).


The code that triggers the error is running on the watch in my watch app extension's "override func willActivate() {...}" method.


session?.sendMessage(["handleWatchKitExtensionRequestMethod": "myMethodNameHere"], replyHandler: { (response) -> Void in

print(response);

}, errorHandler: { (error) -> Void in

print(error);

});


The errorHandler block always gets executed with the following message:


Error Domain=WCErrorDomain Code=7007 "WatchConnectivity session on paired device is not reachable." UserInfo={NSLocalizedDescription=WatchConnectivity session on paired device is not reachable.}


Is anybody else seeing this? Is there a fix for this? This same code works in our App Store version of the app even though that version has not been programmed specifically for iOS 10 or watchOS 3, but it works, as expected. Trying to get this to work in dev when I am targeting watchOS 3 and iOS 10 using Xcode I cannot get this code to work at all.


I read another thread and tried restarting my watch and my iPhone and this has no effect, still fails every time. Please advise if you're able to. Thank you.

Replies

Hi,


I assume you activate the session with something like:

        if ([WCSession isSupported])
        {
            [WCSession defaultSession].delegate = self;
            [[WCSession defaultSession] activateSession];
        }

What values are passed to the delegate method activationDidCompleteWithState:


But maybe you just try to send the message to early. From the docs of activateSession:


This method executes asynchronously and calls the session:activationDidCompleteWithState:error: method of your delegate object upon completion. Call this method when your app is ready to communicate with its counterpart. Your cannot send or receive messages until you call this method. If the delegate property is

nil
, calling this method logs an error.

In watchOS 2.1 and earlier, this method activates the session synchronously and always results in an active session.


Since in watchOS 3 the method executes asychronously, so you have to wait until the delegate method has been called and the session state has become WCSessionActivationStateActivated.


Dirk