I have an array of 10 events, suppose current time is 10 am and the event will start at 11am. Each event is of 30 mins and gap between two events is of 30 mins.
Now, I am able to show that all the required info on Watch Face correctly, i.e, when watch face is launched, then it says, next event is at 11AM, and when first event is finished at 11:30 AM, at 11:31 AM watch face shows next event will start at 12PM.
I am able to do this all successfully.
I am facing issue when I want to show the reminder of first event just 15 mins before its starting time.
Eg, If first event of day will start at 11 AM, then watch face will show the reminder of that first event only at 10:45 AM not before 10:45AM.
Also, How can I remove Complication when last event of the day is over?
I have gone through the video of Complications WWDC - 2015.
I am trying to show Complication on CLKComplicationTemplateModularLargeStandardBody.
private func getTimeLineEntry() -> Date {
if shouldShowCountDown {
return startDate.addingTimeInterval(-15 * 60)
} else {
return startDate
}
}
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
// Call the handler with the current timeline entry
let headerTextProvider = CLKSimpleTextProvider(text: "Complication Updates")
let body1 = "My Title"
let body1TextProvider = CLKSimpleTextProvider(text: body1)
let body2TextProvider = CLKSimpleTextProvider(text: "My Subtitle")
let template = CLKComplicationTemplateModularLargeStandardBody(headerTextProvider: headerTextProvider, body1TextProvider: body1TextProvider, body2TextProvider: body2TextProvider)
let entry = CLKComplicationTimelineEntry(date: getTimeLineEntry(), complicationTemplate: template)
handler(entry)
}
Here, startDate is 11 AM and I want to show the reminder on Complication 15 mins before the event i.e, 10:45 AM. I have used a bool variable to decide whether current time is startDate > Current Date. If yes, then show the Countdown 15 mins before.