AppExtensionPoint.Monitor
A type you use to discover the app extensions available for your host app to use.
Declaration
final class MonitorMentioned in
Overview
A host app uses this type to discover the app extensions that are ready for it to use. This type provides both a static list of current extensions and a way for you to monitor changes in app extension availability. You can use items from this list to instantiate an AppExtensionProcess type when you’re ready to run the app extension’s code.
Create a Monitor in your code and configure it with the extension points you want to track. When you add an extension point to the monitor, the type adds the associated app extensions to its identities property. The property contains only the app extensions that are available for your app to use, and doesn’t include disabled or unapproved app extensions. The following example shows how to use the currently available app extensions for one of the app’s defined extension points.
let someExtensionPoint = AppExtensionPoint.myExampleExtensionPoint
// Get a snapshot of available extensions.
let identitiesSnapshot = try await AppExtensionPoint.Monitor(someExtensionPoint).identitiesThe system manages the list of installed app extensions and updates that list when someone installs or removes an app. The device owner must also approve any newly installed extensions before apps can use them. While your app runs, you can observe the identities property and respond to these changes asynchronously. The following code creates a task to wait on changes to the list of identities:
let monitor = AppExtensionPoint.Monitor(appExtensionPoint:someExtensionPoint)
let identitiesUpdates = Observations { monitor.identities }
Task {
for await update in identitiesUpdates {
// Handle update.
}
}To present a UI with the list of enabled and disabled app extensions, use the EXAppExtensionBrowserViewController type.