community-cordova-plugin-social-sharing 6.2.3 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/src/android/nl/xservices/plugins/SocialSharing.java +5 -0
- package/src/ios/SocialSharing.h +1 -0
- package/src/ios/SocialSharing.m +81 -14
- package/types/index.d.ts +116 -37
- package/www/SocialSharing.js +6 -16
package/README.md
CHANGED
|
@@ -21,6 +21,14 @@ or if you're asking for new features or priority bug fixes. Thank you!
|
|
|
21
21
|
|
|
22
22
|
> Version 6.0.0 is compatible with Android X. See [this issue](https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/pull/1039) for details. 5.6.8 is the last version before 6.0.0, so be sure to pick that if you run into Android X-related issues.
|
|
23
23
|
|
|
24
|
+
### Changelog (Recent)
|
|
25
|
+
|
|
26
|
+
#### 6.3.0
|
|
27
|
+
- Added `hasEmailClients()` method to check if any email client is available (iOS & Android)
|
|
28
|
+
- iOS: Improved email availability detection using mailto: URL scheme (works with third-party email apps like Gmail, Outlook when native Mail is not configured)
|
|
29
|
+
- Changed global variable export to `SocialSharingPlugin` for consistency with other Cordova plugins
|
|
30
|
+
- TypeScript types updated
|
|
31
|
+
|
|
24
32
|
## 0. Index
|
|
25
33
|
|
|
26
34
|
1. [Description](#1-description)
|
|
@@ -292,6 +300,25 @@ Note that on Android, SMS via Hangouts may not behave correctly
|
|
|
292
300
|
|
|
293
301
|
#### Email
|
|
294
302
|
Code inspired by the [EmailComposer plugin](https://github.com/katzer/cordova-plugin-email-composer), note that this is not supported on the iOS 8 simulator (an alert will be shown if your try to).
|
|
303
|
+
|
|
304
|
+
##### Check if email clients are available
|
|
305
|
+
Use `hasEmailClients` to check if any email client is installed. On iOS, this checks for mailto: URL scheme support, which works with third-party email apps (Gmail, Outlook, etc.) even when the native Mail app is not configured.
|
|
306
|
+
```js
|
|
307
|
+
SocialSharingPlugin.hasEmailClients(
|
|
308
|
+
function(hasClients) {
|
|
309
|
+
if (hasClients) {
|
|
310
|
+
console.log('Email clients available');
|
|
311
|
+
} else {
|
|
312
|
+
console.log('No email clients found');
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
function(error) {
|
|
316
|
+
console.log('Error: ' + error);
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
##### Send email
|
|
295
322
|
```js
|
|
296
323
|
window.plugins.socialsharing.shareViaEmail(
|
|
297
324
|
'Message', // can contain HTML tags, but support on Android is rather limited: http://stackoverflow.com/questions/15136480/how-to-send-html-content-with-image-through-android-default-email-client
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "community-cordova-plugin-social-sharing",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "Share text, images (and other files), or a link via the native sharing widget of your device. Android is fully supported, as well as iOS 6 and up. WP8 has somewhat limited support.",
|
|
5
5
|
"cordova": {
|
|
6
6
|
"id": "community-cordova-plugin-social-sharing",
|
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
4
|
id="community-cordova-plugin-social-sharing"
|
|
5
|
-
version="6.
|
|
5
|
+
version="6.3.0">
|
|
6
6
|
|
|
7
7
|
<name>SocialSharing</name>
|
|
8
8
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<dependency id="es6-promise-plugin" version="^4.1.0" />
|
|
29
29
|
|
|
30
30
|
<js-module src="www/SocialSharing.js" name="SocialSharing">
|
|
31
|
-
<clobbers target="
|
|
31
|
+
<clobbers target="SocialSharingPlugin" />
|
|
32
32
|
</js-module>
|
|
33
33
|
|
|
34
34
|
<!-- ios -->
|
|
@@ -48,6 +48,7 @@ public class SocialSharing extends CordovaPlugin {
|
|
|
48
48
|
private static final String ACTION_SHARE_WITH_OPTIONS_EVENT = "shareWithOptions";
|
|
49
49
|
private static final String ACTION_CAN_SHARE_VIA = "canShareVia";
|
|
50
50
|
private static final String ACTION_CAN_SHARE_VIA_EMAIL = "canShareViaEmail";
|
|
51
|
+
private static final String ACTION_HAS_EMAIL_CLIENTS = "hasEmailClients";
|
|
51
52
|
private static final String ACTION_SHARE_VIA = "shareVia";
|
|
52
53
|
private static final String ACTION_SHARE_VIA_TWITTER_EVENT = "shareViaTwitter";
|
|
53
54
|
private static final String ACTION_SHARE_VIA_FACEBOOK_EVENT = "shareViaFacebook";
|
|
@@ -115,6 +116,10 @@ public class SocialSharing extends CordovaPlugin {
|
|
|
115
116
|
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "not available"));
|
|
116
117
|
return false;
|
|
117
118
|
}
|
|
119
|
+
} else if (ACTION_HAS_EMAIL_CLIENTS.equals(action)) {
|
|
120
|
+
boolean hasClients = isEmailAvailable();
|
|
121
|
+
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, hasClients));
|
|
122
|
+
return true;
|
|
118
123
|
} else if (ACTION_SHARE_VIA.equals(action)) {
|
|
119
124
|
return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4), null, false, true);
|
|
120
125
|
} else if (ACTION_SHARE_VIA_SMS_EVENT.equals(action)) {
|
package/src/ios/SocialSharing.h
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
- (void)shareWithOptions:(CDVInvokedUrlCommand*)command;
|
|
15
15
|
- (void)canShareVia:(CDVInvokedUrlCommand*)command;
|
|
16
16
|
- (void)canShareViaEmail:(CDVInvokedUrlCommand*)command;
|
|
17
|
+
- (void)hasEmailClients:(CDVInvokedUrlCommand*)command;
|
|
17
18
|
- (void)shareVia:(CDVInvokedUrlCommand*)command;
|
|
18
19
|
- (void)shareViaTwitter:(CDVInvokedUrlCommand*)command;
|
|
19
20
|
- (void)shareViaFacebook:(CDVInvokedUrlCommand*)command;
|
package/src/ios/SocialSharing.m
CHANGED
|
@@ -269,10 +269,26 @@ static NSString *const kShareOptionIPadCoordinates = @"iPadCoordinates";
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
- (bool)isEmailAvailable {
|
|
272
|
+
// First check if any app can handle mailto: URL (works for third-party email apps)
|
|
273
|
+
NSURL *mailtoURL = [NSURL URLWithString:@"mailto:test@test.com"];
|
|
274
|
+
if ([[UIApplication sharedApplication] canOpenURL:mailtoURL]) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
// Fallback to native Mail app check
|
|
272
278
|
Class messageClass = (NSClassFromString(@"MFMailComposeViewController"));
|
|
273
279
|
return messageClass != nil && [messageClass canSendMail];
|
|
274
280
|
}
|
|
275
281
|
|
|
282
|
+
- (void)hasEmailClients:(CDVInvokedUrlCommand*)command {
|
|
283
|
+
// Check if any email client can handle mailto: URLs
|
|
284
|
+
NSURL *mailtoURL = [NSURL URLWithString:@"mailto:test@test.com"];
|
|
285
|
+
BOOL hasClients = [[UIApplication sharedApplication] canOpenURL:mailtoURL];
|
|
286
|
+
NSLog(@"SocialSharing: hasEmailClients = %@", hasClients ? @"YES" : @"NO");
|
|
287
|
+
|
|
288
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:hasClients];
|
|
289
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
290
|
+
}
|
|
291
|
+
|
|
276
292
|
- (bool)isAvailableForSharing:(CDVInvokedUrlCommand*)command
|
|
277
293
|
type:(NSString *) type {
|
|
278
294
|
|
|
@@ -336,19 +352,74 @@ static NSString *const kShareOptionIPadCoordinates = @"iPadCoordinates";
|
|
|
336
352
|
}
|
|
337
353
|
|
|
338
354
|
- (void)shareViaEmail:(CDVInvokedUrlCommand*)command {
|
|
339
|
-
if
|
|
355
|
+
// Check if MFMailComposeViewController class is available
|
|
356
|
+
Class messageClass = (NSClassFromString(@"MFMailComposeViewController"));
|
|
357
|
+
if (messageClass == nil) {
|
|
358
|
+
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"not available"];
|
|
359
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
340
362
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
363
|
+
// Try to open mail composer even if canSendMail returns false
|
|
364
|
+
// On newer iOS, canSendMail may return false even when third-party mail apps are available
|
|
365
|
+
BOOL canSendMail = [MFMailComposeViewController canSendMail];
|
|
366
|
+
NSLog(@"SocialSharing: canSendMail = %@", canSendMail ? @"YES" : @"NO");
|
|
367
|
+
|
|
368
|
+
if (!canSendMail) {
|
|
369
|
+
// Try using mailto: URL scheme as fallback
|
|
370
|
+
NSString *message = [command.arguments objectAtIndex:0];
|
|
371
|
+
NSString *subject = [command.arguments objectAtIndex:1];
|
|
372
|
+
NSArray *toRecipients = [command.arguments objectAtIndex:2];
|
|
373
|
+
|
|
374
|
+
NSMutableString *mailtoURL = [NSMutableString stringWithString:@"mailto:"];
|
|
375
|
+
|
|
376
|
+
if (toRecipients != (id)[NSNull null] && [toRecipients count] > 0) {
|
|
377
|
+
[mailtoURL appendString:[toRecipients componentsJoinedByString:@","]];
|
|
349
378
|
}
|
|
350
379
|
|
|
351
|
-
[
|
|
380
|
+
NSMutableArray *params = [[NSMutableArray alloc] init];
|
|
381
|
+
|
|
382
|
+
if (subject != (id)[NSNull null] && [subject length] > 0) {
|
|
383
|
+
[params addObject:[NSString stringWithFormat:@"subject=%@", [subject stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]];
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (message != (id)[NSNull null] && [message length] > 0) {
|
|
387
|
+
[params addObject:[NSString stringWithFormat:@"body=%@", [message stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]];
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if ([params count] > 0) {
|
|
391
|
+
[mailtoURL appendString:@"?"];
|
|
392
|
+
[mailtoURL appendString:[params componentsJoinedByString:@"&"]];
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
NSURL *url = [NSURL URLWithString:mailtoURL];
|
|
396
|
+
NSLog(@"SocialSharing: Trying mailto URL: %@", mailtoURL);
|
|
397
|
+
|
|
398
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
399
|
+
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
|
|
400
|
+
if (success) {
|
|
401
|
+
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES];
|
|
402
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
403
|
+
} else {
|
|
404
|
+
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No email app available"];
|
|
405
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
406
|
+
}
|
|
407
|
+
}];
|
|
408
|
+
});
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (TARGET_IPHONE_SIMULATOR && IsAtLeastiOSVersion(@"8.0")) {
|
|
413
|
+
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SocialSharing plugin"
|
|
414
|
+
message:@"Sharing via email is not supported on the iOS 8 simulator."
|
|
415
|
+
delegate:nil
|
|
416
|
+
cancelButtonTitle:@"OK"
|
|
417
|
+
otherButtonTitles:nil];
|
|
418
|
+
[alert show];
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
[self cycleTheGlobalMailComposer];
|
|
352
423
|
|
|
353
424
|
self.globalMailComposer.mailComposeDelegate = self;
|
|
354
425
|
|
|
@@ -427,10 +498,6 @@ static NSString *const kShareOptionIPadCoordinates = @"iPadCoordinates";
|
|
|
427
498
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
428
499
|
[[self getTopMostViewController] presentViewController:self.globalMailComposer animated:YES completion:nil];
|
|
429
500
|
});
|
|
430
|
-
} else {
|
|
431
|
-
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"not available"];
|
|
432
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
433
|
-
}
|
|
434
501
|
}
|
|
435
502
|
|
|
436
503
|
- (UIViewController*) getTopMostViewController {
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Type definitions for PhoneGap / Cordova Social Sharing plugin
|
|
2
|
-
// Project: https://github.com/
|
|
2
|
+
// Project: https://github.com/AhmedRaisi/SocialSharing-PhoneGap-Plugin
|
|
3
3
|
// Licensed under the MIT license.
|
|
4
4
|
|
|
5
5
|
interface Window {
|
|
@@ -7,44 +7,14 @@ interface Window {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
interface Plugins {
|
|
10
|
-
socialsharing:
|
|
10
|
+
socialsharing: SocialSharingManager
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface Navigator {
|
|
14
14
|
share: SocialSharingW3C
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
iPadPopupCoordinates: () => string
|
|
19
|
-
setIPadPopupCoordinates: (coords: string) => void
|
|
20
|
-
available: (callback: (available: boolean) => void) => void
|
|
21
|
-
shareWithOptions: (options: SocialSharingOptions, successCallback?: SocialSharingSuccessCallback<SocialSharingResult>, errorCallback?: SocialSharingErrorCallback) => void
|
|
22
|
-
shareW3C: SocialSharingW3C
|
|
23
|
-
share: (message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
|
|
24
|
-
shareViaTwitter: (message?: string, file?: string, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
|
|
25
|
-
shareViaFacebook: (message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
|
|
26
|
-
shareViaFacebookWithPasteMessageHint: (message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, pasteMessageHint?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
|
|
27
|
-
shareViaWhatsApp: (message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
|
|
28
|
-
shareViaWhatsAppToReceiver: (receiver?: string, message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
|
|
29
|
-
shareViaWhatsAppToPhone: (phone?: string, message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
|
|
30
|
-
shareViaSMS: (options?: SocialSharingOptions | string, phoneNumbers?: ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
|
|
31
|
-
shareViaEmail: (message?: string, subject?: string, toArray?: ArrayLike<string>, ccArray?: ArrayLike<string>, bccArray?: ArrayLike<string>, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
|
|
32
|
-
canShareVia: (via: string, message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
|
|
33
|
-
canShareViaEmail: (successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
|
|
34
|
-
shareViaInstagram: (message?: string, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
|
|
35
|
-
shareVia: (via: string, message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
|
|
36
|
-
saveToPhotoAlbum: (fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
type SocialSharingW3C = (shareData: SocialSharingW3CData) => Promise<SocialSharingResult>
|
|
40
|
-
|
|
41
|
-
interface SocialSharingW3CData {
|
|
42
|
-
title?: string
|
|
43
|
-
text?: string
|
|
44
|
-
url?: string
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface SocialSharingOptions {
|
|
17
|
+
export interface SocialSharingOptions {
|
|
48
18
|
message?: string
|
|
49
19
|
subject?: string
|
|
50
20
|
files?: ArrayLike<string>
|
|
@@ -53,10 +23,119 @@ interface SocialSharingOptions {
|
|
|
53
23
|
appPackageName?: string
|
|
54
24
|
}
|
|
55
25
|
|
|
56
|
-
|
|
57
|
-
type SocialSharingErrorCallback = (msg?: string) => void
|
|
58
|
-
|
|
59
|
-
interface SocialSharingResult {
|
|
26
|
+
export interface SocialSharingResult {
|
|
60
27
|
completed: boolean
|
|
61
28
|
app?: string
|
|
62
29
|
}
|
|
30
|
+
|
|
31
|
+
export interface SocialSharingW3CData {
|
|
32
|
+
title?: string
|
|
33
|
+
text?: string
|
|
34
|
+
url?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type SocialSharingW3C = (shareData: SocialSharingW3CData) => Promise<SocialSharingResult>
|
|
38
|
+
export type SocialSharingSuccessCallback<T> = (result: T) => void
|
|
39
|
+
export type SocialSharingErrorCallback = (msg?: string) => void
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Social Sharing Plugin Manager
|
|
43
|
+
* Direct access to the Cordova Social Sharing plugin
|
|
44
|
+
*/
|
|
45
|
+
export default class SocialSharingManager {
|
|
46
|
+
iPadPopupCoordinates: () => string
|
|
47
|
+
setIPadPopupCoordinates: (coords: string) => void
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Check if sharing is available
|
|
51
|
+
*/
|
|
52
|
+
available(callback: (available: boolean) => void): void
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Share with options (recommended)
|
|
56
|
+
*/
|
|
57
|
+
shareWithOptions(options: SocialSharingOptions, successCallback?: SocialSharingSuccessCallback<SocialSharingResult>, errorCallback?: SocialSharingErrorCallback): void
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* W3C-compliant share method
|
|
61
|
+
*/
|
|
62
|
+
shareW3C: SocialSharingW3C
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Generic share
|
|
66
|
+
*/
|
|
67
|
+
share(message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback): void
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Share via Twitter
|
|
71
|
+
*/
|
|
72
|
+
shareViaTwitter(message?: string, file?: string, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback): void
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Share via Facebook
|
|
76
|
+
*/
|
|
77
|
+
shareViaFacebook(message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback): void
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Share via Facebook with paste message hint
|
|
81
|
+
*/
|
|
82
|
+
shareViaFacebookWithPasteMessageHint(message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, pasteMessageHint?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback): void
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Share via WhatsApp
|
|
86
|
+
*/
|
|
87
|
+
shareViaWhatsApp(message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback): void
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Share via WhatsApp to specific receiver
|
|
91
|
+
*/
|
|
92
|
+
shareViaWhatsAppToReceiver(receiver?: string, message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback): void
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Share via WhatsApp to specific phone number
|
|
96
|
+
*/
|
|
97
|
+
shareViaWhatsAppToPhone(phone?: string, message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback): void
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Share via SMS
|
|
101
|
+
*/
|
|
102
|
+
shareViaSMS(options?: SocialSharingOptions | string, phoneNumbers?: ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback): void
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Share via Email
|
|
106
|
+
*/
|
|
107
|
+
shareViaEmail(message?: string, subject?: string, toArray?: ArrayLike<string>, ccArray?: ArrayLike<string>, bccArray?: ArrayLike<string>, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback): void
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Check if can share via specific app
|
|
111
|
+
*/
|
|
112
|
+
canShareVia(via: string, message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback): void
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Check if can share via email (native Mail app)
|
|
116
|
+
*/
|
|
117
|
+
canShareViaEmail(successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback): void
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Check if email clients are available (works with third-party apps like Gmail, Outlook)
|
|
121
|
+
*/
|
|
122
|
+
hasEmailClients(successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback): void
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Share via Instagram
|
|
126
|
+
*/
|
|
127
|
+
shareViaInstagram(message?: string, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback): void
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Share via specific app
|
|
131
|
+
*/
|
|
132
|
+
shareVia(via: string, message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback): void
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Save to photo album
|
|
136
|
+
*/
|
|
137
|
+
saveToPhotoAlbum(fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback): void
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Legacy type alias for backward compatibility
|
|
141
|
+
declare class SocialSharing extends SocialSharingManager {}
|
package/www/SocialSharing.js
CHANGED
|
@@ -107,6 +107,10 @@ SocialSharing.prototype.canShareViaEmail = function (successCallback, errorCallb
|
|
|
107
107
|
cordova.exec(successCallback, this._getErrorCallback(errorCallback, "canShareViaEmail"), "SocialSharing", "canShareViaEmail", []);
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
+
SocialSharing.prototype.hasEmailClients = function (successCallback, errorCallback) {
|
|
111
|
+
cordova.exec(successCallback, this._getErrorCallback(errorCallback, "hasEmailClients"), "SocialSharing", "hasEmailClients", []);
|
|
112
|
+
};
|
|
113
|
+
|
|
110
114
|
SocialSharing.prototype.shareViaInstagram = function (message, fileOrFileArray, successCallback, errorCallback) {
|
|
111
115
|
cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaInstagram"), "SocialSharing", "shareViaInstagram", [message, null, this._asArray(fileOrFileArray), null]);
|
|
112
116
|
};
|
|
@@ -138,20 +142,6 @@ SocialSharing.prototype._getErrorCallback = function (ecb, functionName) {
|
|
|
138
142
|
}
|
|
139
143
|
};
|
|
140
144
|
|
|
141
|
-
|
|
142
|
-
if (!window.plugins) {
|
|
143
|
-
window.plugins = {};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
window.plugins.socialsharing = new SocialSharing();
|
|
147
|
-
|
|
148
|
-
// Note only polyfill navigator.share if it is not defined, since shareW3C implements L1 of the spec,
|
|
149
|
-
// and an existing navigator.share method could implement L2.
|
|
150
|
-
if (!navigator.share) {
|
|
151
|
-
navigator.share = window.plugins.socialsharing.shareW3C;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return window.plugins.socialsharing;
|
|
155
|
-
};
|
|
145
|
+
var SocialSharingPlugin = new SocialSharing();
|
|
156
146
|
|
|
157
|
-
|
|
147
|
+
module.exports = SocialSharingPlugin;
|