From efc8231ab63adaeffe705faa25aaa31c65141f04 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Fri, 25 Mar 2016 20:11:28 -0400 Subject: [PATCH] feat(plugin): add social sharing plugin closes https://github.com/driftyco/ionic-native/issues/65 --- src/plugins/socialsharing.ts | 139 +++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 src/plugins/socialsharing.ts diff --git a/src/plugins/socialsharing.ts b/src/plugins/socialsharing.ts new file mode 100644 index 000000000..008d2e6f3 --- /dev/null +++ b/src/plugins/socialsharing.ts @@ -0,0 +1,139 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * @name Social Sharing + * @description + * Share text, files, images, and links via social networks, sms, and email. + * @usage + * ```js + * import {SocialSharing} from 'ionic-native'; + * + * ... + * // TODO add usage info + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-x-socialsharing', + pluginRef: 'window.plugins.socialsharing', + repo: 'https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin', + platforms: ['iOS','Android','Windows Phone'] +}) +export class SocialSharing { + + + /** + * Shares using the share sheet + * @param message {string} The message you would like to share. + * @param subject {string} The subject + * @param file {string|Array} 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. + * @param url {string} A URL to share + */ + @Cordova({ + sync: true + }) + static share (message? : string, subject? : string, file? : string|Array, url? : string) : void {} + + /** + * Checks if you can share via a specific app. + * @param appName App name or package name. Examples: instagram or com.apple.social.facebook + */ + @Cordova({ + platforms: ['iOS','Android'] + }) + static canShareVia (appName : string) : Promise {return} + + /** + * Shares directly to Twitter + * @param message + * @param image + * @param url + */ + @Cordova({ + sync: true, + platforms: ['iOS','Android'] + }) + static shareViaTwitter (message : string, image? : string, url? : string) : void {} + + /** + * Shares directly to Facebook + * @param message {string} + * @param image {string} + * @param url {string} + */ + @Cordova({ + platforms: ['iOS','Android'] + }) + static shareViaFacebook (message : string, image? : string, url? : string) : Promise {return} + + + /** + * Shares directly to Facebook with a paste message hint + * @param message {string} + * @param image {string} + * @param url {string} + * @param pasteMessageHint {string} + */ + @Cordova({ + platforms: ['iOS','Android'] + }) + static shareViaFacebookWithPasteMessageHint (message : string, image? : string, url? : string, pasteMessageHint?:string) : Promise {return} + + /** + * Shares directly to Instagram + * @param message {string} + * @param image {string} + */ + @Cordova({ + platforms: ['iOS','Android'] + }) + static shareViaInstagram (message : string, image : string) : Promise {return} + + /** + * Shares directly to WhatsApp + * @param message {string} + * @param image {string} + * @param url {string} + */ + @Cordova({ + platforms: ['iOS','Android'] + }) + static shareViaWhatsApp (message : string, image? : string, url? : string) : Promise {return} + + /** + * Shares directly to a WhatsApp Contact + * @param receiver {string} Pass phone number on Android, and Addressbook ID (abid) on iOS + * @param message {string} Message to send + * @param image {string} Image to send (does not work on iOS + * @param url {string} Link to send + */ + @Cordova({ + platforms: ['iOS','Android'] + }) + static shareViaWhatsAppToReceiver (receiver:string, message : string, image? : string, url? : string) : Promise {return} + + /** + * Share via SMS + * @param messge {string} message to send + * @param number {string} Number or multiple numbers seperated by commas + */ + @Cordova({ + platforms: ['iOS','Android'] + }) + static shareViaSMS(messge : string, number : string) : Promise {return} + + /** + * Share via Email + * @param message {string} + * @param subject {string} + * @param to {Array} + * @param cc {Array} + * @param bcc {Array} + * @param files {string|Array} URL or local path to file(s) to attach + */ + @Cordova({ + platforms: ['iOS','Android'] + }) + static shareViaEmail(message:string, subject:string, to:Array, cc:Array, bcc:Array, files:string|Array) : Promise {return} + + +} \ No newline at end of file