I'm working on a sample Apple Watch application and trying to send a command from Apple Watch to iPhone. Getting the following error message.
2015-12-21 17:44:17.942 SampleWatch WatchKit Extension[157:4572] requestRecord error: Error Domain=WCErrorDomain Code=7001 "Unknown WatchConnectivity error." UserInfo={NSUnderlyingError=0x17d51350 {Error Domain=com.apple.identityservices.error Code=23 "Timed out" UserInfo={NSUnderlyingError=0x17d4a550 {Error Domain=com.apple.ids.idssenderrordomain Code=12 "(null)"}, NSLocalizedDescription=Timed out}}, NSLocalizedDescription=Unknown WatchConnectivity error.}
Code snippet to send command from Watch to iPhone:
- (void)sendCommand
{
NSLog(@" ### SendCommand :%d ###",[self.session isReachable] );
if ([self.session isReachable]) {
NSDictionary *message = @{@"Command": @"Hello"};
[self.session sendMessage:message
replyHandler:^(NSDictionary *reply) {
//handle reply from iPhone app here
NSLog(@"requestRecord reply: %@", reply);
}
errorHandler:^(NSError *error) {
//catch any errors here
NSLog(@"requestRecord error: %@", error);
}
];
}
}
Setting up the session as follows:
- (void)setupWatchSession
{
if ([WCSession isSupported]) {
self.session = [WCSession defaultSession];
self.session.delegate = self;
[self.session activateSession];
NSLog(@"@setupWatchSession: %@", self.session);
}
}
The same way, the set up is done even in the iPhone as well. One way (iPhone to Apple Watch) is able to receive the command but the other way from(Apple Watch to iPhone) is resulting in an error.