在Xcode 7.0(7A218)模拟器中的WCSession sendMessage

我使用从iWatch(模拟器)到iOS的sendMessage唤醒iOS应用程序:

NSDictionary *userInfo = [[NSDictionary alloc]initWithObjectsAndKeys:@"userInfo", @"key", nil]; if ([[WCSession defaultSession] isReachable]){ //iPhone is reachable NSLog(@"iPhone is reachable"); [[WCSession defaultSession] sendMessage:userInfo replyHandler:^(NSDictionary<NSString *,id> * _Nonnull replyMessage) { NSLog(@"ReplyHandler run"); } errorHandler:^(NSError * _Nonnull error) { NSLog(@"iWatch sendMessage Error: %@", error); } 

但是,我发现sendMessage只有在iOS应用程序对应的是在后台或前台。 如果iOS应用程序没有运行,则sendMessage不能唤醒iOS应用程序。 如果App没有在后台/前台运行,那么replyHandler和errorHandler都不会被调用。

这与文档不一致:从WatchKit扩展中调用这个方法,当它处于活动状态并且正在运行时,会在后台唤醒相应的iOS应用程序并使其可用。 从iOS应用程序调用此方法不会唤醒相应的WatchKit扩展。

我在Xcode Beta 5上进行了testing,即使iOS应用程序没有运行,也能运行相同的代码。

任何人在最新的模拟器和Xcode遇到类似的问题? 有什么想法吗?

谢谢