One Logo Pool Ball
DeviceActivity · IOS API REFERENCE

DeviceActivityEvent

struct · iOS 15.0+ · SDK 27.1

struct DeviceActivityEvent

An event that represents an application, category, or website activity. Device activity is the amount of time an application, category, or web domain is frontmost on the screen and accumulates based on the time zone of the scheduled start date. Web domain activity includes domains visited in Safari or any third-party browser that contributes web usage via a `STWebpageController`.

Members (8)

get · iOS 15.0+

includesAllActivity

TypeScript
get includesAllActivity(): boolean
Swift declaration
var includesAllActivity: Bool { get }

A Boolean value that indicates whether the event includes all applications, categories, and web domains. Use `includesAllActivity` to determine the content of the scheduled event. Evaluates to `true` if ``applications``, ``categories``, and ``webDomains`` are empty; otherwise `false`.

get · iOS 17.4+

includesPastActivity

TypeScript
get includesPastActivity(): boolean
Swift declaration
var includesPastActivity: Bool { get }

Whether the system takes into account the person's device activity before your app starts monitoring the event. For example, if your app calls ``DeviceActivityCenter/startMonitoring(_:during:events:)`` at 1:30pm with a schedule of 1:00pm to 2:00pm, then this boolean determines whether any activity between 1:00pm and 1:30pm will contribute to its threshold. If set to `true` and the event's schedule does not start on a round hour (for example, it starts at 1:15pm instead of 1:00pm), the system will include device activity from the start of the nearest round hour (for example, it will still include usage from 1:00pm to 1:15pm).

get · iOS 15.0+

categories

TypeScript
get categories(): Array<_ManagedSettings_Token<_ManagedSettings_ActivityCategory>>
Swift declaration
var categories: Set<ActivityCategoryToken> { get }

The categories that the event includes.

get · iOS 15.0+

webDomains

TypeScript
get webDomains(): Array<_ManagedSettings_Token<_ManagedSettings_WebDomain>>
Swift declaration
var webDomains: Set<WebDomainToken> { get }

The web domains that the event includes.

init · iOS 17.4+

init

TypeScript
static initApplicationsCategoriesWebDomainsThresholdIncludesPastActivity(applications: Array<_ManagedSettings_Token<_ManagedSettings_Application>>, categories: Array<_ManagedSettings_Token<_ManagedSettings_ActivityCategory>>, webDomains: Array<_ManagedSettings_Token<_ManagedSettings_WebDomain>>, threshold: _Foundation_DateComponents, includesPastActivity: boolean): DeviceActivityEvent
Swift declaration
init(applications: Set<ApplicationToken> = [], categories: Set<ActivityCategoryToken> = [], webDomains: Set<WebDomainToken> = [], threshold: DateComponents, includesPastActivity: Bool)

Creates a new event. An application's extension receives a callback once the combination of specified ``applications``, ``categories``, and ``webDomains`` have been in use longer than the event's threshold within the activity's scheduled interval. If your app didn't specify any `applications`, `categories`, or `webDomains`, the event includes all `applications`, `categories`, and `web domains`. - Parameters: - applications: An optional list of applications to include in the event. A small subset of popular App Store apps have known associated web domains that get included implicitly. For example, an event that includes an app implicitly includes usage of the app's web domain. - categories: An optional list of categories to include in the event. - webDomains: An optional list of web domains to include in the event. Some web domains have associated apps included implicitly. - threshold: The amount of time that results in a callback to a ``DeviceActivityMonitor``. - includesPastActivity: Whether the system takes into account the person's device activity before your app starts monitoring the event. For example, if your app calls ``DeviceActivityCenter/startMonitoring(_:during:events:)`` at 1:30pm with a schedule of 1:00pm to 2:00pm, then this boolean determines whether any activity between 1:00 PM and 1:30 PM will contribute to its threshold.

init · iOS 15.0+

init

TypeScript
static initApplicationsCategoriesWebDomainsThreshold(applications: Array<_ManagedSettings_Token<_ManagedSettings_Application>>, categories: Array<_ManagedSettings_Token<_ManagedSettings_ActivityCategory>>, webDomains: Array<_ManagedSettings_Token<_ManagedSettings_WebDomain>>, threshold: _Foundation_DateComponents): DeviceActivityEvent
Swift declaration
init(applications: Set<ApplicationToken> = [], categories: Set<ActivityCategoryToken> = [], webDomains: Set<WebDomainToken> = [], threshold: DateComponents)

Creates a new event. An application's extension receives a callback once the combination of specified ``applications``, ``categories``, and ``webDomains`` have been in use longer than the event's threshold within the activity's scheduled interval. If your app didn't specify any `applications`, `categories`, or `webDomains`, the event includes all `applications`, `categories`, and `web domains`. - Important: When your app calls ``DeviceActivityCenter/startMonitoring(_:during:events:)`` and the event's schedule is active, the system will only consider the person's device activity when it starts monitoring the event. - Parameters: - applications: An optional list of applications to include in the event. A small subset of popular App Store apps have known associated web domains that get included implicitly. For example, an event that includes an app implicitly includes usage of the app's web domain. - categories: An optional list of categories to include in the event. - webDomains: An optional list of web domains to include in the event. Some web domains have associated apps included implicitly. - threshold: The amount of time that results in a callback to a ``DeviceActivityMonitor``.

get · iOS 15.0+

applications

TypeScript
get applications(): Array<_ManagedSettings_Token<_ManagedSettings_Application>>
Swift declaration
var applications: Set<ApplicationToken> { get }

The applications that the event includes.

get · iOS 15.0+

threshold

TypeScript
get threshold(): _Foundation_DateComponents
Swift declaration
var threshold: DateComponents { get }

The amount of time to monitor the provided applications, categories, and web domains. Once the activity exceeds the threshold, the system invokes the ``DeviceActivity/DeviceActivityMonitor/eventDidReachThreshold(_:activity:)`` method of the application extension's principal class.

Skipped declarations

No declarations were skipped in this snapshot.

All DeviceActivity types →