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


Every iOS app has exactly one instance of UIApplication (or, very rarely, a subclass of UIApplication). When an app is launched, the system calls the UIApplicationMain(_:_:_:_:) function; among its other tasks, this function creates a Singleton UIApplication object. Thereafter you access the object by calling the shared class method.

A major role of your app’s application object is to handle 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) and through those can 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 openURL(_:) 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 do not 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, dispatch it back to the system by calling [super sendEvent:event] after you handle the event. Intercepting events is only rarely required and you should avoid it if possible.


Getting the App Instance

class var shared: UIApplication

Returns the singleton app instance.

Getting the App Delegate

var delegate: UIApplicationDelegate?

The delegate of the app object.

Getting App Windows

var keyWindow: UIWindow?

The app's key window.

var windows: [UIWindow]

The app's visible and hidden windows.

Controlling and Handling Events

func sendEvent(UIEvent)

Dispatches an event to the appropriate responder objects in the app.

func sendAction(Selector, to: Any?, from: Any?, for: UIEvent?)

Sends an action message identified by selector to a specified target.

func beginIgnoringInteractionEvents()

Tells the receiver to suspend the handling of touch-related events.

func endIgnoringInteractionEvents()

Tells the receiver to resume the handling of touch-related events.

var isIgnoringInteractionEvents: Bool

A Boolean value that indicates whether the receiver is ignoring events initiated by touches on the screen.

var applicationSupportsShakeToEdit: Bool

A Boolean value that determines whether shaking the device displays the undo-redo user interface.

Opening a URL Resource

func open(URL, options: [String : Any] = [:], completionHandler: ((Bool) -> Void)? = nil)

Attempts to open the resource at the specified URL asynchronously.

func canOpenURL(URL)

Returns a Boolean value indicating whether or not the URL’s scheme can be handled by some app installed on the device.

Configuring the User Notification Settings

func registerUserNotificationSettings(UIUserNotificationSettings)

Registers your preferred options for notifying the user.

var currentUserNotificationSettings: UIUserNotificationSettings?

Returns the user notification settings for the app.


Registering for Remote Notifications

func registerForRemoteNotifications()

Register to receive remote notifications via Apple Push Notification service.

func unregisterForRemoteNotifications()

Unregister for all remote notifications received via Apple Push Notification service.

var isRegisteredForRemoteNotifications: Bool

A Boolean indicating whether the app is currently registered for remote notifications.

Managing Background Execution

var applicationState: UIApplicationState

The runtime state of the app.

var backgroundTimeRemaining: TimeInterval

The amount of time the app has to run in the background.

var backgroundRefreshStatus: UIBackgroundRefreshStatus

The ability of the app to be launched into the background so that it can perform background behaviors.

func setMinimumBackgroundFetchInterval(TimeInterval)

Specifies the minimum amount of time that must elapse between background fetch operations.

func beginBackgroundTask(withName: String?, expirationHandler: (() -> Void)? = nil)

Marks the beginning of a new long-running background task with the specified name.

func beginBackgroundTask(expirationHandler: (() -> Void)? = nil)

Marks the beginning of a new long-running background task.

func endBackgroundTask(UIBackgroundTaskIdentifier)

Marks the end of a specific long-running background task.

Managing the App Idle Timer

var isIdleTimerDisabled: Bool

A Boolean value that controls whether the idle timer is disabled for the app.

Managing the State Restoration Behavior

func extendStateRestoration()

Tells the app that your code is restoring state asynchronously.

func completeStateRestoration()

Tells the app that your code has finished any asynchronous state restoration.

func ignoreSnapshotOnNextApplicationLaunch()

Prevents the app from using the recent snapshot image during the next launch cycle.

class func registerObject(forStateRestoration: UIStateRestoring, restorationIdentifier: String)

Registers a custom object for use with the state restoration system.

Managing Home Screen Quick Actions for 3D Touch

var shortcutItems: [UIApplicationShortcutItem]?

The Home screen dynamic quick actions for your app; available on devices that support 3D Touch.

Determining the Availability of Protected Content

var isProtectedDataAvailable: Bool

A Boolean value indicating whether content protection is active.

Registering for Remote Control Events

func beginReceivingRemoteControlEvents()

Tells the app to begin receiving remote-control events.

func endReceivingRemoteControlEvents()

Tells the app to stop receiving remote-control events.

Controlling App Appearance

var statusBarFrame: CGRect

The frame rectangle defining the area of the status bar.

var isNetworkActivityIndicatorVisible: Bool

A Boolean value that turns an indicator of network activity on or off.

var userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection

Returns the layout direction of the user interface.

Managing the App's Icon

var applicationIconBadgeNumber: Int

The number currently set as the badge of the app icon in Springboard.

var supportsAlternateIcons: Bool

A Boolean value indicating whether the app is allowed to change its icon.

var alternateIconName: String?

The name of the icon being displayed for the app.

Getting the Font Sizing Preference

var preferredContentSizeCategory: UIContentSizeCategory

The font sizing option preferred by the user.

Managing the Default Interface Orientations

Managing Status Bar Orientation

var statusBarOrientationAnimationDuration: TimeInterval

The animation duration in seconds for the status bar during a 90 degree orientation change.

Deprecated Methods

func openURL(URL)

Attempts to open the resource at the specified URL.

func scheduleLocalNotification(UILocalNotification)

Schedules a local notification for delivery at its encapsulated date and time.

func presentLocalNotificationNow(UILocalNotification)

Presents a local notification immediately.

func cancelLocalNotification(UILocalNotification)

Cancels the delivery of the specified scheduled local notification.

