[英]Sharing data to social media in React native
我有一個應用程序,一旦用戶點擊社交圖標,我想在其中將特定數據共享到社交媒體,如 facebook、twitter、pinterest 等。 我已經使用了 react native 鏈接,它將我發送到這些平台的頁面。 但是我想在點擊后與這些共享數據。 我已經為 whatsapp 做了這個,就像這樣:
<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>
let url = 'twitter://send?text=hello this is checked'
我如何為其他社交媒體平台執行此操作?
對於推特,請使用這個,
let url = 'twitter://post?message=${yourMsg}'
我會這樣做: https : //facebook.github.io/react-native/docs/share
通過這種方式,用戶可以根據用戶設備上安裝的應用程序選擇他想要共享的應用程序
react-native-share 是一個很好的包,用於在不同平台上共享一些東西。 早在 2019 年初,這個包還沒有那么成熟,但現在它真的很有用。
https://github.com/react-native-community/react-native-share
看看這里。 謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.