3D Touch for Home screen quick actions

Taras Markevych
ButterflyMX Engineering
2 min readNov 19, 2019

Home screen quick actions can be used by deep 3D press on the app icon using 3D Touch. Choose an action from the quick access list of your application. In our case, for example, quick actions used for give access to some unit.

Shortcut contains: title, subtitle (as optional) and icon.

Quick actions can has 2 types static and dynamic. But we have limits of 4 maximum shortcuts. Also static actions has hight priority before dynamic. If your application contains 2 static and 5 dynamic, will be displayed 2 static and 2 dynamic icons.

Dynamic shortcuts

Dynamic shortcuts sets dynamically from your received data for example we have some array of data what we need to set in shortcuts. Basically UIApplicationShortcutItem contains from: title, subtitle, icon of the action (Don’t use an emoji in place of an icon. Because emojis don’t align properly with right-aligned text and emojis are full color, where as icons must be monochromatic), type (a unique identifier for describe type of shortcut) of the action.

For create dynamic shortcuts call method below in appDelegate or elsewhere where you need set this data.

Great now we can see our shortcuts when press our application icon. Next step we need add logic for detecting our action when user press some shortcut. So our second step implement logic for handle user action.

We need to add method: application:shortcutItem:completionHandler: in AppDelegate class, will be called when user press shortcut.

As result of action completionHandler should return true or false with successfully completed or not action.

Static shortcuts

Static shortcuts contains the same properties like dynamic, but we must to set all information into info.plist

Also if you need remove all shortcuts just call shortcutItems with empty array of items:

As result we can see how in our case we call API for opening some of unit.

Thanks for reading, IOS Team ButterflyMX!

--

--