Home screen quick actions are a convenient way to perform useful, app-specific actions right from the Home screen, using 3D Touch. Apply a little pressure to an app icon with your finger—more than you use for tap and hold—to see a list of available quick actions. Tap one to activate it. Quick actions can be static or dynamic.
We have added some 3D home screen quick action to our SUSI iOS app. In this post, we will see how they are implemented and how they work.
The following 3D home screen quick actions are added to SUSI iOS:
- Open SUSI Skills – user can directly go to SUSI skills without opening a chat screen.
- Customize Settings – user can customize their setting directly by using this quick action.
- Setup A Device – when the user quickly wants to configure his/her device for SUSI Smart Speaker, this is quick action is very helpful in that.
- Change SUSI’s Voice – user can change SUSI message reading language accents directly from this quick action.
Each Home screen quick action includes a title, an icon on the left or right (depending on your app’s position on the home screen), and an optional subtitle. The title and subtitle are always left-aligned in left-to-right languages.
Step 1 – Adding the Shortcut Items
We add static home screen quick actions using the UIApplicationShortcutItems array in the app Info.plist file. Each entry in the array is a dictionary containing items matching properties of the UIApplicationShortcutItem class. As seen in screenshot below, we have 4 shortcut items and each item have three properties UIApplicationShortcutItemIconType/UIApplicationShortcutItemIconFile, UIApplicationShortcutItemTitle, and UIApplicationShortcutItemType.
- UIApplicationShortcutItemIconType and UIApplicationShortcutItemIconFile is the string for setting icon for quick action. For the system icons, we use UIApplicationShortcutItemIconType property and for the custom icons, we use UIApplicationShortcutItemIconFile.
- UIApplicationShortcutItemTitle is a required string that is displayed to the user.
- UIApplicationShortcutItemType is a required app specific string used to identify the quick action.
Step 2 – Handling the Shortcut
AppDelegate is the place where we handle all the home screen quick actions. We define these variables:
When a user chooses one of the quick actions the launch of the system or resumes the app and calls the
performActionForShortcutItem method in app delegate:
Whenever the application becomes active, applicationDidBecomeActive function is called:
Inside the applicationDidBecomeActive function we call the handleHomeAction() method which handles the home screen quick action.