Instance Method


Registers your preferred options for notifying the user.


func registerUserNotificationSettings(_ notificationSettings: UIUserNotificationSettings)



The types of notifications that your app wants to use. You also use this object to specify custom actions that can be initiated by the user from an alert displayed in response to a local or remote notification.


If your app displays alerts, play sounds, or badges its icon, you must call this method during your launch cycle to request permission to alert the user in these ways. (You must also make this request if you want to set the applicationIconBadgeNumber property directly.) Typically, you make this request if your app uses local or remote notifications to alert the user to new information involving your app. The first time your app launches and calls this method, the system asks the user whether your app should be allowed to deliver notifications and stores the response. Thereafter, the system uses the stored response to determine the actual types of notifications you may use.

After calling this method, the app calls the application(_:didRegister:) method of its app delegate to report the results. You can use that method to determine if your request was granted or denied by the user.

It is recommended that you call this method before you schedule any local notifications or register with the push notification service. Apps that support custom actions must include all of their supported actions in the notificationSettings object.

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.

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.