Instance Method

application(_:didRegister:)

Called to tell the delegate the types of local and remote notifications that can be used to get the user’s attention.

Declaration

optional func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings)

Parameters

application

The app object that registered the user notification settings.

notificationSettings

The user’s specified notification settings for your app. The settings in this object may be different than the ones you originally requested.

Discussion

Apps that use local or remote notifications to alert the user to new information must register the types of notifications they want to use by calling the registerUserNotificationSettings(_:) method of the app object. The system compares your app’s request with the user’s preferences to determine the types of local and remote notifications allowed, and returns the results to your app by calling this method. Check the contents of the notificationSettings parameter whenever this method is called.

Because the user can change notification settings in the Settings app at any time, call the currentUserNotificationSettings method before your app performs work to prepare a notification for presentation.

The first time you register your app’s preferred notification types, the system asks the user whether your app should be allowed to deliver notifications and stores the user’s response. The system does not prompt the user on subsequent calls to the registerUserNotificationSettings(_:) method, but the user can always change notification preferences using Settings.

A user’s notification settings control only whether the system displays local or remote notifications onscreen. Regardless of the notification settings, local and remote notifications are delivered to your app at the appropriate times.

See Also

Deprecated Symbols

func application(UIApplication, didReceive: UILocalNotification)

Sent to the delegate when a running app receives a local notification.

Deprecated
func application(UIApplication, didReceiveRemoteNotification: [AnyHashable : Any])

Called when your app has received a remote notification.

Deprecated
func application(UIApplication, handleActionWithIdentifier: String?, for: UILocalNotification, completionHandler: () -> Void)

Called when your app has been activated because user selected a custom action from the alert panel of a local notification.

Deprecated
func application(UIApplication, handleActionWithIdentifier: String?, forRemoteNotification: [AnyHashable : Any], completionHandler: () -> Void)

Tells the app delegate to perform the custom action specified by a remote notification.

Deprecated
func application(UIApplication, handleOpen: URL)

Asks the delegate to open a resource identified by URL.

Deprecated
func application(UIApplication, open: URL, sourceApplication: String?, annotation: Any)

Asks the delegate to open a resource identified by a URL.

Deprecated