Skip to main content

Donating Shortcuts

Donate shortcut for an activity each time the user does it. For example, each time the user orders soup you may want to donate an activity that is relevant to ordering soup. Siri will use this information to then potentially recommend this activity to the user in their spotlight etc.

note

These recommendations are based on factors such as time and location.

warning

Do not donate an activity if the user hasn't done it.

API Definition

donateShortcut

Donate a shortcut for an activity that the user just did.

donateShortcut(options: ShortcutOptions): void;

Type Reference

ShortcutOptions

{
/** The activity type with which the user activity object was created. */
activityType: string;
/** An optional, user-visible title for this activity, such as a document name or web page title. */
title?: string;
/** A set of keys that represent the minimal information about the activity that should be stored for later restoration. */
requiredUserInfoKeys?: Array<string>;
/** A dictionary containing app-specific state information needed to continue an activity on another device. */
userInfo?: { [key: string]: any };
/** Indicates that the state of the activity needs to be updated. */
needsSave?: boolean;
/** A set of localized keywords that can help users find the activity in search results. */
keywords?: Array<string>;
/** A value used to identify the user activity. */
persistentIdentifier?: string;
/** A Boolean value that indicates whether the activity can be continued on another device using Handoff. */
isEligibleForHandoff?: boolean;
/** A Boolean value that indicates whether the activity should be added to the on-device index. */
isEligibleForSearch?: boolean;
/** A Boolean value that indicates whether the activity can be publicly accessed by all iOS users. */
isEligibleForPublicIndexing?: boolean;
/** The date after which the activity is no longer eligible for Handoff or indexing. In ms since Unix Epox */
expirationDate?: number;
/** Webpage to load in a browser to continue the activity. */
webpageURL?: string;
/** A Boolean value that determines whether Siri can suggest the user activity as a shortcut to the user. */
isEligibleForPrediction?: boolean;
/** A phrase suggested to the user when they create a shortcut. */
suggestedInvocationPhrase?: string;
/** Content type of this shorcut. Check available options at https://developer.apple.com/documentation/mobilecoreservices/uttype/uti_abstract_types */
contentType?: string;
/** An optional description for the shortcut. */
description?: string;
}