I get the following error when sending an Apple Watch message to the device
Domain error = code WCErrorDomain = 7012 "The response message took too long." UserInfo = {NSLocalizedDescription = The response message took too long. NSLocalizedFailureReason = response timeout.}
#import <WatchConnectivity/WatchConnectivity.h> located on both sides and the main target applications and corresponds to the delegation methods on both the watch and the device
SEND MESSAGE FROM CLOCK TO DEVICE
- Session Confirmed As Available
Session Confirmed Reachable
NSDictionary *applicationDict = [[NSDictionary alloc] initWithObjects:@[@"SomethingHere"] forKeys:@[@"valueKey"]];
if([[WCSession defaultSession] isReachable]) {
NSLog(@"Reachable");
[[WCSession defaultSession] sendMessage:applicationDict
replyHandler:^(NSDictionary *reply) {
NSLog(@"%@",reply);
}
errorHandler:^(NSError *error) {
NSLog(@"%@",error);
}];
}
DEVICE
In appdelegate didFinishLaunching
if ([WCSession isSupported]) {
WCSession *session = [WCSession defaultSession];
session.delegate = self;
[session activateSession];
NSLog(@"\n\n - WatchKit Session Started - \n\n");
}
else{
NSLog(@"WatchKit Session Error");
}
Session Confirms As Starting As Expected
Receive a message on the device
- (void)session:(nonnull WCSession *)session didReceiveMessage:(nonnull NSDictionary<NSString *,id> *)message replyHandler:(nonnull void (^)(NSDictionary<NSString *,id> * __nonnull))replyHandler {
NSLog(@"Data delagte");
dispatch_async(dispatch_get_main_queue(), ^{
resultFromWatch = [message objectForKey:@"resultDataValue"];
});
}
Update:
- (void) session:(nonnull WCSession *)session didReceiveApplicationContext:(nonnull NSDictionary<NSString *,id> *)message {
dispatch_async(dispatch_get_main_queue(), ^{
});
}
, ccjensen