gpt4 book ai didi

ios - 什么是 UserNotification 框架相当于 didReceive 通知 : UILocalNotification?

转载 作者:行者123 更新时间:2023-11-28 12:28:59 24 4
gpt4 key购买 nike

我已经知道这段代码可以在 iOS 10 之前使用:

func application(_ application: UIApplication, didReceive notification: UILocalNotification) {

}

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

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

最佳答案

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

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

Called when a notification is delivered to a foreground app.

Documentation.

关于ios - 什么是 UserNotification 框架相当于 didReceive 通知 : UILocalNotification?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42618726/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com