Fixes deep links not working when app is not running
This commit is contained in:
parent
e63a525671
commit
0babc81914
@ -19,6 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate
|
|||||||
var window: UIWindow?
|
var window: UIWindow?
|
||||||
|
|
||||||
private let deepLinkController = DeepLinkController()
|
private let deepLinkController = DeepLinkController()
|
||||||
|
private var appLaunchDeepLink: DeepLink?
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
|
||||||
{
|
{
|
||||||
@ -40,10 +41,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate
|
|||||||
// Controllers
|
// Controllers
|
||||||
ExternalGameControllerManager.shared.startMonitoring()
|
ExternalGameControllerManager.shared.startMonitoring()
|
||||||
|
|
||||||
|
// Notifications
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.databaseManagerDidStart(_:)), name: DatabaseManager.didStartNotification, object: DatabaseManager.shared)
|
||||||
|
|
||||||
// Deep Links
|
// Deep Links
|
||||||
if let shortcut = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem
|
if let shortcut = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem
|
||||||
{
|
{
|
||||||
self.deepLinkController.handle(.shortcut(shortcut))
|
self.appLaunchDeepLink = .shortcut(shortcut)
|
||||||
|
|
||||||
// false = we handled the deep link, so no need to call delegate method separately.
|
// false = we handled the deep link, so no need to call delegate method separately.
|
||||||
return false
|
return false
|
||||||
@ -164,3 +168,15 @@ extension AppDelegate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private extension AppDelegate
|
||||||
|
{
|
||||||
|
@objc func databaseManagerDidStart(_ notification: Notification)
|
||||||
|
{
|
||||||
|
guard let deepLink = self.appLaunchDeepLink else { return }
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.deepLinkController.handle(deepLink)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,11 @@ import Harmony
|
|||||||
import Roxas
|
import Roxas
|
||||||
import ZIPFoundation
|
import ZIPFoundation
|
||||||
|
|
||||||
|
extension DatabaseManager
|
||||||
|
{
|
||||||
|
static let didStartNotification = Notification.Name("databaseManagerDidStartNotification")
|
||||||
|
}
|
||||||
|
|
||||||
extension DatabaseManager
|
extension DatabaseManager
|
||||||
{
|
{
|
||||||
enum ImportError: Error, Hashable
|
enum ImportError: Error, Hashable
|
||||||
@ -97,6 +102,9 @@ extension DatabaseManager
|
|||||||
|
|
||||||
self.prepareDatabase {
|
self.prepareDatabase {
|
||||||
self.isStarted = true
|
self.isStarted = true
|
||||||
|
|
||||||
|
NotificationCenter.default.post(name: DatabaseManager.didStartNotification, object: self)
|
||||||
|
|
||||||
completionHandler(nil)
|
completionHandler(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,7 +105,9 @@ extension LaunchViewController
|
|||||||
|
|
||||||
UIView.transition(with: self.view, duration: 0.3, options: [.transitionCrossDissolve], animations: {
|
UIView.transition(with: self.view, duration: 0.3, options: [.transitionCrossDissolve], animations: {
|
||||||
showGameViewController()
|
showGameViewController()
|
||||||
}, completion: nil)
|
}) { (finished) in
|
||||||
|
self.gameViewController.startEmulation()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user