UNUserNotificationCenter

public extension UNUserNotificationCenter
  • Schedules a local notification with the current user notification center.

    This creates a notification request with the content and trigger values and schedules it for local delivery through the add(_:, withCompletionHandler:) method of UNUserNotificationCenter.

    Declaration

    Swift

    static func scheduleLocalNotification(content: UNMutableNotificationContent,
                                          trigger: UNNotificationTrigger?,
                                          completion: ((Error?) -> Void)? = nil)

    Parameters

    content

    The content of the notification.

    trigger

    The condition that causes the notification to be delivered. Specify nil to deliver the notification right away.

    completion

    The closure to execute with the results. It has no return value and takes the an error as a parameter.

    error

    The error object indicating whether a problem occurred. If the notification was scheduled successfully, this parameter is nil; otherwise, it is set to an error object indicating the reason for the failure.