I am trying to access iOS' share button where you can share content to all services, including messages etc... Any idea how I could do this? Thanks
You might want to check out the react-native-share package, it should cover your usecase. You can also see more relevant packages on JS.Coach
You can achieve this out of the box in React Native - just use ActionSheetIOS.showShareActionSheetWithOptions
. See the documentation here .
You now have a simple Share API in react-native.
import { Share } from "react-native"
Share.share(
{
title: "a title",
message: "some message",
// or
url: imageReference
},
(options)
);
It's much easier than you think. Adding to @MoOx answer further.
With the new share api available, you can easily share information with your React Native app by just using it with all variables and configuration. ( see here )
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.