如果用户同时打开了 Apple Watch 应用程序和 iPhone 应用程序,我希望能够更新我的 Apple Watch 视图。我知道这里有一个WatchKit 1 问题,但我想知道我是否可以使用 WatchConnectivity 来做到这一点。
在我的 iOS 应用程序中,我发送了一条消息:
if WCSession.isSupported() {
// Set the session to default session singleton
let session = WCSession.defaultSession()
// Fire the message to watch
NSLog("send message")
session.sendMessage(["action": "messageAction"], replyHandler: nil, errorHandler: { (error) -> Void in
// Display alert
NSLog(error.description)
})
}
但我不断收到错误:
Error Domain=WCErrorDomain Code=7007 "WatchConnectivity session on paired device is not reachable." UserInfo={NSLocalizedDescription=WatchConnectivity session on paired device is not reachable.}
从 iPhone 向 Apple Watch 发送消息,WatchConnectivity
sendMessage
使用方法是否正确?