我如何才能知道用户使用了我的应用程序提供的哪些复杂功能?

How can I find out which complications my app provides are been using by user?

做一个watchOS only app,它专注于并发症,我计划支持多种类型的并发症。

主应用视图将是让用户更改复杂选项的地方。 由于该应用程序计划支持许多复杂功能,如果手表屏幕上显示的选项太多,将很难使用。有什么方法可以检测现在使用了哪些复杂功能,所以我只能显示这些复杂功能的选项,而不是在手表的表面显示太多选项?

代码简单,目前只支持三种并发:

ComplicationController.swift

func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -> Void) {
    let descriptors = [
        CLKComplicationDescriptor(identifier: "complication", displayName: "DDD", supportedFamilies: [CLKComplicationFamily.modularLarge, CLKComplicationFamily.circularSmall, CLKComplicationFamily.modularSmall])
    ]

    handler(descriptors)
}

谢谢。

根据记忆,我想您会想要访问 CLKComplicationServer 以找出当前有哪些并发症 运行。特别是 activeComplications.

来自 Apple 文档:

This property contains an array of CLKComplication objects; each represents a version of your complication currently displayed on the clock face. If the property contains an empty array, it means your app has no complications on the active watch face.

activeComplications on Apple Developer site