什么是 UserNotification 框架等同于 didReceive 通知:UILocalNotification?

What's UserNotification framework's equivalent of didReceive notification: UILocalNotification?

我在iOS 10:

之前就已经知道这个代码可以用了
func application(_ application: UIApplication, didReceive notification: UILocalNotification) {

}

但是,它已经贬值了,所以我想问一下有没有什么方法可以与 UserNotifications 框架等效,或者我只需要通过这个警告就可以了?

请注意,我希望应用程序在应用程序处于后台或终止时执行某些操作。

当应用程序在前台收到通知时,已弃用的方法是通知委托。现在 UNUserNotificationCenterDelegate 做同样的事情:

func userNotificationCenter(
    UNUserNotificationCenter, 
    willPresent: UNNotification, 
    withCompletionHandler: @escaping (UNNotificationPresentationOptions) -> Void
)

Called when a notification is delivered to a foreground app.

Documentation.