import ReactNative from "react-native" ; param { string } url param { string } text param { string } title returns { Promise . < boolean > } export async function Share ( url ? , text ? , title ? ) { if ( ! text && ! url ) { return Promise . reject ( new Error ( "It is required to provide at least one of input parameters 'Text' and 'Url'" ) ) ; } if ( navigator && navigator . product === "ReactNative" ) { const RNShare = require ( "react-native" ) . Share ; const content = url && text ? { message : text + "\n" + url , title } : url ? { url , title } : { message : text ! , title } ; return RNShare . share ( content ) . then ( result => { if ( result . action === RNShare . dismissedAction ) { return false ; } return true ; } ) ; } if ( navigator && navigator . share ) { return navigator . share ( { url , text , title } ) . then ( ( ) => true ) ; } if ( window && window . plugins && window . plugins . socialsharing ) { return new Promise ( ( resolve , reject ) => { window ! . plugins ! . socialsharing ! . shareWithOptions ( { message : text , subject : title , url } , result => resolve ( result . completed ) , errorMessage => reject ( new Error ( errorMessage ) ) ) ; } ) ; } if ( document && document . location && document . location . protocol === "http:" ) { return Promise . reject ( new Error ( "This action requires a secure https: connection" ) ) ; } return Promise . reject ( new Error ( "This action is not supported by this browser" ) ) ; }