social share ionic code example
Example 1: ionic social sharing
npm install cordova-plugin-x-socialsharing
npm install @ionic-native/social-sharing
ionic cap sync
Example 2: ionic social sharing
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
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', ['[email protected]']).then(() => {
// Success!
}).catch(() => {
// Error!
});