是否有可用的课程告诉我手表是否与设备配对?
我正在寻找一个简单的是/否检查,它会告诉我手表是否与设备配对。
答案 0 :(得分:4)
You can use the WatchConnectivity (WC) framework to check the connections between iPhone and the paired Apple Watch, including pairing status.
Import WatchConnectivity in your code and then use the following code:
Swift:
if (WCSession.defaultSession().paired){
// Paired
} else{
// Not Paired
}
Objective-C:
if([WCSession defaultSession].paired){
// Paired
} else{
// Not Paired
}
Use the suitable code for each condition in Obj-C or Swift.
NOTE: WatchConnectivity framework is only available in watchOS 2. You can't get status of the paired Apple Watch in watchOS 1 (the old WatchKit). Make sure ur session is activated. This will return true only after session activated