activities
TypeScriptget activities(): Array<DeviceActivityName>Swift declarationvar activities: [DeviceActivityName] { get }The activities that the application's extension currently monitors.
struct · iOS 15.0+ · SDK 27.1
struct DeviceActivityCenterA class that enables an application's extension to start monitoring scheduled device activity. Activity begins when someone first uses a device within the scheduled time interval and ends when someone first uses the device outside of the interval. The system only invokes the ``DeviceActivity/DeviceActivityMonitor/intervalDidStart(for:)`` and ``DeviceActivity/DeviceActivityMonitor/intervalDidEnd(for:)`` when the device is in use. Likewise, the system invokes the ``DeviceActivity/DeviceActivityMonitor/eventDidReachThreshold(_:activity:)`` function when an event reaches its threshold.
get activities(): Array<DeviceActivityName>Swift declarationvar activities: [DeviceActivityName] { get }The activities that the application's extension currently monitors.
stopMonitoring(activities?: Array<DeviceActivityName>): voidSwift declarationfunc stopMonitoring(_ activities: [DeviceActivityName] = [])Stops monitoring the specified device activities. This method ignores names that don't correspond to monitored activities. - Parameters: - activities: The names of the activities. If the array is empty or no `activities` are explicitly specified, this method stops monitoring all activities.
startMonitoring(activity: DeviceActivityName, schedule: DeviceActivitySchedule, events?: NativeMap<DeviceActivityEvent_Name, DeviceActivityEvent>): voidSwift declarationfunc startMonitoring(_ activity: DeviceActivityName, during schedule: DeviceActivitySchedule, events: [DeviceActivityEvent.Name : DeviceActivityEvent] = [:]) throwsStarts monitoring the specified device activity. - Parameters: - activity: The name of the activity. - schedule: The schedule on which your app extension's ``DeviceActivityMonitor`` receives callbacks. - events: An optional mapping of events keyed by their names. If this parameter is empty, the application extension only receives callbacks for the start and end times of the schedule's interval. If the device's time zone changes in the middle of a schedule's interval, any ongoing events include device activity that may have accumulated outside of the new time zone. In other words, the system uses the time zone of the device at `nextInterval.start` to calculate device activity for the entirety of the interval. If the app already monitored the activity, this method overwrites the previous schedule and events. Attempting to monitor too many activities or activities that are too tightly scheduled can cause this method to throw an error. The system throws an error if the attempt to monitor the device activity failed. To avoid errors, reduce the number of unique, tightly-scheduled activities. For example, consider using the `warningTime` property of an activity's schedule. - Important: The application extension's ``DeviceActivityMonitor`` may begin receiving callbacks as soon as the system calls this method if the activity's scheduled interval is ongoing.
events(activity: DeviceActivityName): NativeMap<DeviceActivityEvent_Name, DeviceActivityEvent>Swift declarationfunc events(for activity: DeviceActivityName) -> [DeviceActivityEvent.Name : DeviceActivityEvent]Fetches the events of a device activity. The returned object is a static representation of the events at the time the function was called. In other words, an `Event` fetched for a particular activity doesn't dynamically update in response to future changes made to that activity. - Parameters: - activity: The name of the activity. - Returns: The events of the activity. The dictionary is empty if your app doesn't monitor the activity.
schedule(activity: DeviceActivityName): (DeviceActivitySchedule) | nullSwift declarationfunc schedule(for activity: DeviceActivityName) -> DeviceActivitySchedule?Fetches the schedule of a device activity. The returned object is a static representation of the schedule at the time the function was called. In other words, a `Schedule` fetched for a particular activity doesn't dynamically update in response to future changes made to that activity. - Parameters: - activity: The name of the activity. - Returns: The schedule of the activity or `nil` if no such activity is currently monitored.
static init(): DeviceActivityCenterSwift declarationinit()Creates an activity center to manage which device activities your application monitors. All instances are equivalent and manage the activities monitored by the application's extension.
No declarations were skipped in this snapshot.