I would like to create a complication for watchOS 3 that will simply launch my App. I have used XCode to create the ComplicationController:
class Complicatio
Apple Watch 4 new graphic complications looks like this:
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
// Call the handler with the current timeline entry
switch complication.family {
case .graphicCorner:
if #available(watchOSApplicationExtension 5.0, *) {
let template = CLKComplicationTemplateGraphicCornerCircularImage()
let image = UIImage(named: "Complication/Graphic Corner")!
template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
handler(timelineEntry)
} else {
handler(nil)
}
case .graphicCircular:
if #available(watchOSApplicationExtension 5.0, *) {
let template = CLKComplicationTemplateGraphicCircularImage()
let image = UIImage(named: "Complication/Graphic Circular")!
template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
handler(timelineEntry)
} else {
handler(nil)
}
default:
handler(nil)
}
}
func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
// This method will be called once per supported complication, and the results will be cached
switch complication.family {
case .graphicCorner:
if #available(watchOSApplicationExtension 5.0, *) {
let template = CLKComplicationTemplateGraphicCornerCircularImage()
let image = UIImage(named: "Complication/Graphic Corner")!
template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
handler(template)
} else {
handler(nil)
}
case .graphicCircular:
if #available(watchOSApplicationExtension 5.0, *) {
let template = CLKComplicationTemplateGraphicCircularImage()
let image = UIImage(named: "Complication/Graphic Circular")!
template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
handler(template)
} else {
handler(nil)
}
default:
handler(nil)
}
}