是否可以从watchOS 3应用程序中唤醒iPhone应用程序?
代码的第一部分在watchOS 2上已经足够了,但即使代码的两个部分也无法在watchOS 3上运行:
初始化:
if ([WCSession isSupported]) {
WCSession* session = [WCSession defaultSession];
session.delegate = self;
[session activateSession];
}
另一种方法:
if ([WCSession isSupported]) {
WCSession* session = [WCSession defaultSession];
if (session.reachable) { // <-- RETURNS FALSE
NSDictionary *message = @{@"action":@"wakeup"};
[session sendMessage:message replyHandler:nil errorHandler:nil];
}
}
答案 0 :(得分:1)
- (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];
}
}
}