Share

The Share API provides the ability to share text, files, images, and links via social networks, SMS, and email.

Usage
// Check if sharing via email is supported
Share.canShareViaEmail()
    .then(() => {
        // Sharing via email is possible
        
        Share.shareViaEmail('Body', 'Subject', ['recipient@example.org']).then(() => {
            // Success!
        }).catch(() => {
            // Error!
        });
        
    }).catch(() => {
        // Sharing via email is not possible
    });
// Check if sharing via email is supported
window.Share.canShareViaEmail()
    .then(() => {
        // Sharing via email is possible

        window.Share.shareViaEmail("Body", "Subject", ["recipient@example.org"])
            .then(() => {
                // Success!
            })
            .catch(() => {
                // Error!
            });
    })
    .catch(() => {
        // Sharing via email is not possible
    });
// Check if sharing via email is supported
window.Share.canShareViaEmail()
    .then(() => {
        // Sharing via email is possible

        Share.shareViaEmail("Body", "Subject", ["recipient@example.org"])
            .then(() => {
                // Success!
            })
            .catch(() => {
                // Error!
            });
    })
    .catch(() => {
        // Sharing via email is not possible
    });
// Check if sharing via email is supported
(<any>window).Share.canShareViaEmail()
    .then(() => {
        // Sharing via email is possible

        (window).Share.shareViaEmail("Body", "Subject", ["recipient@example.org"])
        .then(() => {
            // Success!
        })
        .catch(() => {
            // Error!
        });
    })
    .catch(() => {
        // Sharing via email is not possible
    });
// Check if sharing via email is supported
window.Share.canShareViaEmail()
    .then(() => {
        // Sharing via email is possible

        Share.shareViaEmail("Body", "Subject", ["recipient@example.org"])
            .then(() => {
                // Success!
            })
            .catch(() => {
                // Error!
            });
    })
    .catch(() => {
        // Sharing via email is not possible
    });

Classes

Share

canShareVia
canShareVia(appName: <string>, message?: <string>, subject?: <string>, image?: <string>, url?: <string>): Promise<any>

Checks if you can share via a specific app.


PARAMETERS
appName: string App name or package name. Examples: instagram or com.apple.social.facebook
message [Optional]: string
subject [Optional]: string
image [Optional]: string
url [Optional]: string

RETURN
returns: Promise<any>
canShareViaEmail
canShareViaEmail(): Promise<any>

Checks if you can share via email.

RETURN
returns: Promise<any>
saveToPhotoAlbum
saveToPhotoAlbum(fileOrFileArray: string | string[]) Promise<any>

PARAMETERS
fileOrFileArray: string | string[]

RETURN
returns: Promise<any>
share
share(message?: string, subject?: string, file?: string | string[], url?: string):  Promise<any>

Shares using the share sheet.


PARAMETERS
message [Optional]: string
subject [Optional]: string
file [Optional]: string | string[]
url [Optional]: string

RETURN
returns: Promise<any>
shareVia
shareVia(appName: string, message: string, subject?: string, image?: string, url?: string):  Promise<any>

Share via AppName.


PARAMETERS
appName: string
message: string
subject <Optional>: string
image <Optional>: string | string[]
url <Optional>: string

RETURN
returns: Promise<any>
shareViaEmail
shareViaEmail(message: string, subject: string, to: string[], cc?: string[], bcc?: string[], files?: string | string[]):  Promise<any>

Share via Email.


PARAMETERS
message: string
subject: string
to: string[]
cc [Optional]: string
bcc [Optional]: string || string[]
files[Optional]: string

RETURN
returns: Promise<any>
shareViaFacebook
shareViaFacebook(message: string, image?: string, url?: string):  Promise<any>

Shares directly to Facebook.


PARAMETERS
message: string
image [Optional]: string
url [Optional]: string

RETURN
returns: Promise<any>
shareViaFacebookWithPasteMessageHint
shareViaFacebookWithPasteMessageHint(message: string, image?: string, url?: string, pasteMessageHint?: string):  Promise<any>

Shares directly to Facebook with a paste message hint.


PARAMETERS
message: string
image [Optional]: string
url [Optional]: string
pasteMessageHint [Optional]: string

RETURN
returns: Promise<any>
shareViaInstagram
shareViaInstagram(message: string, image: string):  Promise<any>

Shares directly to Instagram.


PARAMETERS
message: string
image: string

RETURN
returns: Promise<any>
shareViaSMS
shareViaSMS(message: string, image: string):  Promise<any>

Share via SMS.


PARAMETERS
message: string
phoneNumber: string

RETURN
returns: Promise<any>
shareViaTwitter
shareViaTwitter(message: string, image?: string, url?: string):  Promise<any>

Shares directly to Twitter.


PARAMETERS
message [Optional]: string
image [Optional]: string
url [Optional]: string

RETURN
returns: Promise<any>
shareViaWhatsApp
shareViaWhatsApp(message: string, image?: string, url?: string):  Promise<any>

Shares directly to WhatsApp.


PARAMETERS
message: string
image [Optional]: string
url [Optional]: string

RETURN
returns: Promise<any>
shareViaWhatsAppToReceiver
shareViaWhatsAppToReceiver(receiver: string, message: string, image?: string, url?: string):  Promise<any>

Shares directly to a WhatsApp Contact.


PARAMETERS
receiver: string
message: string
image [Optional]: string
url [Optional]: string

RETURN
returns: Promise<any>
shareWithOptions
shareWithOptions(options: object):  Promise<any>

Shares using the share sheet with additional options and returns a result object or an error message.


PARAMETERS
chooserTitle [Optional]: string
files [Optional]: string
message [Optional]: string
subject [Optional]: string
url [Optional]: string

RETURN
returns: Promise<any>