Skip to content

Commit

Permalink
fix(social-sharing): various fixes (#520)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ramonornela authored and ihadeed committed Sep 7, 2016
1 parent caf2d67 commit 4f97164
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions src/plugins/socialsharing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ 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<any> { return; }

/**
* 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']
Expand All @@ -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<any> { return; }
static canShareVia(appName: string, message?: string, subject?: string, image?: string, url?: string): Promise<any> { 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<any> { return; }
Expand All @@ -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<any> { return; }
Expand All @@ -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<any> { return; }
Expand All @@ -98,6 +116,7 @@ export class SocialSharing {
* Shares directly to Instagram
* @param message {string}
* @param image {string}
* @returns {Promise}
*/
@Cordova({
platforms: ['iOS', 'Android']
Expand All @@ -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<any> { return; }
Expand All @@ -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<any> { return; }
Expand All @@ -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']
Expand All @@ -139,6 +165,7 @@ export class SocialSharing {

/**
* Checks if you can share via email
* @returns {Promise}
*/
@Cordova({
platforms: ['iOS', 'Android']
Expand All @@ -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<any> { 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<any> { return; }
}

0 comments on commit 4f97164

Please sign in to comment.