如何以编程方式区分两个不同的 Apple Watch?

How to differentiate two different Apple watch programmatically?

我打算开发 Apple Watch 应用程序。在开始编写代码之前,我几乎没有想过什么问题。

请帮忙弄清楚这些场景。

WCSession提供了属性watchDirectoryURL,你可以在其中存储特定于给定配对手表的数据,如果活动手表发生变化,这个目录也会改变。

来自 Apple 的文档:

Use this directory to store preferences, files, and other data that is relevant to the specific instance of your Watch app running on the currently paired Apple Watch. If more than one Apple Watch is paired with the same iPhone, the URL in this directory changes when the active Apple Watch changes.

您可以在此目录中存储您想要的任何信息,包括您的业务逻辑用来检测哪个手表当前处于活动状态的唯一标识符。