【发布时间】:2018-10-29 12:21:34
【问题描述】:
如何共享将在 React Native 移动应用 Web 浏览器中打开的 pdf 文件链接或图像链接。我添加了一个共享按钮,但是当用户单击它时,它会打开共享菜单选项的位置,例如 WhatsApp、Gmail、消息等。但是当单击 WhatsApp 时它不会发送任何内容,为什么会这样?我是否需要在我的 react native android 应用程序中使用 Gmail、WhatsApp API
代码:
import {
Text,
View,
StyleSheet,
Button,
Animated,
Dimensions,
ScrollView,
Image,
TouchableOpacity,
Linking,
Platform,
Share
} from 'react-native';
// inside render
onSharePress = (shareOptions) => Share.share(shareOptions);
const shareOptions = {
title: 'Download Brochure',
url: brochure
}
// inside return
<View style={{paddingLeft: 10, marginRight: 20, flex: 1, flexDirection: 'row', justifyContent: 'flex-end'}}>
<TouchableOpacity onPress={() => this.onSharePress(shareOptions)}>
<Icon style={{paddingLeft: 10}} name="md-share" size={25} color="black"/>
</TouchableOpacity>
</View>
在下面的屏幕截图中,您可以看到它只是打开了共享选项菜单,但是当我单击某些平台时,未发送内容(即文件的 URL)我该怎么做?我错过了什么吗?
【问题讨论】:
-
@harsh Patel 你能帮我分享一下本机反应吗?为什么它不起作用?
-
很抱歉,我还没有尝试过 react JS。
标签: javascript reactjs react-native