ios - "devices not paired"的 WatchKit 事件?

标签 ios watchkit apple-watch

我想确保当 Watch 未与 iPhone 配对时,用户会收到正确信息的警告。我看到当我关闭蓝牙时,一些其他应用程序显示全屏红色设备图标,应用程序名称为白色,表示设备未配对,应用程序需要配对才能工作。当我使用我的应用程序做同样的事情时,没有任何反应,我仍然只在右(或左,取决于手腕......)角落的时间旁边得到一个小图标,而不是全屏图标。

我想知道是否有一种特定的方法可以向用户显示该状态,或者它是否应该是由系统处理的自动功能,但由于某些原因,它对我不起作用。

最佳答案

不知道自动功能,但使用 WatchConnectivity 框架你可以知道 paired iPhone 是否可达。如果没有,您可以显示一个 interface controller 并带有适当的消息来警告用户。 WCSession 有一个 bool 属性 reachable 其描述如下。

讨论

In your WatchKit extension, the value of this property is YES when a matching session is active on the user’s iPhone and the device is within range so that communication may occur. On iOS, the value is YES when the paired Apple Watch is in range and the associated Watch app is running in the foreground. In all other cases, the value is NO.

更多详情请查看WatchConnectivity Framwork

关于ios - "devices not paired"的 WatchKit 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34529302/

相关文章:

ios - UIViewController 上的 BOOL 属性会自行更改

ios - 使用键更新字典值

swift - 错误 : "cannot invoke initializer" for function to be executed on Watch OS only

iOS openParentApplication 没有唤醒父应用程序

ios - 将依赖 watchOS 应用程序转换为独立 watchOS 6 的影响

ios - 二进制文件无效,二进制文件缺少架构 [arm64]

iphone - 我可以拥有两个包 ID 不同但名称相同的应用程序吗?

ios - WatchKit - 如何移动标签或图像

ios - 没有通信应用程序 -> watch 应用程序和 Apple Watch 上的应用程序安装失败 - iOS 9 Beta 5

nfc - Apple Watch 是否被 RFID 读取器检测到?