init
TypeScriptstatic init(): DeviceActivityMonitorSwift declarationoverride dynamic init()class · iOS 15.0+ · SDK 27.1
@objc class DeviceActivityMonitorThe object that monitors scheduled device activity. `DeviceActivityMonitor` provides the entry point into a device activity monitor extension. You should subclass `DeviceActivityMonitor` and designate your subclass as the principal class of your app extension. The following code implements `DeviceActivityMonitor` in an app: ```swift class MyMonitorExtension: DeviceActivityMonitor { let store = ManagedSettingsStore() // You can use the `store` property to shield apps when an interval starts, ends, or meets a threshold. override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) // Shield selected applications. let model = MyModel() let applications = model.selectionToShield.applications store.shield.applications = applications.isEmpty ? nil : applications } ``` > Note: Shielding an app dims the app's icon on the homescreen and applies an hourglass symbol. When the app launches, the system covers it with a view that your app can configure.
static init(): DeviceActivityMonitorSwift declarationoverride dynamic init()intervalDidEnd(activity: DeviceActivityName): voidSwift declarationfunc intervalDidEnd(for activity: DeviceActivityName)Indicates that the device activity interval ended. An activity ends when someone first uses the device outside the activity's scheduled time interval or when your app stops monitoring an activity with an ongoing interval. In other words, the system only invokes this method when the device is in use. - Parameters: - activity: The name of the activity.
intervalDidStart(activity: DeviceActivityName): voidSwift declarationfunc intervalDidStart(for activity: DeviceActivityName)Indicates that the device activity interval started. An activity starts when someone first uses the device within the activity's scheduled time interval. In other words, the system only invokes this method when the device is in use. - Parameters: - activity: The name of the activity.
eventDidReachThreshold(event: DeviceActivityEvent_Name, activity: DeviceActivityName): voidSwift declarationfunc eventDidReachThreshold(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName)Indicates that the activity reached its threshold. The system invokes this method when use of the `activity` reaches its threshold. - Parameters: - activity: The name of the activity. - event: The name of the event.
intervalWillEndWarning(activity: DeviceActivityName): voidSwift declarationfunc intervalWillEndWarning(for activity: DeviceActivityName)Warns your app of an ongoing activity's conclusion a specified time before the activity ends. When an activity is about to end, `intervalWillEndWarning` warns your app extension of the concluding activity. - Parameters: - activity: The name of the activity.
intervalWillStartWarning(activity: DeviceActivityName): voidSwift declarationfunc intervalWillStartWarning(for activity: DeviceActivityName)Warns your app of an upcoming activity a specified time before the activity starts. When an activity is about to start, `intervalWillStartWarning` warns your app extension of the upcoming activity. - Parameters: - activity: The name of the activity.
eventWillReachThresholdWarning(event: DeviceActivityEvent_Name, activity: DeviceActivityName): voidSwift declarationfunc eventWillReachThresholdWarning(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName)Warns your app that an activity is about to reach its threshold. When an activity is about to reach its threshold, `eventWillReachThresholdWarning` warns your app extension of the concluding threshold limit. - Parameters: - activity: The name of the activity. - event: The name of the event.
No declarations were skipped in this snapshot.