Contents

registerUserNotificationSettings(_:)

Registers your preferred options for notifying the user.

Declaration

func registerUserNotificationSettings(_ notificationSettings: UIUserNotificationSettings)

Parameters

  • notificationSettings:

    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.

Discussion

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

Related Documentation

Deprecated methods