简体   繁体   English

在iOS 8中检测Apple Watch

[英]Detecting Apple Watch in iOS 8

I have some events that should only be fired off if a user has an Apple Watch. 我有一些仅在用户使用Apple Watch时才应触发的事件。 Is there a way to detect whether a watch is paired? 有没有一种方法可以检测手表是否配对? I'm not sure if I can use the shared app group to detect the Apple Watch extension or maybe I can use bluetooth? 我不确定是否可以使用共享应用程序组来检测Apple Watch扩展,或者是否可以使用蓝牙?

The best you an do is set a BOOL to true in shared NSUserDefaults the first time the Watch app is run and then check for that value in your iOS app. 最好的办法是在第一次运行Watch应用程序时在共享NSUserDefaults中将BOOL设置为true,然后在iOS应用程序中检查该值。 All indications on the dev forums and publicly have been that there isn't a way to programatically know if a Watch has been paired. 开发人员论坛上和公开场合的所有迹象都表明,尚无办法以编程方式知道手表是否已配对。

This is possible on watchOS2.0+ 在watchOS2.0 +上可以实现

I tried to give an answer here https://stackoverflow.com/a/44190804/2946782 我试图在这里给出答案https://stackoverflow.com/a/44190804/2946782

you can check if connectivity session is supported as described here: How to check whether iPhone and apple watch are connected 您可以按照以下说明检查是否支持连接会话: 如何检查iPhone和Apple Watch是否已连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM