Skip to end of metadata
Go to start of metadata


Titanium SDK supports the Peek and Pop, and Quick Action features of 3D touch, which provides additional functionality and responsiveness for iOS users. Both features require a 3D Touch enabled device running iOS 9 or later. Note that you can only test 3D touch features on device.

  • Peek and Pop provides a way for the user to quickly preview item content in the application by pressing on it, then optionally switching to the peeked item.
  • Quick Action provides application shortcuts when the user presses the application icon on the Home Screen. The shortcuts allow the user to quickly perform an action with your application without navigating through the application.

3D Touch != Force Touch


 Apple also has a feature called Force Touch for the Apple Watch, MacBook and Magic Trackpad, which should not be confused with 3D touch.

Quick Actions

Press firmly on the app icon in the Home screen to reveal the Quick Actions (or Application Shortcuts). Quick actions can either be static (always present) or dynamic (generated by the application).

To use quick actions, first create static or dynamic actions, then listen for the shortcutitemclick event to determine when the user taps a quick action.


Add Static Shortcuts

To define static shortcuts, add the UIApplicationShortcutItems key to the ios/plist/dict element in the tiapp.xml file. Set the UIApplicationShortcutItems key to an array of dict items containing additional keys that define the shortcut. You must specify the UIApplicationShortcutItemType and  UIApplicationShortcutItemTitle keys :

  • UIApplicationShortcutItemTitle (required): title of the quick action. May be assigned an i18n localized string in the app.xml file.

  • UIApplicationShortcutItemType (required): unique identifier of the quick action passed to the event. Use a reverse domain notation, for example, com.foocompany.fooapp.fooshortcut.

  • UIApplicationShortcutItemSubtitle: string to display underneath the title in the quick action. May be assigned an i18n localized string in the app.xml file.
  • UIApplicationShortcutItemIconType: Set to a UIApplicationShortcutIcon enum to display an icon with the quick action.
  • UIApplicationShortcutItemIconFile: Hash of a 35 x 35 dp icon to display with the quick action. To retrieve the hash of the icon, build the project once and retrieve the hash of the corresponding image from build/iphone/Assets.xcassets.
  • UIApplicationShortcutItemUserInfo: custom dictionary that is passed to the event.



Place localized strings for the title and subtitle of the quick actions in the app.xml file as opposed to the strings.xml file.

Custom Quick Action Icons


If you specify a custom quick action icon using the UIApplicationShortcutItemIconFile, you need to enable slicing, that is, adding images to the asset catalog. To enable slicing, add the use-app-thinning element to the ios element in the tiapp.xml file and set the value to true.




Add Dynamic Shortcuts

To create or remove dynamic shortcuts, use the Ti.UI.iOS.ApplicationShortcuts API.

To create a dynamic shortcut:

  1. Use the Ti.UI.iOS.forceTouchSupported to test if the device supports 3D touch.
  2. Create an instance of an ApplicationShortcut using the Ti.UI.iOS.createApplicationShortcuts() method.
  3. Invoke the addDynamicShortcut() method on the ApplicationShortcut instance and pass method a dictionary with the following parameters:
    • itemtype (required): unique identifier of the quick action passed to the event. Use a reverse domain notation, for example, com.foocompany.fooapp.fooshortcut.
    • title (required): title of the quick action.
    • subtitle: subtitle of the quick action displayed beneath the title.
    • icon: icon to display with the quick action. May be assigned a Titanium.UI.iOS.SHORTCUT_ICON_TYPE_* constant, an image URL or a Titanium.Contacts.Person. If you use an image file, you need to enable slicing. See the note in the previous section for instructions.

To remove a dynamic shortcut, invoke the ApplicationShortcut instance's removeDynamicShortcut() method and pass it the itemtype identifier of the dynamic shortcut to remove or invoke the removeAllDynamicShortcuts() method to remove all dynamic shortcuts.


Respond to Quick Actions

When the user taps a Quick Action, the shortcutitemclick event is fired for the Ti.App.iOS static class. The payload includes all properties set for the static or dynamic shortcut except the icon. Simply use the itemtype to identify the shortcut and act accordingly.


Peek and Pop

To use Peek and Pop, press firmly on a peek-supported view. As you start applying more force, the rest of the screen will blur and reveal the preview. Maintaining the press will eventually open (pop) the detailed window. Swipe up while you peek to reveal any available quick actions.


To enable Peek and Pop:

  1. Use the Ti.UI.iOS.forceTouchSupported to test if the device supports 3D touch.
  2. Create a PreviewContext object using the Titanium.UI.iOS.createPreviewContext() method. Pass the method a dictionary with the following properties:
    • preview: view object to use as the peeked view.
    • actions: array of PreviewActions or PreviewActionGroup objects to use as the quick actions.
    • contentHeight: height of the preview window. Defaults to fill most of the screen.
  3. Add the peek and pop events to the created preview context to receive updates about the current preview state.
  4. Attach the PreviewContext object to a view. Set the view's previewContext property to the PreviewContext object.


The following example shows how to attach a PreviewContext to an ImageView in an Alloy view.  Note that the example omits the preview and pop views referenced in the controller code.



For a full example, see

Further Reading

  • No labels

1 Comment

  1. just removed some spurious tags from the bullet near the bottom "To enable peek and pop" as I think it's corrupting the text further down on the public site.