Reputation: 581
I'm using a WCSession object to send data from a watch app (watchOS 3.3 beta 4) back to the corresponding iOS app via sendMessage(_:replyHandler:errorHandler:)
. According to the documentation from Apple:
Calling this method from your WatchKit extension while it is active and running wakes up the corresponding iOS app in the background and makes it reachable.
However, I find that if the isReachable
property of the WCSession
object is false
before calling sendMessage
, the message fails to send with this error:
Error Domain=WCErrorDomain Code=7007 "WatchConnectivity session on paired device is not reachable." UserInfo={NSLocalizedDescription=WatchConnectivity session on paired device is not reachable.}
The session is activated, so I believe this sendMessage
call is supposed to make the iOS app reachable and then be sent, but this is not happening.
Under what circumstances does this happen, and are there any workarounds?
Upvotes: 0
Views: 1631
Reputation: 1469
a) If you are using sendMessage(_, replyHandler:_, errorHandler:_)
with non-nil reply handler, ios counterpart's WCSessionDelegate should have session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void)
method implemented, and message will be referred to as delivered once you'll call replyHandler(_:)
inside this method. If this method is not implemented, message will not get response and you'll get timeout error.
b) Also, I've noticed that messages not be delivered while code in any of session(_ session: WCSession, didXXX: XXX)
methods of WCSessionDelegate is executing. Looks like all of them are being executed in one serial background queue.
Upvotes: -1