簡體   English   中英

在 React Native 中將數據共享到社交媒體

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM