如何决定在iOS 13上为userNotificationCenter:OpenSettings for:打开哪个窗口的通知设置?
iOS具有以下被调用的方法,因此您可以通过通知中心或设置应用程序向用户提供自定义通知设置:如何决定在iOS 13上为userNotificationCenter:OpenSettings for:打开哪个窗口的通知设置?,ios,ios13,uiwindow,unusernotificationcenter,uiscene,Ios,Ios13,Uiwindow,Unusernotificationcenter,Uiscene,iOS具有以下被调用的方法,因此您可以通过通知中心或设置应用程序向用户提供自定义通知设置: func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) { // Open up a Settings view controller within your app or something } 在其中,您将打开一
func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {
// Open up a Settings view controller within your app or something
}
在其中,您将打开一些应用程序内设置视图控制器
在iOS 12上,这很容易,找到活动窗口,找到rootViewController,然后将设置屏幕放在上面
在iOS 13上,你可以有多个窗口,所以我假设这个方法可以在任何一个窗口上被调用
假设你在后台打开了5个应用程序窗口,然后打开设置应用程序并请求应用程序的通知设置。它使用哪个窗口?我如何知道要将设置屏幕添加到哪个窗口/视图控制器?我不想随机选择一个,然后意外地将它添加到背景中的一个,而不是打开的那个
另一方面,UNNotificationResponse
确实有一个targetScene
方法,因此如果您的应用程序是通过通知打开的,您可以知道要使用哪个窗口,但这个方法似乎缺少它
我是否应该遍历应用程序可用的所有窗口场景,并在前景中找到一个