as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

Share

Example

Copied to clipboard.


import React from 'react';
import {Alert, Share, Button} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

const ShareExample = () => {
  const onShare = async () => {
    try {
      const result = await Share.share({
        message:
          'React Native | A framework for building native apps using React',
      });
      if (result.action === Share.sharedAction) {
        if (result.activityType) {
          // shared with activity type of result.activityType
        } else {
          // shared
        }
      } else if (result.action === Share.dismissedAction) {
        // dismissed
      }
    } catch (error) {
      Alert.alert(error.message);
    }
  };
  return (
    <SafeAreaProvider>
      <SafeAreaView>
        <Button onPress={onShare} title="Share" />
      </SafeAreaView>
    </SafeAreaProvider>
  );
};

export default ShareExample;

Reference

Methods

share() Android iOS

static share(content: ShareContent, options?: ShareOptions);

Open a dialog to share text content.

In iOS, returns a Promise which will be invoked with an object containing action and activityType. If the user dismissed the dialog, the Promise will still be resolved with action being Share.dismissedAction and all the other keys being undefined. Note that some share options will not appear or work on the iOS simulator.

In Android, returns a Promise which will always be resolved with action being Share.sharedAction.

Properties:

Name Type Description
content (Required) object message - a message to share, url - a URL to share (iOS), title - title of the message (Android). At least one of url and message is required.
options object dialogTitle (Android), excludedActivityTypes (iOS), subject - a subject to share via email (iOS), tintColor (iOS), anchor - the node to which the action sheet should be anchored (used for iPad) (iOS)

Properties

sharedAction Android iOS

static sharedAction: 'sharedAction';

The content was successfully shared.


dismissedAction iOS

static dismissedAction: 'dismissedAction';

The dialog has been dismissed.


Last updated: Jul 07, 2026