func cancelAllLocalNotifications()

Cancels the delivery of all scheduled local notifications.

var scheduledLocalNotifications: [UILocalNotification]?

All currently scheduled local notifications.

func setNewsstandIconImage(UIImage?)

Sets the icon of a Newsstand app to an image depicting the current issue of a publication.

func setKeepAliveTimeout(TimeInterval, handler: (() -> Void)? = nil)

Configures a periodic handler for VoIP apps in older versions of iOS.

func clearKeepAliveTimeout()

Removes a previously installed periodic handler block.

func setStatusBarHidden(Bool, with: UIStatusBarAnimation)

Hides or shows the status bar, optionally animating the transition.

var isStatusBarHidden: Bool

A Boolean value that determines whether the status bar is hidden.

func setStatusBarStyle(UIStatusBarStyle, animated: Bool)

Sets the style of the status bar, optionally animating the transition to the new style.

var statusBarStyle: UIStatusBarStyle

The current style of the status bar.

func setStatusBarOrientation(UIInterfaceOrientation, animated: Bool)

Sets the app's status bar to the specified orientation, optionally animating the transition.

var statusBarOrientation: UIInterfaceOrientation

The current orientation of the app's status bar.

func registerForRemoteNotifications(matching: UIRemoteNotificationType)

Register to receive remote notifications of the specified types via Apple Push Notification service.

func enabledRemoteNotificationTypes()

Returns the types of notifications the app accepts.



enum UIApplicationState

The running states of an app

typealias UIBackgroundTaskIdentifier

A unique token that identifies a request to run in the background.

Background Task Constants

Constants used when running in the background.

enum UIBackgroundFetchResult

Constants that indicate the result of a background fetch operation.

Fetch Intervals

Constants indicating fetch intervals for background downloads.

enum UIBackgroundRefreshStatus

Constants indicating whether background execution is enabled for the app.

struct UIRemoteNotificationType

Constants indicating the types of notifications the app may display to the user.

enum UIInterfaceOrientation

The orientation of the app's user interface.

struct UIInterfaceOrientationMask

These constants are mask bits for specifying a view controller’s supported interface orientations.

enum UIUserInterfaceLayoutDirection

Specifies the directional flow of the user interface.

enum UIStatusBarStyle

The style of the device’s status bar.

enum UIStatusBarAnimation

The animation applied to the status bar as it is hidden or made visible.

Settings Launch URL

Constant used to open the app’s settings.

UserInfo Dictionary Keys

Keys used to access values in the userInfo dictionary of some UIApplication-posted notifications.

Content Size Category Constants

Constants that indicate the user’s preferred font size.

Accessibility Content Size Category Constants

Constants that indicate the preferred font sizes when accessibility is enabled.

Key for Content Size Change Notifications

Key identifying the new content size category.

Extension Point Identifier Constants

Constants that identify extension points you want to disallow in your app.

Run Loop Mode for Tracking

Mode while tracking in controls is taking place.


The following constant defines an exception that can be thrown by the app.

struct UIContentSizeCategory

Constants indicating the preferred size of your content.


All UIApplication notifications are posted by the app instance returned by shared.

static let UIApplicationBackgroundRefreshStatusDidChange: NSNotification.Name

Posted when the app’s status for downloading content in the background changes.

static let UIApplicationDidChangeStatusBarFrame: NSNotification.Name

Posted when the frame of the status bar changes.

static let UIApplicationDidChangeStatusBarOrientation: NSNotification.Name

Posted when the orientation of the app’s user interface changes.

static let UIApplicationDidEnterBackground: NSNotification.Name

Posted when the app enters the background.

static let UIApplicationDidFinishLaunching: NSNotification.Name

Posted immediately after the app finishes launching.

static let UIApplicationDidReceiveMemoryWarning: NSNotification.Name

Posted when the app receives a warning from the operating system about low memory availability.

static let UIApplicationProtectedDataDidBecomeAvailable: NSNotification.Name

Posted when the protected files become available for your code to access.

static let UIApplicationProtectedDataWillBecomeUnavailable: NSNotification.Name

Posted shortly before protected files are locked down and become inaccessible.

static let UIApplicationSignificantTimeChange: NSNotification.Name

Posted when there is a significant change in time, for example, change to a new day (midnight), carrier time update, and change to or from daylight savings time.

static let UIApplicationUserDidTakeScreenshot: NSNotification.Name

Posted when the user presses the Home and Lock buttons to take a screenshot.

static let UIApplicationWillChangeStatusBarOrientation: NSNotification.Name

Posted when the app is about to change the orientation of its interface.

static let UIApplicationWillChangeStatusBarFrame: NSNotification.Name

Posted when the app is about to change the frame of the status bar.

static let UIApplicationWillEnterForeground: NSNotification.Name

Posted shortly before an app leaves the background state on its way to becoming the active app.

static let UIApplicationWillResignActive: NSNotification.Name

Posted when the app is no longer active and loses focus.

static let UIApplicationWillTerminate: NSNotification.Name

Posted when the app is about to terminate.

static let UIContentSizeCategoryDidChange: NSNotification.Name

Posted when the user changes the preferred content size setting.

See Also


Ensuring the Privacy of User Data

Protect user privacy by securing personal data and respecting the user's wishes with how data is used.

protocol UIApplicationDelegate

A set of methods that are called by the singleton UIApplication object in response to important events in the lifetime of your app.

func UIApplicationMain(Int32, UnsafeMutablePointer<UnsafeMutablePointer<Int8>>!, String?, String?)

Creates the application object and the application delegate and sets up the event cycle.