MENU
Share
This API allows you to bring out on the user's phone the share dialog box which allows some content to be shared across different apps such as Gmail, Bluetooth and WhatsApp.
Methodsshare() | Properties sharedActiondismissedAction |
RESETRUNFULL
import React from 'react';import { Share, View, Button } from 'react-native';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(error.message);
}
};
return (
<View style={{ marginTop: 50 }}>
<Button onPress={onShare} title="Share" />
</View>
);};export default ShareExample;