From 4f9716415b17737170ba11d815d54f4a7b9067bc Mon Sep 17 00:00:00 2001 From: Ramon Henrique Ornelas Date: Tue, 6 Sep 2016 22:58:04 -0300 Subject: [PATCH] fix(social-sharing): various fixes (#520) * feat(socialsharing): add method shareVia() * docs(socialsharing): fix docs params Types * docs(socialsharing): fix docs param Type method canShareVia * docs(socialsharing): shareVia() * fix(socialsharing): fix order callback, because params is optional * feat(socialsharing): add params optionals canShareVia() * docs(socialsharing): add returns Promise --- src/plugins/socialsharing.ts | 53 ++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/plugins/socialsharing.ts b/src/plugins/socialsharing.ts index d194b221b8..26118bd9ac 100644 --- a/src/plugins/socialsharing.ts +++ b/src/plugins/socialsharing.ts @@ -37,6 +37,7 @@ export class SocialSharing { * @param subject {string} The subject * @param file {string|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. * @param url {string} A URL to share + * @returns {Promise} */ @Cordova() static share(message?: string, subject?: string, file?: string|string[], url?: string): Promise { return; } @@ -44,6 +45,7 @@ export class SocialSharing { /** * Shares using the share sheet with additional options and returns a result object or an error message (requires plugin version 5.1.0+) * @param options {object} The options object with the message, subject, files, url and chooserTitle properties. + * @returns {Promise} */ @Cordova({ platforms: ['iOS', 'Android'] @@ -52,20 +54,30 @@ export class SocialSharing { /** * Checks if you can share via a specific app. - * @param appName App name or package name. Examples: instagram or com.apple.social.facebook + * @param appName {string} App name or package name. Examples: instagram or com.apple.social.facebook + * @param message {string} + * @param subject {string} + * @param image {string} + * @param url {string} + * @returns {Promise} */ @Cordova({ + successIndex: 5, + errorIndex: 6 platforms: ['iOS', 'Android'] }) - static canShareVia(appName: string): Promise { return; } + static canShareVia(appName: string, message?: string, subject?: string, image?: string, url?: string): Promise { return; } /** * Shares directly to Twitter - * @param message - * @param image - * @param url + * @param message {string} + * @param image {string} + * @param url {string} + * @returns {Promise} */ @Cordova({ + successIndex: 3, + errorIndex: 4 platforms: ['iOS', 'Android'] }) static shareViaTwitter(message: string, image?: string, url?: string): Promise { return; } @@ -75,8 +87,11 @@ export class SocialSharing { * @param message {string} * @param image {string} * @param url {string} + * @returns {Promise} */ @Cordova({ + successIndex: 3, + errorIndex: 4 platforms: ['iOS', 'Android'] }) static shareViaFacebook(message: string, image?: string, url?: string): Promise { return; } @@ -88,8 +103,11 @@ export class SocialSharing { * @param image {string} * @param url {string} * @param pasteMessageHint {string} + * @returns {Promise} */ @Cordova({ + successIndex: 4, + errorIndex: 5 platforms: ['iOS', 'Android'] }) static shareViaFacebookWithPasteMessageHint(message: string, image?: string, url?: string, pasteMessageHint?: string): Promise { return; } @@ -98,6 +116,7 @@ export class SocialSharing { * Shares directly to Instagram * @param message {string} * @param image {string} + * @returns {Promise} */ @Cordova({ platforms: ['iOS', 'Android'] @@ -109,8 +128,11 @@ export class SocialSharing { * @param message {string} * @param image {string} * @param url {string} + * @returns {Promise} */ @Cordova({ + successIndex: 3, + errorIndex: 4 platforms: ['iOS', 'Android'] }) static shareViaWhatsApp(message: string, image?: string, url?: string): Promise { return; } @@ -121,8 +143,11 @@ export class SocialSharing { * @param message {string} Message to send * @param image {string} Image to send (does not work on iOS * @param url {string} Link to send + * @returns {Promise} */ @Cordova({ + successIndex: 4, + errorIndex: 5 platforms: ['iOS', 'Android'] }) static shareViaWhatsAppToReceiver(receiver: string, message: string, image?: string, url?: string): Promise { return; } @@ -131,6 +156,7 @@ export class SocialSharing { * Share via SMS * @param messge {string} message to send * @param phoneNumber {string} Number or multiple numbers seperated by commas + * @returns {Promise} */ @Cordova({ platforms: ['iOS', 'Android'] @@ -139,6 +165,7 @@ export class SocialSharing { /** * Checks if you can share via email + * @returns {Promise} */ @Cordova({ platforms: ['iOS', 'Android'] @@ -153,10 +180,26 @@ export class SocialSharing { * @param cc {string[]} * @param bcc {string[]} * @param files {string|string[]} URL or local path to file(s) to attach + * @returns {Promise} */ @Cordova({ platforms: ['iOS', 'Android'] }) static shareViaEmail(message: string, subject: string, to: string[], cc: string[] = [], bcc: string[] = [], files: string|string[] = []): Promise { return; } + /** + * Share via AppName + * @param appName {string} App name or package name. Examples: instagram or com.apple.social.facebook + * @param message {string} + * @param subject {string} + * @param image {string} + * @param url {string} + * @returns {Promise} + */ + @Cordova({ + successIndex: 5, + errorIndex: 6 + platforms: ['iOS', 'Android'] + }) + static shareVia(appName: string, message: string, subject?: string, image?: string, url?: string): Promise { return; } }