Don't perform notification open action if modal window is open

This commit is contained in:
relikd
2020-07-27 19:23:16 +02:00
parent e398ac8bcd
commit b774e2152c

View File

@@ -102,6 +102,10 @@ extension TBCMain: UNUserNotificationCenterDelegate {
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
defer { completionHandler() }
if isFrontmostModal() {
return // dont intervene user actions
}
switch response.notification.request.identifier {
case PushNotification.Identifier.YouShallRecordMoreReminder.rawValue:
selectedIndex = 1 // open recordings tab
@@ -111,11 +115,24 @@ extension TBCMain: UNUserNotificationCenterDelegate {
case let x: // domain notification
(openTab(0) as! TVCDomains).pushOpen(domain: x) // open requests tab
}
completionHandler()
}
@available(iOS 12.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {
(openTab(2) as! TVCSettings).openNotificationSettings()
}
func isFrontmostModal() -> Bool {
var x = selectedViewController!
while let tmp = x.presentedViewController {
x = tmp
}
if x is UIAlertController {
return true
} else if #available(iOS 13.0, *) {
return x.isModalInPresentation
} else {
return x.modalPresentationStyle == .custom
}
}
}