Created
January 12, 2017 08:00
-
-
Save SylarRuby/49070aef94dfe4fb31515e15b026d711 to your computer and use it in GitHub Desktop.
Redirects user to loginVC if not currently logged in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* If any issues, be sure to import Firebase or FirebaseAuth and check your Podfile | |
* | |
*/ | |
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { | |
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) | |
let root = UIApplication.shared.keyWindow?.rootViewController | |
let lc: LoginVC = storyboard.instantiateViewController(withIdentifier: "loginVC") as! LoginVC | |
// If the user is not logged in, redirect to loginViewController (loginVC) | |
if (FIRAuth.auth()?.currentUser) != nil { | |
// Do stuff if shortcutItem.type == "your shortcut" | |
} else { | |
// Passing the shortcutItem to the loginVC's variable | |
lc.params = "\(shortcutItem.type)" | |
root?.present(lc, animated: false, completion: { () -> Void in | |
completionHandler(true) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment