Linking 3D Touch Static Shortcuts To Tabbed/Navigation View Controllers In Swift 4

In this example, I have a Swift 4 app with a single Tab Bar Controller and three Navigation Controllers each segued to a View Controller. There are plenty of guides online to help you set up the necessary strings in your Info.plist to enable static 3D touch shortcuts. In my case, I have three shortcuts – each is linked to a different view controller.

Place the following function into your AppDelegate.swift file.

func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void)
        guard let tabBarController = window?.rootViewController as? UITabBarController else 
        switch shortcutItem.type 
        case "UIApplicationShortcutItemType-0":
            tabBarController.selectedIndex = 0
        case "UIApplicationShortcutItemType-1":
            tabBarController.selectedIndex = 1
        case "UIApplicationShortcutItemType-2":
            tabBarController.selectedIndex = 2

The bold code should match the UIApplicationShortcutItemType you placed in Info.plist for each shortcut. 🙂

Previous article
Next article

Related Articles


Please enter your comment!
Please enter your name here

Try EchoTools - my free, iOS ultrasonography reference application!

Latest Articles