Fixes Patreon deep link not working on app launch

This commit is contained in:
Riley Testut
2020-01-13 13:53:04 -08:00
parent c6a0437577
commit c49b357868

View File

@@ -13,6 +13,8 @@ class LaunchViewController: RSTLaunchViewController
{ {
private var didFinishLaunching = false private var didFinishLaunching = false
private var destinationViewController: UIViewController!
override var launchConditions: [RSTLaunchCondition] { override var launchConditions: [RSTLaunchCondition] {
let isDatabaseStarted = RSTLaunchCondition(condition: { DatabaseManager.shared.isStarted }) { (completionHandler) in let isDatabaseStarted = RSTLaunchCondition(condition: { DatabaseManager.shared.isStarted }) { (completionHandler) in
DatabaseManager.shared.start(completionHandler: completionHandler) DatabaseManager.shared.start(completionHandler: completionHandler)
@@ -28,6 +30,14 @@ class LaunchViewController: RSTLaunchViewController
override var childForStatusBarHidden: UIViewController? { override var childForStatusBarHidden: UIViewController? {
return self.children.first return self.children.first
} }
override func viewDidLoad()
{
super.viewDidLoad()
// Create destinationViewController now so view controllers can register for receiving Notifications.
self.destinationViewController = self.storyboard!.instantiateViewController(withIdentifier: "tabBarController") as! TabBarController
}
} }
extension LaunchViewController extension LaunchViewController
@@ -61,15 +71,14 @@ extension LaunchViewController
// Add view controller as child (rather than presenting modally) // Add view controller as child (rather than presenting modally)
// so tint adjustment + card presentations works correctly. // so tint adjustment + card presentations works correctly.
let viewController = self.storyboard!.instantiateViewController(withIdentifier: "tabBarController") as! TabBarController self.destinationViewController.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height)
viewController.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height) self.destinationViewController.view.alpha = 0.0
viewController.view.alpha = 0.0 self.addChild(self.destinationViewController)
self.addChild(viewController) self.view.addSubview(self.destinationViewController.view, pinningEdgesWith: .zero)
self.view.addSubview(viewController.view, pinningEdgesWith: .zero) self.destinationViewController.didMove(toParent: self)
viewController.didMove(toParent: self)
UIView.animate(withDuration: 0.2) { UIView.animate(withDuration: 0.2) {
viewController.view.alpha = 1.0 self.destinationViewController.view.alpha = 1.0
} }
self.didFinishLaunching = true self.didFinishLaunching = true