Instance Method


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


func setKeepAliveTimeout(_ timeout: TimeInterval, handler keepAliveHandler: (() -> Void)? = nil) -> Bool



The maximum interval (measured in seconds) at which your app should be woken up to check its VoIP connection. The minimum acceptable timeout value is 600 seconds.


A block that performs the tasks needed to maintain your VoIP network connection. Setting this parameter to nil releases the current handler block and prevents UIKit from scheduling the next wake.

Return Value

true if the handler was installed or false if it was not.


In iOS 8 and later, voice-over-IP (VoIP) apps register for registerForRemoteNotifications() remote notifications instead of using this method. Using remote notifications eliminates the need for a timeout handler to check in with the VoIP service. Instead, when a calls arrives for the user, the VoIP service sends a VoIP remote notification to the user’s device. Upon receiving this notification, the device launches or wakes the app as needed so that it can handle the incoming call.

In iOS 7 and earlier, VoIP apps use this method to install a handler whose job is to maintain the app’s network connection with a VoIP server. This handler is guaranteed to be called before the specified timeout value but may be called at a slightly different time interval in order to better align execution of your handler with other system tasks, and thereby save power. Your handler has a maximum of 10 seconds to perform any needed tasks and exit. If it does not exit before time expires, the app is suspended.

Timeout values and handlers are not persisted between app launches. Therefore, if your app is terminated for any reason, you must reinstall the handler during the next launch cycle.

For calls to this method to succeed, the app must have the voip value in the array associated with the UIBackgroundModes key in its Info.plist file. Calling this method replaces the previously installed handler and timeout values, if any.

See Also

Deprecated Symbols

func setMinimumBackgroundFetchInterval(TimeInterval)

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

var statusBarOrientationAnimationDuration: TimeInterval

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

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 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 statusBarOrientationUserInfoKey: String

A key whose value is an NSNumber object that encapsulates a UIInterfaceOrientation value indicating the current orientation (see UIInterfaceOrientation). This key is used with didChangeStatusBarOrientationNotification and willChangeStatusBarOrientationNotification notifications.

class let statusBarFrameUserInfoKey: String

A key whose value is an NSValue object that encapsulates a CGRect structure expressing the location and size of the new status bar frame. This key is used with didChangeStatusBarFrameNotification and willChangeStatusBarFrameNotification notifications.

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.

let UIMinimumKeepAliveTimeout: TimeInterval

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

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