Ionic 2: capture screenshot and social sharing

In Ionic 2, if you want to capture screenshot and send it or share it via Social Network, you can follow these steps below:

// First import

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

// Second in constructor

constructor(
        //....
        private screenshotScreenshot,
        private socialSharingSocialSharing,
        //....
    ) {
    }

// Now do it

// Share Facebook

this.screenshot.URI().then((res=> {
                        this.socialSharing.shareViaFacebookWithPasteMessageHint(bodyres.URIlinkbodyHint).then(() => {});
                    });

// share via twitter
this.screenshot.URI().then((res=> {
                        this.socialSharing.shareViaTwitter(bodyres.URIlink).then(() => {});
                    });

// Share via Email (Gmail included)
this.screenshot.URI().then((res=> {
                        this.socialSharing.shareViaEmail(body + ' ' + link'', [], nullnullres.URI).then(() => {});
                        });
                    });

Enjoy!

Comments

  1. Property 'URI' does not exist on type 'typeof Screenshot'.

    ReplyDelete
  2. The first step is the user needs to visit the link which is given here
    mobiloans login

    ReplyDelete

Post a Comment

Popular posts from this blog

Ionic 2 Angular 2 Cordova Fix: Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)