Skip to main content

AddToSiriButton

A Button that allows the user to easily add/edit/remove a voice shortcut by pressing it.

import {
AddToSiriButton,
SiriButtonStyles,
presentShortcut,
} from "react-native-siri-shortcut";

const OrderSoupSiriButton = () => {
return (
<AddToSiriButton
shortcut={orderSoupShortcut}
buttonStyle={SiriButtonStyles.automaticOutline}
onPress={() => {
presentShortcut(orderSoupShortcut, ({status}) => {
console.log(`${status} order soup shortcut`);
});
}}
/>
);
};
note

This component is only supported from iOS 12 onwards. On Android and iOS versions older than 12, it will not render.

Props

buttonStyle

One of 6 possible styles to apply to the button. Can be one of:

  • SiriButtonStyles.white

White Style

  • SiriButtonStyles.whiteOutline

White Style

  • SiriButtonStyles.black

White Style

  • SiriButtonStyles.blackOutline

White Style

iOS 13+ only

  • SiriButtonStyles.automatic
  • SiriButtonStyles.automaticOutline

Defaults to automatic.

note

The automatic and automaticOutline styles are only supported from iOS 13 onwards. On iOS 12, they default to white and whiteOutline, respectfully.

style

You can use any style you would use for a View.

shortcut

Required. The shortcut to attach to this button.

Type of ShortcutOptions.

onPress

Called whenever the user presses the button. You usually call presentShortcut here.

Type of () => void.

Type Reference

SiriButtonStyles

enum SiriButtonStyles {
white = 0,
whiteOutline = 1,
black = 2,
blackOutline = 3,
/** Only supported on iOS >= 13. On iOS 12 this defaults to `white` */
automatic = 4,
/** Only supported on iOS >= 13. On iOS 12 this defaults to `whiteOutline` */
automaticOutline = 5,
}

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;
}