WCSession sendMessage:replyHandler error code 7014 (WCErrorCodeDeliveryFailed)

gsempe picture gsempe · Oct 18, 2015 · Viewed 10.5k times · Source

I have a Watch OS 2 application that communicates with the iOS app via WCSession method sendMessage:replyHandler:errorHandler:

The iOS application reply correctly but time to time I get the error with code 7014 of domain WCErrorDomain: "Payload could not be delivered"

It happens more often when the iOS application is not foreground.

I do not find any solution of this problem, I hope one of you know a solution to this problem

Answer

Peter Robert picture Peter Robert · Sep 8, 2016

For anyone having issues on iOS10 beta 6 and GM, and you are using Swift3, the solution is to change the delegate function header in the iOS app to the following:

    func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {

Note the @escaping and the Any instead of the AnyObject type.