Apple Watch:检查配对状态?

时间:2015-06-24 20:58:15

标签: ios apple-watch

是否有可用的课程告诉我手表是否与设备配对?

我正在寻找一个简单的是/否检查,它会告诉我手表是否与设备配对。

1 个答案:

答案 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

相关问题