Social Sharing
Share text, files, images, and links via social networks, sms, and email.
For Browser usage check out the Web Share API docs: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#5-web-share-api
Repo: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin
Installation
- Install the Cordova and Ionic Native plugins:
 $ ionic cordova plugin add cordova-plugin-x-socialsharing $ npm install --save @ionic-native/social-sharing@4
- Add this plugin to your app's module
Supported platforms
- Android
- Browser
- iOS
- Windows
- Windows Phone
Usage
import { SocialSharing } from '@ionic-native/social-sharing';
constructor(private socialSharing: SocialSharing) { }
...
// Check if sharing via email is supported
this.socialSharing.canShareViaEmail().then(() => {
  // Sharing via email is possible
}).catch(() => {
  // Sharing via email is not possible
});
// Share via email
this.socialSharing.shareViaEmail('Body', 'Subject', ['recipient@example.org']).then(() => {
  // Success!
}).catch(() => {
  // Error!
});
Instance Members
share(message, subject, file, url)
Shares using the share sheet
| Param | Type | Details | 
|---|---|---|
| message | string | The message you would like to share. | 
| subject | string | The subject | 
| file | string|Array.<string> | URL(s) to file(s) or image(s), local path(s) to file(s) or image(s), or base64 data of an image. Only the first file/image will be used on Windows Phone. | 
| url | string | A URL to share | 
  Returns: Promise<any>
shareWithOptions(options)
Platforms:iOS Android
Shares using the share sheet with additional options and returns a result object or an error message (requires plugin version 5.1.0+)
| Param | Type | Details | 
|---|---|---|
| options | object | The options object with the message, subject, files, url and chooserTitle properties. | 
  Returns: Promise<any>
canShareVia(appName, message, subject, image, url)
Platforms:iOS Android
Checks if you can share via a specific app.
| Param | Type | Details | 
|---|---|---|
| appName | string | App name or package name. Examples: instagram or com.apple.social.facebook | 
| message | string | |
| subject | string | |
| image | string | |
| url | string | 
  Returns: Promise<any>
shareViaTwitter(message, image, url)
Platforms:iOS Android
Shares directly to Twitter
| Param | Type | Details | 
|---|---|---|
| message | string | |
| image | string | |
| url | string | 
  Returns: Promise<any>
shareViaFacebook(message, image, url)
Platforms:iOS Android
Shares directly to Facebook
| Param | Type | Details | 
|---|---|---|
| message | string | |
| image | string | |
| url | string | 
  Returns: Promise<any>
shareViaFacebookWithPasteMessageHint(message, image, url, pasteMessageHint)
Platforms:iOS Android
Shares directly to Facebook with a paste message hint
| Param | Type | Details | 
|---|---|---|
| message | string | |
| image | string | |
| url | string | |
| pasteMessageHint | string | 
  Returns: Promise<any>
shareViaInstagram(message, image)
Platforms:iOS Android
Shares directly to Instagram
| Param | Type | Details | 
|---|---|---|
| message | string | |
| image | string | 
  Returns: Promise<any>
shareViaWhatsApp(message, image, url)
Platforms:iOS Android
Shares directly to WhatsApp
| Param | Type | Details | 
|---|---|---|
| message | string | |
| image | string | |
| url | string | 
  Returns: Promise<any>
shareViaWhatsAppToReceiver(receiver, message, image, url)
Platforms:iOS Android
Shares directly to a WhatsApp Contact
| Param | Type | Details | 
|---|---|---|
| receiver | string | Pass phone number on Android, and Addressbook ID (abid) on iOS | 
| message | string | Message to send | 
| image | string | Image to send (does not work on iOS | 
| url | string | Link to send | 
  Returns: Promise<any>
shareViaSMS(messge, phoneNumber)
Platforms:iOS Android
Share via SMS
| Param | Type | Details | 
|---|---|---|
| messge | string | message to send | 
| phoneNumber | string | Number or multiple numbers seperated by commas | 
  Returns: Promise<any>
canShareViaEmail()
Platforms:iOS Android
Checks if you can share via email
  Returns: Promise<any>
shareViaEmail(message, subject, to, cc, bcc, files)
Platforms:iOS Android
Share via Email
| Param | Type | Details | 
|---|---|---|
| message | string | |
| subject | string | |
| to | string[] | |
| cc | string[] | Optional | 
| bcc | string[] | Optional | 
| files | string|Array.<string> | Optional URL or local path to file(s) to attach | 
  Returns: Promise<any>
shareVia(appName, message, subject, image, url)
Platforms:iOS Android
Share via AppName
| Param | Type | Details | 
|---|---|---|
| appName | string | App name or package name. Examples: instagram or com.apple.social.facebook | 
| message | string | |
| subject | string | |
| image | string | |
| url | string | 
  Returns: Promise<any>
setIPadPopupCoordinates(targetBounds)
Platforms:iOS
defines the popup position before call the share method.
| Param | Type | Details | 
|---|---|---|
| targetBounds | string | left, top, width, height | 
saveToPhotoAlbum(fileOrFileArray)
Platforms:iOS
Save an array of images to the camera roll
| Param | Type | Details | 
|---|---|---|
| fileOrFileArray | string|Array.<string> | Single or multiple files | 
  Returns: Promise<any>