voltmx.forcetouch Namespace
The voltmx.forcetouch namespace provides the functions to add, remove, enable, disable, and access dynamic Quick Action items. It contains the following API elements.
Functions
The voltmx.forcetouch
namespace contains the following functions.
voltmx.forcetouch.disableQuickActionItems
The disableQuickActionItems
function disables pinned shortcuts that were previously enabled. If the target shortcuts are already disabled, this function does not take any action. It sets the mentioned disabled message for all Quick Action items. When you try to launch the disabled actionItem shortcut, a relevant toast message is displayed. You should use this function for dynamic shortcut Quick Action items, and you must not call the function with static quickAction IDs.
Syntax
disableQuickActionItems(Object quickActionList, String disableMessage)
Input Parameters
An object of quickAction ID and the disable message.
Example 1
Note: The above example disables all shortcut IDs (com.voltmx.first1 and com.voltmx.first.imageName) with the common disable message as “Disabled all Shortcuts”.
Example 2
Note: This example disables the shortcuts mentioned above with their respective disable messages.
Return Values
None.
Platform Availability
- Android 7.1 and later or API Level 25 or later
voltmx.forcetouch.enableQuickActionItems
The enableQuickActionItems
function enables pinned shortcuts that were previously disabled. If the target shortcuts were already enabled, this function does not take any action.
Syntax
enableQuickActionItems(Array quickActionId)
Input Parameters
An array of quickAction IDs.
Example
Return Values
None.
Platform Availability
- Android 7.1 and later or API Level 25 or later
voltmx.forcetouch.getPinnedQuickActionItems
The getPinnedQuickActionItems
function returns an ID list of all the pinned Quick Action items. This function helps you pin a shortcut of any of the functional options of an app on the home screen of a mobile device.
Syntax
Input Parameters
None.
Example
Return Values
An array of ID strings.
Platform Availability
- Android 7.1 and later or API Level 25 or later
voltmx.forcetouch.getQuickActionItems
The getQuickActionItems
function gets an array of dynamic Quick Action items that are set in the app.
Syntax
voltmx.forcetouch.getQuickActionItems()
Example
Input Parameters
None.
Return Values
A string array of dynamic Quick Action items containing only IDs, if any are set in the app. Otherwise, this function returns an empty array.
Remarks
The returned array does not contain icon key-value pairs.
Platform Availability
- iOS 9.0 and later
- Android 7.1 and later or API Level 25 or later
voltmx.forcetouch.getStaticQuickActionItems
The getQuickActionItems
function returns an array of immutable or static Quick Action items that are set in the app.
Syntax
voltmx.forcetouch.getStaticQuickActionItems()
Example
Input Parameters
None.
Return Values
An array of ID strings.
Platform Availability
- iOS 9.0 and later
- Android 7.1 and later or API Level 25 or later
voltmx.forcetouch.removeQuickActionItems
The removeQuickActionItems
function removes all the dynamic Quick Action items that are set in the app.
Syntax
Example
Input Parameters
None.
Return Values
None.
Platform Availability
- iOS 9.0 and later
- Android 7.1 and later or API Level 25 or later
voltmx.forcetouch.removeQuickActionItems
The removeQuickActionItems
function removes the array of specified dynamic Quick Action items.
Syntax
voltmx.forcetouch.removeQuickActionItems(
Array ID);
Input Parameters
Parameter | Description |
---|---|
ID | An array of quickNotification IDs. |
Example
Return Values
None.
Platform Availability
- iOS 9.0 and later
- Android 7.1 and later or API Level 25 or later
voltmx.forcetouch.setQuickActionItems
The setQuickActionItems
function sets dynamic Quick Action items in the app.
Syntax
voltmx.forcetouch.setQuickActionItems(quickActionItems)
Input Parameters
quickActionItems - Mandatory.
An array of key-value pairs that contains the following values.
Key Description id A string containing an app-defined id the home screen quick action. For example, com.appName.formName. title A string that holds a user-visible title of the home screen quick action. This value can be localized. subtitle A user-visible string that holds the subtitle of the home screen quick action. This value can be localized. icon An optional value that selects the icon for the action. For system icons, this value can be set to one of the Force Touch System Icon Constants. For iOS, if your app uses a custom icon that is included in the app’s bundle, set this value to a string containing the filename of the icon. Also for iOS, if your app uses a contact’s picture as its quick action icon, set this value to a ReferenceTable object for the contact that your app obtains by calling the voltmx.contact.find function. For Android, you can set the value of icon as either an image bundled with the app or as a Volt MX image Object. info A dictionary with developer-provided key-value pairs that contain app-defined information about the home screen quick action. This information is used by the app to implement the action.
Example 1
You can create quick actions with system-defined icons, a custom image in your app’s bundle, or with a picture from a contact in the device. To select a custom image as a Quick Action’s icon, your app must specify the icon’s file name as value for the icon key in the quickActionItems of the setQuickActionItems function.
The following example shows how to system-defined icon as the icon for the Quick Action.
Example 2
The following example shows how to specify a custom image as the icon for the Quick Action and how to use the image from a contact as the icon for a Quick Action.
Example 3
Note: For this example, you may get an alert on Iris to write the code in dot notation. Please ignore that alert and execute the provided code as is.
Return Values
A Boolean value that is true
if at least one dynamic Quick Action item was set in the app; otherwise the value is false
.
Platform Availability
- iOS 9.0 and later
- Android 7.1 and later or API Level 25 or later