handleSharedComplicationDescriptors(_:)
Informs the app about complications from a shared watch face.
Declaration
optional func handleSharedComplicationDescriptors(_ complicationDescriptors: [CLKComplicationDescriptor])Parameters
- complicationDescriptors:
The descriptors for your app’s complications from a shared watch face.
Mentioned in
Discussion
ClockKit calls this method when the Apple Watch receives a shared watch face that contains one or more of your app’s complications. Implement this method to prepare your app so that it can provide complication data for the descriptors.
For example, a weather app may provide separate complications for all of the user’s favorite cities. However, when the user receives a shared watch face from someone else, the shared watch face may include a complication for a city that isn’t in the user’s favorite city list. The weather app needs to provide data for the new city, and may need to add the city to the user’s favorite list.
func handleSharedComplicationDescriptors(_ complicationDescriptors: [CLKComplicationDescriptor]) {
// If the descriptor has a city ID, add it to the favorite city list,
// so the app will download weather updates for the city.
for descriptor in complicationDescriptors {
guard let cityID = descriptor.userInfo?[myCityIDKey] as? String else { continue }
myData.addFavoriteCity(byID: cityID)
}
}See Also
Deprecated methods
CLKLaunchedTimelineEntryDateKeyCLKLaunchedComplicationIdentifierKeygetComplicationDescriptors(handler:)getLocalizableSampleTemplate(for:withHandler:)getPrivacyBehavior(for:withHandler:)CLKComplicationPrivacyBehaviorgetAlwaysOnTemplate(for:withHandler:)getTimelineEndDate(for:withHandler:)getCurrentTimelineEntry(for:withHandler:)getTimelineEntries(for:after:limit:withHandler:)getTimelineAnimationBehavior(for:withHandler:)CLKComplicationTimelineAnimationBehaviorgetSupportedTimeTravelDirections(for:withHandler:)CLKComplicationTimeTravelDirectionsgetTimelineStartDate(for:withHandler:)