So you are trying to send instant message to parent iPhone app and still receiving “Payload could not be delivered”? This happens only if one of those two thing occured:
1. there is no connection to watch (you should check session.reachable in WCSession)
2. your iPhone app is not responding with didReceiveMessage:replyHandler:
Second one is the most probably so how to fix it? There are 2 “didReceiveMessage” methods in WCSessionDelegate protocol, to make it work, you need to implement second one:
- (void)session:(WCSession *)session didReceiveMessage:(NSDictionary*)message replyHandler:(void(^)(NSDictionary *replyMessage))replyHandler;
so just make it look like:
- (void)session:(WCSession *)session didReceiveMessage:(NSDictionary*)message replyHandler:(void(^)(NSDictionary *replyMessage))replyHandler { NSLog(@"iPhone: didReceiveMessage %@", message); replyHandler(@{@"command": @"reply"}); }
You just need to respond with NSDictionary. And it works. Really.
I was using the block-less delegate method, which used to work. Switching to this one in my watch extension fixed my issue. I don’t see anything in the docs that would indicate this is necessary, so thank you!
Thank you so much! I’ve literally been stuck on this for around 5 hours, couldn’t thank you enough!!
Hello can you please suggest me how can i implement this in swift.