如何解决.isComplicationEnabled 在模拟器中工作吗?
我正在尝试更新模拟器中的手表并发症。但是 session.isComplicationEnabled
始终返回 false,尽管在活动表盘上启用了复杂功能。
func sendDataToWatch() {
if WCSession.isSupported() {
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let jsonData = try encoder.encode(self.data)
if let jsonString = String(data: jsonData,encoding: .utf8) {
print(jsonString)
// send to watch
let session = WCSession.default
if session.isWatchAppInstalled {
do {
let dictionary = ["dataForWatch": jsonString]
// update complications
let isReachable = session.isReachable
if !isReachable {
if session.isComplicationEnabled {
session.transferCurrentComplicationUserInfo(dictionary)
}
}
} catch {
print("ERROR: \(error)")
}
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。