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

Time:04-03

Making a watchOS only app, it focuses on complications, I plan to support many styles of complications.

The main app view will be the place that let user change options for complications. Since the app plan to support many complications, it'll be hard to use if there are too many options shows on the watch's screen. Is there any way I can detect which complications been using now, so I can only show options for those complications instead of showing too many options on the watch's face?

The code is simple, for now it supports only three kinds of complication:

ComplicationController.swift

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

    handler(descriptors)
}

Thanks.

CodePudding user response:

I think from memory you will want to access the CLKComplicationServer to find out which complications are currently running. Specifically the activeComplications.

From the Apple Documentation:

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.

enter link description here

  • Related