iOS Watch ComplicationController not showing result

290 views Asked by At

I have followed the Apple Developer guide on setting up my ComplicationController. I have set modularLarge enabled, and made sure its also enabled in info.plist.

I have set my data source in Complication Settings to "$(PRODUCT_MODULE_NAME).ComplicationController" which cross checks with info.plist.

I can select the Complication on the watch but it doesn't load any of the Test labels. It just says:

My App Name

"- - - - - - - -"

"- - - - - - - -"

import Foundation
import WatchKit
import ClockKit

class ComplicationController: NSObject, CLKComplicationDataSource {

func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) {
    handler([])
}

func getCurrentTimelineEntry(for complication: CLKComplication,
                         withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {

    handler(nil)

}

func getPrivacyBehaviorForComplication(complication: CLKComplication, withHandler handler: (CLKComplicationPrivacyBehavior) -> Void) {
    handler(.showOnLockScreen)
}

func getPlaceholderTemplateForComplication(complication: CLKComplication, withHandler handler: (CLKComplicationTemplate?) -> Void) {
    switch complication.family {
    case .modularLarge:
        let template = CLKComplicationTemplateModularLargeStandardBody()
        
        template.headerTextProvider = CLKSimpleTextProvider(text: "Test1", shortText: "T1")
        template.body1TextProvider = CLKSimpleTextProvider(text: "Test2", shortText: nil)
        template.body2TextProvider = CLKSimpleTextProvider(text: "Test2", shortText: nil)
        
        handler(template)
    default:
        handler(nil)
    }
}

}

screenshot of info plist screenshot of complications configuration

1

There are 1 answers

0
John Pollard On BEST ANSWER

You are returning "Test1" etc. in getPlaceholderTemplateForComplication - which as the documentation at https://developer.apple.com/documentation/clockkit/clkcomplicationdatasource/1628026-getplaceholdertemplateforcomplic?language=objc says

Gets a static template to display in the selection screen for your complication.

You need to use getCurrentTimelineEntry(...) to return the actual data shown on the complication.