且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取 Apple Watch 硬件标识符?

更新时间:2023-12-05 17:07:10

没有 WatchKit 方法来获取硬件标识符.为了区分 38 毫米和 42 毫米手表,开发论坛中的一位 Apple 员工建议使用 WKInterfaceDevice 上的 screenBounds 属性.像这样:

There is no WatchKit method to obtain the hardware identifier. To distinguish between the 38mm and 42mm Watches, an Apple employee in the dev forums recommended using the screenBounds property on WKInterfaceDevice. Something like this:

if ([WKInterfaceDevice currentDevice].screenBounds.size.width == 136.0f) {
    // 38mm
}
else {
    // 42mm
}