/ swift

3D touch Quick Actions in iOS Swift Language

In iPhone, A user can now press Home screen icon to immediately access 3D touch Quick Actions functionality provided by your app. By Pressing hard on the home screen icon can now launch a quick action menu to take the user directly to parts of the app.

Users with devices that support 3D Touch will use this feature. You can add this feature quickly.

Home Screen Quick Actions

Quick actions can be static or dynamic. You can define static actions at build time and dynamic actions at runtime. Static actions are visible to the user when they install or update the app but dynamic actions the user will only see them once they have run the app at least once. We can add four static actions for the home screen.
Each quick action can have a title and optional subtitle and icon.

Example of Static Quick Actions

Adding the Shortcut Items

We can add static home screen quick actions using the UIApplicationShortcutItems array in the app Info.plist file. Each object of a dictionary array containing items properties of the UIApplicationShortcutItem class:

List of Properties

  • UIApplicationShortcutItemType
    To identify the quick action.

  • UIApplicationShortcutItemTitle
    A required string that is visible to the user.

  • UIApplicationShortcutItemSubtitle
    An optional string displayed below the title.

  • UIApplicationShortcutItemIconType
    Optional string for a system icon to display with the quick action.

  • UIApplicationShortcutItemIconFile
    Optional string for an icon image in app bundle.

  • UIApplicationShortcutItemUserInfo
    Optional dictionary with array to pass additional infromation.

enter image description here

Handling the Shortcut

When a user selects quick action the systems launches or resumes the app and calls the performActionForShortcutItem method in your app delegate:

func application(application: UIApplication,
     performActionForShortcutItem shortcutItem: UIApplicationShortcutItem,
     completionHandler: (Bool) -> Void) {


private func handleShortcut(shortcutItem: UIApplicationShortcutItem) -> Bool {        
    let shortcutType = shortcutItem.type
    guard let shortcutIdentifier = ShortcutIdentifier(fullIdentifier: shortcutType) else {
        return false
    return selectItemForIdentifier(shortcutIdentifier)

This function gets the item type first then after get Identifier. The guard protects from failure and exits if it does not recognise the shortcut and it will skip the detail but when we have valid it will move to a particular screen.


enter image description here