When the app is brought to the foreground from an external action (e.g., tapping on the widget, opening from a notification), a notification is posted (with a slight delay).

`MasterFeedViewController` and `SettingsViewController` are observers. `MasterFeedViewController` will dismiss any `SFSafariViewController`s that are presented, while `SettingsViewController` will dismiss itself.
This commit is contained in:
Stuart Breckenridge
2021-11-06 22:43:50 +08:00
parent 50a61d6a67
commit 0db88c5f92
4 changed files with 27 additions and 0 deletions

View File

@@ -11,6 +11,10 @@ import UserNotifications
import Account
import Zip
public extension Notification.Name {
static let DidLaunchFromExternalAction = Notification.Name("DidLaunchFromExternalAction")
}
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
@@ -105,6 +109,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let context = urlContexts.first else { return }
DispatchQueue.main.async {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
NotificationCenter.default.post(name: .DidLaunchFromExternalAction, object: nil)
}
let urlString = context.url.absoluteString
// Handle the feed: and feeds: schemes
@@ -202,6 +211,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
return
}
}
}
}