Dmitry Dmitry - 11 days ago 9
Objective-C Question

Is it possible to wake up iPhone app from watchOS 3 app?

Is it possible to wake up iPhone app from watchOS 3 app?

The first part of the code was enough on watchOS 2 but even the both parts of the code don't work on watchOS 3:

Initialization:

if ([WCSession isSupported]) {
WCSession* session = [WCSession defaultSession];
session.delegate = self;
[session activateSession];
}


On another method:

if ([WCSession isSupported]) {
WCSession* session = [WCSession defaultSession];
if (session.reachable) { // <-- RETURNS FALSE
NSDictionary *message = @{@"action":@"wakeup"};
[session sendMessage:message replyHandler:nil errorHandler:nil];
}
}

Answer

Apple suggested the following code:

- (void)session:(WCSession *)session activationDidCompleteWithState:(WCSessionActivationState)activationState error:(NSError *)error {
    if ([WCSession isSupported]) {
        WCSession* session = [WCSession defaultSession];
        if (session.activationState == WCSessionActivationStateActivated) {
            NSDictionary *message = @{@"action":@"wakeup"};
            [session sendMessage:message replyHandler:nil errorHandler:nil];
        }
    }
}