Site icon VR SoftCoder

How to add social sharing in ionic react app

How to add social sharing in ionic react app, social sharing in ionic

How to add social sharing in ionic react app, social sharing in ionic

After lots of searching and efforts i have done the social sharing in my ionic react app. So you need to follow below setups:-

1) Install the below packages through npm


npm install cordova-plugin-x-socialsharing

npm install @ionic-native/social-sharing

2) Import package in your component as like below:-

import { SocialSharing } from '@ionic-native/social-sharing';

3) Now you need to call social sharing functions to share your content. I am using some popular social sharing platform for example:-

Share on Facebook:-> To add facebook sharing in ionic react app you need to use below code:-

 SocialSharing.shareViaFacebook(Body, Message, url).then(() => {
  
    })

Share on Twitter:-> To add twitter sharing in ionic react app you need to use below code:-

 SocialSharing.shareViaTwitter(Body, Message, url).then(() => {
  
    })

Share on Whatsapp:-> To add whatsapp sharing in ionic react app you need to use below code:-

 SocialSharing.shareViaWhatsApp(null, null, url).then(() => {
  
    })

Share on Instagram:-> To add Instagram sharing in ionic react app you need to use below code:-

 SocialSharing.shareViaInstagram(message, image).then(() => {
  
    })

Share on SMS:-> To add sms sharing in ionic react app you need to use below code:-

 SocialSharing.shareViaSMS(messge, phoneNumbe).then(() => {
  
    })

Share on Email:-> To add email sharing in ionic react app you need to use below code:-

 SocialSharing.shareViaEmail(message, subject, to, cc, bcc, files).then(() => {
  
    })

Now check your app in mobile all social sharing will work.

Exit mobile version