Want to offer native, in-app customer service to your users? Get going quickly with Zendesk’s Mobile SDKs. Free with Zendesk.


#79: Static Shortcut Items πŸ“Œ


Shortcut Items were introduced with the announcement of 3D Touch on iPhone 6S and iPhone 6S Plus. They allow users to quickly jump to a particular section or feature of an app, straight from the home screen.

Shortcut Items come in two forms: Static, and Dynamic. Static shortcut items live in the Info.plist of our project. Dynamic shortcut items are defined in code, and configured at run time. Let's take a look at how to implement static shortcut items.

The first step is to configure the shortcut items in our Info.plist file:

Then, we need to implement one new function on our app delegate. We're using JLRoutes here (covered in Bite #62) to run some code when a given URL is passed in.

Then we'll call the provided completionHandler, with a Bool indicating whether we were able to handle the item.

func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: Bool -> Void) {
  let url = NSURL(string: shortcutItem.userInfo["url"])!

  let didHandle = JLRoutes.routeURL(url)


Note: At publish time of this Bite, Xcode did not offer a way to test shortcut items in the Simulator. To test shortcut items' functionality, this project by Conrad Kramer was used.

UPDATE: We covered Dynamic Shortcut Items in Bite #88. Head there to read about how to modify an app's shortcut items in code, at runtime.