什么时候在手表 WCSessionDelegate 上调用 sessionReachabilityDidChange(_:)?
When is sessionReachabilityDidChange(_:) called on a watch WCSessionDelegate?
Apple 的文档在方法的讨论部分这样说 description:
This method is called to let the
current process know that its counterpart session’s reachability
changed.
The description of the isReachable property says this: WatchKit
extension. The iOS device is within range, so communication can occur
and the WatchKit extension is running in the foreground, or is running
with a high priority in the background (for example, during a workout
session or when a complication is loading its initial timeline data).
我假设这意味着如果手表移出或移入 iOS 设备的范围,WatchKit 扩展将启动并调用 WCSessionDelegate 的 sessionReachabilityDidChange()
方法,并且如果 iOS 设备刚刚进入范围,则 WCSession 的 isReachable 为真,如果刚超出范围,则为假。
我还没有在 xcode 中找到验证这一点的方法。例如,我在 sessionReachabilityDidChange(_:)
中放置了一条日志消息并走出了范围,但是 xcode 只是说应用程序与 iphone 失去了连接并且无法再调试它。有人可以验证这一点或指出一些更好地描述这一点的文档吗?
我认为你无法在 Xcode 中验证这一点。
我在 iOS 和 watchOS 上有一个应用程序。要检查这种情况,我可以在 iOS 和 watchOS 上启用调试警报。当 func sessionReachabilityDidChange(session: WCSession)
被触发时,我会显示调试警报。
现在,如果我 运行(不在 Xcode 下)我的手表扩展,然后关闭配对的 iPhone,手表上会显示调试警报。
这表明 sessionReachabilityDidChange
实际上按预期调用了。
显然,在 Xcode 下,连接的 iOS 设备始终可以访问。
编辑:
为了检查手表扩展不在前台时的情况,我做了以下操作:
我现在没有显示调试警报,而是将并发症设置为一个唯一的值,否则这是不可能的。我启动了手表扩展程序,并通过显示带有复杂功能的表盘将其置于背景中。
当我现在关闭 iPhone 时,并发症 未 更新。
这向我表明 sessionReachabilityDidChange
是 而不是 在后台调用。
Apple 的文档在方法的讨论部分这样说 description:
This method is called to let the current process know that its counterpart session’s reachability changed.
The description of the isReachable property says this: WatchKit extension. The iOS device is within range, so communication can occur and the WatchKit extension is running in the foreground, or is running with a high priority in the background (for example, during a workout session or when a complication is loading its initial timeline data).
我假设这意味着如果手表移出或移入 iOS 设备的范围,WatchKit 扩展将启动并调用 WCSessionDelegate 的 sessionReachabilityDidChange()
方法,并且如果 iOS 设备刚刚进入范围,则 WCSession 的 isReachable 为真,如果刚超出范围,则为假。
我还没有在 xcode 中找到验证这一点的方法。例如,我在 sessionReachabilityDidChange(_:)
中放置了一条日志消息并走出了范围,但是 xcode 只是说应用程序与 iphone 失去了连接并且无法再调试它。有人可以验证这一点或指出一些更好地描述这一点的文档吗?
我认为你无法在 Xcode 中验证这一点。
我在 iOS 和 watchOS 上有一个应用程序。要检查这种情况,我可以在 iOS 和 watchOS 上启用调试警报。当 func sessionReachabilityDidChange(session: WCSession)
被触发时,我会显示调试警报。
现在,如果我 运行(不在 Xcode 下)我的手表扩展,然后关闭配对的 iPhone,手表上会显示调试警报。
这表明 sessionReachabilityDidChange
实际上按预期调用了。
显然,在 Xcode 下,连接的 iOS 设备始终可以访问。
编辑:
为了检查手表扩展不在前台时的情况,我做了以下操作:
我现在没有显示调试警报,而是将并发症设置为一个唯一的值,否则这是不可能的。我启动了手表扩展程序,并通过显示带有复杂功能的表盘将其置于背景中。
当我现在关闭 iPhone 时,并发症 未 更新。
这向我表明 sessionReachabilityDidChange
是 而不是 在后台调用。