WCSession has not been activated
One other thing to check if your code seems good and the WCsession still will not activate, restart your watch. This was the answer for me.
I figured out the problem I had, and I think yours is similar. I was trying to send a message immediately after calling activate()
, which worked in the past, but since the introduction of the session(activationDidCompleteWith:)
function I needed to send my messages from there.
So I think your solution is one of these:
- Make your InterfaceController be the
WCSessionDelegate
, move allWCSession
activation calls there, and send the message fromsession(activationDidCompleteWith:)
- Send the message from
session(activationDidCompleteWith:)
in theExtensionDelegate
(in my app I handle all communication in theExtensionDelegate
) - Post a notification from
session(activationDidCompleteWith:)
in theExtensionDelegate
and add an observer to handle it inInterfaceController
Aside from this, I think you may also have a problem because the declaration of session(didReceiveMessage:)
is wrong in your AppDelegate (or at least I had a problem when I tried your code.)
The new declaration is:
func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void)