skip to Main Content

explanation –

I am trying to use social sharing in my ionic Application using https://ionicframework.com/docs/native/social-sharing/ , for ios and Android
it is working
But when I try to use share on facebook , twitter , linkdin for web platform Api is not available How can I do it for web platform

2

Answers


  1. As per the cordova-plugin github repository, It supports only Mobile Platforms (Android, IOS, Windows). It doesn’t support desktop version. You need to add support from your end.

    https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/tree/master/src

    Login or Signup to reply.
  2. You can share links to social sites using these api’s

     shareTwitter(e) {
    
      e.preventDefault();
      var twitterWindow = window.open('https://twitter.com/share?url=' + document.URL, 'twitter-popup', 'height=350,width=600');
      if(twitterWindow.focus) { twitterWindow.focus(); }
        return false;
     }
     shareFacebook(e) {
      e.preventDefault();
      var facebookWindow = window.open('https://www.facebook.com/sharer/sharer.php?u=' + document.URL, 'facebook-popup', 'height=350,width=600');
      if(facebookWindow.focus) { facebookWindow.focus(); }
        return false;
     }
     shareGooglePlus(e) {
      //  var _this = this;
      e.preventDefault();
      var GooglePlusWindow = window.open('https://plus.google.com/share?url=' + document.URL, 'googleplus-popup', 'height=350,width=600');
      if(GooglePlusWindow.focus) { GooglePlusWindow.focus(); }
        return false;
     }
     shareLinkedIn(e) {
      var url =  document.URL
      var title = this.contributionDetails.Title;
      var text = document.URL;
      window.open('http://www.linkedin.com/shareArticle?mini=true&url='+url+'&title='+title, 'sharer', 'left=0,top=0,width=650,height=420,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
     }
    

    HTML File

            <ul>
              <li><a (click)="shareFacebook($event)" class="fbicon"><span class="fa fa-facebook"></span></a></li>
              <li><a (click)="shareTwitter($event)" class="twittericon"><span class="fa fa-twitter"></span></a></li>
              <li><a  (click)="shareGooglePlus($event)" class="gpicon"><span class="fa fa-google-plus"></span></a></li>
              <li><a  (click)="shareLinkedIn($event)" class="linkicon"><span class="fa fa-linkedin"></span></a></li>
             </ul>
          </div>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search