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


class UIApplication : UIResponder


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.

Managing the App's Behavior

var delegate: UIApplicationDelegate?

The delegate of the app object.

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.

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.

Getting the Application State

var applicationState: UIApplication.State

The runtime state of the app.

enum UIApplication.State

The running states of an app

Managing Background Execution

var backgroundRefreshStatus: UIBackgroundRefreshStatus

Indicates whether the app can refresh content when running in the background.

enum UIBackgroundRefreshStatus

Constants indicating whether background execution is enabled for the app.

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

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

func endBackgroundTask(UIBackgroundTaskIdentifier)

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

struct UIBackgroundTaskIdentifier

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

var backgroundTimeRemaining: TimeInterval

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

Fetching Content in the Background

func setMinimumBackgroundFetchInterval(TimeInterval)

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

class let backgroundFetchIntervalMinimum: TimeInterval

The smallest fetch interval supported by the system.

class let backgroundFetchIntervalNever: TimeInterval

A fetch interval large enough to prevent fetch operations from occurring.

let UIMinimumKeepAliveTimeout: TimeInterval

The minimum amount of time (measured in seconds) an app may run a critical background task in the background.

Opening a URL Resource

func canOpenURL(URL) -> Bool

Returns a Boolean value indicating whether an app is available to handle a URL scheme.

class let openSettingsURLString: String

Used to create a URL that you can pass to the openURL(_:) method. When you open the URL built from this string, the system launches the Settings app and displays the app’s custom settings, if it has any.

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.

enum UIUserInterfaceLayoutDirection

Specifies the directional flow of the user interface.

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?) -> Bool

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.

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 App Windows

var keyWindow: UIWindow?

The app's key window.

var windows: [UIWindow]

The app's visible and hidden windows.

Getting the Font Sizing Preference

var preferredContentSizeCategory: UIContentSizeCategory

The font sizing option preferred by the user.

struct UIContentSizeCategory

Constants indicating the preferred size of your content.

Managing the Default Interface Orientations

func supportedInterfaceOrientations(for: UIWindow?) -> UIInterfaceOrientationMask

Returns the default set of interface orientations to use for the view controllers in the specified window.

Managing Status Bar Animations

var statusBarOrientationAnimationDuration: TimeInterval

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


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.

UserInfo Dictionary Keys

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

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.


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

class let backgroundRefreshStatusDidChangeNotification: NSNotification.Name

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

class let didChangeStatusBarFrameNotification: NSNotification.Name

Posted when the frame of the status bar changes.

class let didChangeStatusBarOrientationNotification: NSNotification.Name

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

class let didEnterBackgroundNotification: NSNotification.Name

Posted when the app enters the background.

class let didFinishLaunchingNotification: NSNotification.Name

Posted immediately after the app finishes launching.

class let didReceiveMemoryWarningNotification: NSNotification.Name

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

class let protectedDataDidBecomeAvailableNotification: NSNotification.Name

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

class let protectedDataWillBecomeUnavailableNotification: NSNotification.Name

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

class let significantTimeChangeNotification: 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.

class let userDidTakeScreenshotNotification: NSNotification.Name

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

class let willChangeStatusBarOrientationNotification: NSNotification.Name

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

class let willChangeStatusBarFrameNotification: NSNotification.Name

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

class let willEnterForegroundNotification: NSNotification.Name

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

class let willResignActiveNotification: NSNotification.Name

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

class let willTerminateNotification: NSNotification.Name

Posted when the app is about to terminate.

static let didChangeNotification: NSNotification.Name

Posted when the user changes the preferred content size setting.

Deprecated Symbols

func registerUserNotificationSettings(UIUserNotificationSettings)

Registers your preferred options for notifying the user.

var currentUserNotificationSettings: UIUserNotificationSettings?

Returns the user notification settings for the app.

struct UIRemoteNotificationType

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

func openURL(URL) -> Bool

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)?) -> Bool

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() -> UIRemoteNotificationType

Returns the types of notifications the app accepts.


See Also


Managing Your App's Life Cycle

Understand how the app delegate manages your app's high-level behavior.

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.

Allowing Apps and Websites to Link to Your Content

Use universal links to link to content within your app and share data securely.

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

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