admin管理员组文章数量:1026989
I have an app in which i want to share specific data to social media like facebook,twitter,pinterest etc once the user clicks on the social icon. I have already used react native link which sends me to the pages of these platforms. But i want to share data to these once clicked. I have done this for whatsapp which is like this:
<TouchableOpacity onPress={() => {
let url = 'whatsapp://send?text=${hello}&phone=${01753362960}';
Linking.openURL(url).then((data) => {
console.log('open whatsapp', data)
}).catch(() => {
console.log('App not installed')
});
}} >
<Icon name='logo-whatsapp' style={{color: '#395894', fontSize: 30, marginRight: 10}}/>
</TouchableOpacity>
I have an app in which i want to share specific data to social media like facebook,twitter,pinterest etc once the user clicks on the social icon. I have already used react native link which sends me to the pages of these platforms. But i want to share data to these once clicked. I have done this for whatsapp which is like this:
<TouchableOpacity onPress={() => {
let url = 'whatsapp://send?text=${hello}&phone=${01753362960}';
Linking.openURL(url).then((data) => {
console.log('open whatsapp', data)
}).catch(() => {
console.log('App not installed')
});
}} >
<Icon name='logo-whatsapp' style={{color: '#395894', fontSize: 30, marginRight: 10}}/>
</TouchableOpacity>
I have done this for twitter also. But when that icon is clicked it shows the alert that the app is not installed although it was installed on my device.It was like:
let url = 'twitter://send?text=hello this is checked'
How can i do this for other social media platforms?
Share Improve this question asked Jan 29, 2019 at 10:46 Kazi RahamatullahKazi Rahamatullah 4712 gold badges5 silver badges18 bronze badges 1-
Have you tried this? Why do you think that twitter has
/send
page? – TeaNyan Commented Jan 29, 2019 at 10:52
3 Answers
Reset to default 1For twitter please use this,
let url = 'twitter://post?message=${yourMsg}'
I would do it this way: https://facebook.github.io/react-native/docs/share
This way the user can chose what app he wants to share to based on apps installed on users device
react-native-share is a good package to use for making some stuff share at different platforms. Back in early 2019 this package wasn't this much mature, but now it's really usefull.
https://github./react-native-munity/react-native-share
Have a look at here. Thanks.
I have an app in which i want to share specific data to social media like facebook,twitter,pinterest etc once the user clicks on the social icon. I have already used react native link which sends me to the pages of these platforms. But i want to share data to these once clicked. I have done this for whatsapp which is like this:
<TouchableOpacity onPress={() => {
let url = 'whatsapp://send?text=${hello}&phone=${01753362960}';
Linking.openURL(url).then((data) => {
console.log('open whatsapp', data)
}).catch(() => {
console.log('App not installed')
});
}} >
<Icon name='logo-whatsapp' style={{color: '#395894', fontSize: 30, marginRight: 10}}/>
</TouchableOpacity>
I have an app in which i want to share specific data to social media like facebook,twitter,pinterest etc once the user clicks on the social icon. I have already used react native link which sends me to the pages of these platforms. But i want to share data to these once clicked. I have done this for whatsapp which is like this:
<TouchableOpacity onPress={() => {
let url = 'whatsapp://send?text=${hello}&phone=${01753362960}';
Linking.openURL(url).then((data) => {
console.log('open whatsapp', data)
}).catch(() => {
console.log('App not installed')
});
}} >
<Icon name='logo-whatsapp' style={{color: '#395894', fontSize: 30, marginRight: 10}}/>
</TouchableOpacity>
I have done this for twitter also. But when that icon is clicked it shows the alert that the app is not installed although it was installed on my device.It was like:
let url = 'twitter://send?text=hello this is checked'
How can i do this for other social media platforms?
Share Improve this question asked Jan 29, 2019 at 10:46 Kazi RahamatullahKazi Rahamatullah 4712 gold badges5 silver badges18 bronze badges 1-
Have you tried this? Why do you think that twitter has
/send
page? – TeaNyan Commented Jan 29, 2019 at 10:52
3 Answers
Reset to default 1For twitter please use this,
let url = 'twitter://post?message=${yourMsg}'
I would do it this way: https://facebook.github.io/react-native/docs/share
This way the user can chose what app he wants to share to based on apps installed on users device
react-native-share is a good package to use for making some stuff share at different platforms. Back in early 2019 this package wasn't this much mature, but now it's really usefull.
https://github./react-native-munity/react-native-share
Have a look at here. Thanks.
本文标签: javascriptSharing data to social media in React nativeStack Overflow
版权声明:本文标题:javascript - Sharing data to social media in React native - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745653052a2161433.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论