Summary: [DOCS] Closes https://github.com/facebook/react-native/pull/16874 Differential Revision: D6375515 Pulled By: hramos fbshipit-source-id: 64359b45a37c7b478919121573ca04dbb1ce6609
2.6 KiB
id, title, layout, category, permalink, next, previous
| id | title | layout | category | permalink | next | previous |
|---|---|---|---|---|---|---|
| actionsheetios | ActionSheetIOS | docs | APIs | docs/actionsheetios.html | alert | accessibilityinfo |
Display action sheets and share sheets on iOS.
Methods
Reference
Methods
showActionSheetWithOptions()
ActionSheetIOS.showActionSheetWithOptions(options, callback)
Display an iOS action sheet.
| Name | Type | Required | Description |
|---|---|---|---|
| options | object | Yes | See below. |
| callback | function | Yes | Provides index for the selected item. |
The options object must contain one or more of:
options(array of strings) - a list of button titles (required)cancelButtonIndex(int) - index of cancel button inoptionsdestructiveButtonIndex(int) - index of destructive button inoptionstitle(string) - a title to show above the action sheetmessage(string) - a message to show below the title
The 'callback' function takes one parameter, the zero-based index of the selected item.
Minimal example:
ActionSheetIOS.showActionSheetWithOptions({
options: ['Remove', 'Cancel'],
destructiveButtonIndex: 1,
cancelButtonIndex: 0,
},
(buttonIndex) => {
if (buttonIndex === 1) { // destructive action }
});
showShareActionSheetWithOptions()
ActionSheetIOS.showShareActionSheetWithOptions(options, failureCallback, successCallback)
Display the iOS share sheet.
| Name | Type | Required | Description |
|---|---|---|---|
| options | object | Yes | See below. |
| failureCallback | function | Yes | See below. |
| successCallback | function | Yes | See below. |
The options object should contain one or both of message and url and can additionally have a subject or excludedActivityTypes:
url(string) - a URL to sharemessage(string) - a message to sharesubject(string) - a subject for the messageexcludedActivityTypes(array) - the activities to exclude from the ActionSheet
NOTE: If
urlpoints to a local file, or is a base64-encoded uri, the file it points to will be loaded and shared directly. In this way, you can share images, videos, PDF files, etc.
The 'failureCallback' function takes one parameter, an error object. The only property defined on this object is an optional stack property of type string.
The 'successCallback' function takes two parameters:
- a boolean value signifying success or failure
- a string that, in the case of success, indicates the method of sharing