Contents

UIApplication

The centralized point of control and coordination for apps running in iOS.

Declaration

@MainActor class UIApplication

Mentioned in

Overview

Every iOS app has exactly one instance of UIApplication (or, very rarely, a subclass of UIApplication). When an app launches, the system calls the UIApplicationMain(_:_:_:_:) function. Among its other tasks, this function creates a singleton UIApplication object that you access using shared.

Your app’s application object handles the initial routing of incoming user events. It dispatches action messages forwarded to it by control objects (instances of the UIControl class) to appropriate target objects. The application object maintains a list of open windows (UIWindow objects), which it can use to retrieve any of the app’s UIView objects.

The UIApplication class defines a delegate that conforms to the UIApplicationDelegate protocol and must implement some of the protocol’s methods. The application object informs the delegate of significant runtime events—for example, app launch, low-memory warnings, and app termination—giving it an opportunity to respond appropriately.

Apps can cooperatively handle a resource, such as an email or an image file, through the open(_:options:completionHandler:) method. For example, an app that calls this method with an email URL causes the Mail app to launch and display the message.

The APIs in this class allow you to manage device-specific behavior. Use your UIApplication object to do the following:

Subclassing notes

Most apps don’t need to subclass UIApplication. Instead, use an app delegate to manage interactions between the system and the app.

If your app must handle incoming events before the system does—a very rare situation—you can implement a custom event or action dispatching mechanism. To do this, subclass UIApplication and override the sendEvent(_:) and/or the sendAction(_:to:from:for:) methods. For every event you intercept, after you handle the event, dispatch it back to the system by calling:

super.sendEvent(event)

Intercepting events is only rarely required and you should avoid it if possible.

Topics

Accessing the shared application

Configuring your app’s behavior

Registering for remote notifications

Getting the application state

Getting scene information

Managing a scene’s life cycle

Managing background tasks

Fetching content in the background

Opening a URL resource

Deep linking to custom settings

Managing the app’s idle timer

Managing state restoration

Providing an app’s shortcut items

Accessing protected content

Receiving remote control events

Accessing the layout direction

Controlling and handling events

Managing the app’s icon

Managing the preferred content size

Specifying the supported interface orientations

Tracking controls in the run loop

Detecting screenshots

Discovering if your app is the default app in a category

Deprecated

Structures

See Also

Life cycle