我正在开发示例手表套件应用程序(Apple Watch + iPhone)。在这里,我的应用程序同步正常。我还使用数据传输(iPhone 到 Apple Watch)在 WCSession 上工作。当两者都处于活动状态时,它工作正常。但是如果 Applewatch 处于非活动状态(后台状态、睡眠模式或前台状态),我无法将数据传输到它。委托方法未调用。
- (void)applicationDidBecomeActive {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
if ([WCSession isSupported]) {
WCSession *session = [WCSession defaultSession];
session.delegate = self;
[session activateSession];
}
}
这是我的委托方法。
- (void)session:(nonnull WCSession *)session didReceiveMessage:(nonnull NSDictionary<NSString *,id> *)message replyHandler:(nonnull void (^)(NSDictionary<NSString *,id> * __nonnull))replyHandler {}
请帮我。