Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AppDelegate methods for Home screen quick actions
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
self.handleShortCutItem(shortcutItem)
}
func handleShortCutItem(shortcutItem: UIApplicationShortcutItem) {
guard let rootViewCntrlr = self.window?.rootViewController else {
return
}
if rootViewCntrlr.presentedViewController != nil {
let viewCntrlr = rootViewCntrlr.presentedViewController
viewCntrlr?.dismissViewControllerAnimated(false, completion: nil)
}
let storyboard = UIStoryboard(name: "Main", bundle: nil)
guard let presentNavigation = storyboard.instantiateViewControllerWithIdentifier("PRESENT_NAVIGATION_SCREEN") as? UINavigationController else {
return
}
guard let viewCntrlr = presentNavigation.topViewController as? PresentedViewController else {
return
}
viewCntrlr.shortCutItem = shortcutItem
rootViewCntrlr.presentViewController(presentNavigation, animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.