Contents

getNotificationSettings(completionHandler:)

Retrieves the authorization and feature-related settings for your app.

Declaration

func getNotificationSettings(completionHandler: @escaping  @Sendable (UNNotificationSettings) -> Void)
func notificationSettings() async -> UNNotificationSettings

Parameters

  • completionHandler:

    The block to execute asynchronously with the results. Your app may execute this block on a background thread. The block has no return value and takes the following parameter:

    settings

    The Unnotificationsettings object containing the current authorization settings for your app.

Mentioned in

Discussion

Use this method to determine the user interactions and notification-related features that the system authorizes your app to use. You might then use this information to enable or disable specific notification-related features of your app.

let center = UNUserNotificationCenter.current()
let settings = await center.notificationSettings()
// Add code here to inspect or act on the settings.

When the user initially grants authorization to your app, the system gives your app a set of default notification-related settings. The user may change those settings at any time to enable or disable specific capabilities. For example, the user might disable the playing of sounds when a notification arrives.

See Also

Managing the notification center