One Logo Pool Ball
DeviceActivity · IOS API REFERENCE

DeviceActivityMonitor

class · iOS 15.0+ · SDK 27.1

@objc class DeviceActivityMonitor

The 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.

Members (7)

init · iOS 15.0+

init

TypeScript
static init(): DeviceActivityMonitor
Swift declaration
override dynamic init()
method · iOS 15.0+

intervalDidEnd

TypeScript
intervalDidEnd(activity: DeviceActivityName): void
Swift declaration
func 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.

method · iOS 15.0+

intervalDidStart

TypeScript
intervalDidStart(activity: DeviceActivityName): void
Swift declaration
func 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.

method · iOS 15.0+

eventDidReachThreshold

TypeScript
eventDidReachThreshold(event: DeviceActivityEvent_Name, activity: DeviceActivityName): void
Swift declaration
func 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.

method · iOS 15.0+

intervalWillEndWarning

TypeScript
intervalWillEndWarning(activity: DeviceActivityName): void
Swift declaration
func 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.

method · iOS 15.0+

intervalWillStartWarning

TypeScript
intervalWillStartWarning(activity: DeviceActivityName): void
Swift declaration
func 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.

method · iOS 15.0+

eventWillReachThresholdWarning

TypeScript
eventWillReachThresholdWarning(event: DeviceActivityEvent_Name, activity: DeviceActivityName): void
Swift declaration
func 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.

Skipped declarations

No declarations were skipped in this snapshot.

All DeviceActivity types →