Ionic 5 Full Starter App
  • Enappd Apps
  • Ionic 5 Full App
    • What is Ionic 5 Full App?
    • Template Features
    • Initial Setup
      • Environment Configuration
      • Credentials
    • Running the app
    • Deploying app as PWA
    • Building App on device
    • How to use this template?
      • Copy a module to another app
      • Shared Component & Modules
      • Map Service
    • Beginner Pack Features
      • Firebase
      • Layouts
      • Sidemenus
      • Login and Signups
      • Chat screens
      • Chat Lists
      • Video Playlists
      • Grids and Lists Layouts
    • Startup Pack Features
      • Wordpress
        • Wordpress JSON API Basics
        • Wordpress in Ionic 5 Full App
      • Translation - Multi-language
      • Using Custom Fonts
      • Infinite scroll
      • Content Loaders
      • Pull to refresh
      • List re-ordering
      • Date Pickers
    • Pro Pack Features
      • Phaser Game Framework
      • AdMob Integration
        • AdMob Introduction
        • Setting up Google Admob
        • Integration
      • Social Sharing
      • QR and Barcode Scanning
      • Google Places
      • Google Autocomplete
      • Social Logins
        • Google Login
        • Facebook Login
        • Twitter Login
      • Woo-commerce Integration
    • Removing a Page / Component
    • Removing a plugin
    • FAQs
    • Changelog
    • Troubleshoot
Powered by GitBook
On this page

Was this helpful?

  1. Ionic 5 Full App
  2. Pro Pack Features

Social Sharing

Share text, images and url with various apps in your device

PreviousIntegrationNextQR and Barcode Scanning

Last updated 5 years ago

Was this helpful?

Every app requires sharing in one way or another. plugin allows you to use the native sharing window of your mobile device.

  • Works on Android, version 2.3.3 and higher (probably 2.2 as well).

  • Works on iOS6 and up.

  • Works on Windows Phone 8 since v4.0 of this plugin (maybe even WP7, but I have no such testdevice).

  • Share text, a link, a images (or other files like pdf or ics). Subject is also supported, when the receiving app supports it.

  • Supports sharing files from the internet, the local filesystem, or from the www folder.

  • You can skip the sharing dialog and directly share to Twitter, Facebook, or other apps.

Install the plugin

$ ionic cordova plugin add cordova-plugin-x-socialsharing
$ npm install @ionic-native/social-sharing

and import the plugin in your pages

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

constructor(private socialSharing: SocialSharing) { }

In Ionic 5 Full App, this plugin's implementation can be found at src/app/pages/addons3/social-share

Sharing with Whatsapp

this.socialSharing.shareViaWhatsApp(text, image, url).then((res) => {
  // Success
}).catch((e) => {
  // Error!
});

You can share text, images or url. If any data is missing, use null in its place.

Sharing with Instagram

this.socialSharing.shareViaInstagram(text, image).then((res) => {
  // Success
}).catch((e) => {
  // Error!
});

Sharing with Facebook

this.socialSharing.shareViaFacebook(text, image, url).then((res) => {
  // Success
}).catch((e) => {
  // Error!
});

Text may be ignored by Facebook, as it often does not allow preset text to be filled in Facebook posts or shares.

Sharing with Twitter

this.socialSharing.shareViaTwitter(text, image, url).then((res) => {
  // Success
}).catch((e) => {
  // Error!
});

Sharing with Email

Check if email sharing is possible

this.socialSharing.canShareViaEmail().then((res) => {
  // Success
}).catch((e) => {
  // Error!
});

And then share with email

this.socialSharing.shareViaEmail(body, subject, ['recipient@example.org']).then((res) => {
  // Success
}).catch((e) => {
  // Error!
})
Social Sharing
Social sharing page with various sharing options