ERROR: "Message response took too long" sending message to device OS 2 clock kit

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"); //<---- Console shows reachable
    
        [[WCSession defaultSession] sendMessage:applicationDict
                                    replyHandler:^(NSDictionary *reply) {
    
                                       NSLog(@"%@",reply);
    
                                   }
    
                                   errorHandler:^(NSError *error) {
    
                                       NSLog(@"%@",error); //<--- returns error
    
                                   }];
    
       }
    

DEVICE

In appdelegate didFinishLaunching

    // Watch kit session
    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

+4
2

:

1/, WCSessionDelegate . ( , / )
, , (_: didReceiveMessage: replyHandler:).
2/, replyHandler WCSessionDelegate, : " ". WCSessionDelegate
3/ , , iPhone, .

, , WCSessionDelegate , , , ( , ).

, .

: , , . , iPhone , , ( ), . , -.

+5

, WCSession delegate , .

0

All Articles