feat(social-sharing): add canShareViaEmail (#333)
* - Add support for canShareViaEmail - Make the following parameters in shareViaEmail method optional: cc, bcc, files - Add usage for canShareViaEmail and shareViaEmail - Fix some formatting to be more consistent - Fix pluginRef * Fix import
This commit is contained in:
parent
a8fa61ddb9
commit
5807dd7f09
@ -1,35 +1,44 @@
|
|||||||
import { Cordova, Plugin } from './plugin';
|
import { Cordova, Plugin } from './plugin';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Social Sharing
|
* @name Social Sharing
|
||||||
* @description
|
* @description
|
||||||
* Share text, files, images, and links via social networks, sms, and email.
|
* Share text, files, images, and links via social networks, sms, and email.
|
||||||
* @usage
|
* @usage
|
||||||
* ```js
|
* ```ts
|
||||||
* import {SocialSharing} from 'ionic-native';
|
* import {SocialSharing} from 'ionic-native';
|
||||||
*
|
*
|
||||||
* ...
|
* // Check if sharing via email is supported
|
||||||
* // TODO add usage info
|
* SocialSharing.canShareViaEmail().then(() => {
|
||||||
|
* // Sharing via email is possible
|
||||||
|
* }).catch(() => {
|
||||||
|
* // Sharing via email is not possible
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // Share via email
|
||||||
|
* SocialSharing.shareViaEmail('Body', 'Subject', 'recipient@example.org').then(() => {
|
||||||
|
* // Success!
|
||||||
|
* }).catch(() => {
|
||||||
|
* // Error!
|
||||||
|
* });
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@Plugin({
|
@Plugin({
|
||||||
plugin: 'cordova-plugin-x-socialsharing',
|
plugin: 'cordova-plugin-x-socialsharing',
|
||||||
pluginRef: 'window.plugins.socialsharing',
|
pluginRef: 'plugins.socialsharing',
|
||||||
repo: 'https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin',
|
repo: 'https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin',
|
||||||
platforms: ['iOS', 'Android', 'Windows Phone']
|
platforms: ['iOS', 'Android', 'Windows Phone']
|
||||||
})
|
})
|
||||||
export class SocialSharing {
|
export class SocialSharing {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shares using the share sheet
|
* Shares using the share sheet
|
||||||
* @param message {string} The message you would like to share.
|
* @param message {string} The message you would like to share.
|
||||||
* @param subject {string} The subject
|
* @param subject {string} The subject
|
||||||
* @param file {string|Array<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 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
|
* @param url {string} A URL to share
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static share(message?: string, subject?: string, file?: string | Array<string>, url?: string): Promise<any> { return; }
|
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+)
|
* Shares using the share sheet with additional options and returns a result object or an error message (requires plugin version 5.1.0+)
|
||||||
@ -38,7 +47,7 @@ export class SocialSharing {
|
|||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['iOS', 'Android']
|
platforms: ['iOS', 'Android']
|
||||||
})
|
})
|
||||||
static shareWithOptions(options: { message?: string, subject?: string, file?: string | Array<string>, url?: string, chooserTitle?: string }): Promise<any> { return; }
|
static shareWithOptions(options: { message?: string, subject?: string, file?: string|string[], url?: string, chooserTitle?: string }): Promise<any> { return; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if you can share via a specific app.
|
* Checks if you can share via a specific app.
|
||||||
@ -128,17 +137,25 @@ export class SocialSharing {
|
|||||||
static shareViaSMS(messge: string, phoneNumber: string): Promise<any> { return; }
|
static shareViaSMS(messge: string, phoneNumber: string): Promise<any> { return; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Share via Email
|
* Checks if you can share via email
|
||||||
* @param message {string}
|
|
||||||
* @param subject {string}
|
|
||||||
* @param to {Array<string>}
|
|
||||||
* @param cc {Array<string>}
|
|
||||||
* @param bcc {Array<string>}
|
|
||||||
* @param files {string|Array<string>} URL or local path to file(s) to attach
|
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
platforms: ['iOS', 'Android']
|
platforms: ['iOS', 'Android']
|
||||||
})
|
})
|
||||||
static shareViaEmail(message: string, subject: string, to: Array<string>, cc: Array<string>, bcc: Array<string>, files: string | Array<string>): Promise<any> { return; }
|
static canShareViaEmail(): Promise<any> { return; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Share via Email
|
||||||
|
* @param message {string}
|
||||||
|
* @param subject {string}
|
||||||
|
* @param to {string[]}
|
||||||
|
* @param cc {string[]}
|
||||||
|
* @param bcc {string[]}
|
||||||
|
* @param files {string|string[]} URL or local path to file(s) to attach
|
||||||
|
*/
|
||||||
|
@Cordova({
|
||||||
|
platforms: ['iOS', 'Android']
|
||||||
|
})
|
||||||
|
static shareViaEmail(message: string, subject: string, to: string[], cc: string[] = [], bcc: string[] = [], files: string|string[] = []): Promise<any> { return; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user