share-to-whatsapp 0.0.1
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 +49 -0
- package/ShareToWhatsapp.podspec +17 -0
- package/android/build.gradle +58 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/pareshgami/shareto/Shareto.java +89 -0
- package/android/src/main/java/com/pareshgami/shareto/SharetoPlugin.java +77 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +47 -0
- package/dist/esm/definitions.d.ts +14 -0
- package/dist/esm/definitions.js +5 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +14 -0
- package/dist/esm/web.js +12 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +28 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +31 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Shareto.swift +8 -0
- package/ios/Plugin/SharetoPlugin.h +10 -0
- package/ios/Plugin/SharetoPlugin.m +8 -0
- package/ios/Plugin/SharetoPlugin.swift +18 -0
- package/package.json +78 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# share-to-whatsapp
|
|
2
|
+
|
|
3
|
+
The share-to-whatsapp plugin allows you to easily share images and PDF files directly to a specified WhatsApp number from your Ionic/Capacitor application.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install share-to-whatsapp
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`shareImage(...)`](#shareimage)
|
|
17
|
+
* [`sharePdf(...)`](#sharepdf)
|
|
18
|
+
|
|
19
|
+
</docgen-index>
|
|
20
|
+
|
|
21
|
+
<docgen-api>
|
|
22
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
23
|
+
|
|
24
|
+
### shareImage(...)
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
shareImage(options: { base64?: string; fileName?: string; phoneNumber?: string; message?: string; }) => Promise<void>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Param | Type |
|
|
31
|
+
| ------------- | -------------------------------------------------------------------------------------------- |
|
|
32
|
+
| **`options`** | <code>{ base64?: string; fileName?: string; phoneNumber?: string; message?: string; }</code> |
|
|
33
|
+
|
|
34
|
+
--------------------
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### sharePdf(...)
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
sharePdf(options: { base64?: string; fileName?: string; phoneNumber?: string; message?: string; }) => Promise<void>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Param | Type |
|
|
44
|
+
| ------------- | -------------------------------------------------------------------------------------------- |
|
|
45
|
+
| **`options`** | <code>{ base64?: string; fileName?: string; phoneNumber?: string; message?: string; }</code> |
|
|
46
|
+
|
|
47
|
+
--------------------
|
|
48
|
+
|
|
49
|
+
</docgen-api>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'ShareToWhatsapp'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:7.2.1'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.pareshgami.shareto"
|
|
22
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
package com.pareshgami.shareto;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.net.Uri;
|
|
6
|
+
import android.util.Base64;
|
|
7
|
+
import android.util.Log;
|
|
8
|
+
import androidx.core.content.FileProvider;
|
|
9
|
+
import java.io.File;
|
|
10
|
+
import java.io.FileOutputStream;
|
|
11
|
+
import java.io.IOException;
|
|
12
|
+
import java.util.UUID;
|
|
13
|
+
import android.widget.Toast;
|
|
14
|
+
|
|
15
|
+
public class Shareto {
|
|
16
|
+
|
|
17
|
+
private static final String TAG = "Shareto";
|
|
18
|
+
private Context context;
|
|
19
|
+
|
|
20
|
+
public Shareto(Context context) {
|
|
21
|
+
this.context = context;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public void shareImage(String base64, String fileName, String phoneNumber, String message) throws IOException {
|
|
25
|
+
if (base64 == null && message == null) {
|
|
26
|
+
throw new IllegalArgumentException("Either base64 string or message is required.");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
File imageFile = base64 != null ? saveBase64ToFile(base64, fileName != null ? fileName : UUID.randomUUID().toString() + ".png") : null;
|
|
30
|
+
Uri imageUri = imageFile != null ? FileProvider.getUriForFile(
|
|
31
|
+
context,
|
|
32
|
+
context.getPackageName() + ".fileprovider",
|
|
33
|
+
imageFile
|
|
34
|
+
) : null;
|
|
35
|
+
shareFile(imageUri, "image/*", phoneNumber, message);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public void sharePdf(String base64, String fileName, String phoneNumber, String message) throws IOException {
|
|
39
|
+
if (base64 == null && message == null) {
|
|
40
|
+
throw new IllegalArgumentException("Either base64 string or message is required.");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Log the message
|
|
44
|
+
Log.i(TAG, "Sharing PDF with message: " + message);
|
|
45
|
+
|
|
46
|
+
File pdfFile = base64 != null ? saveBase64ToFile(base64, fileName != null ? fileName : UUID.randomUUID().toString() + ".pdf") : null;
|
|
47
|
+
Uri pdfUri = pdfFile != null ? FileProvider.getUriForFile(
|
|
48
|
+
context,
|
|
49
|
+
context.getPackageName() + ".fileprovider",
|
|
50
|
+
pdfFile
|
|
51
|
+
) : null;
|
|
52
|
+
shareFile(pdfUri, "application/pdf", phoneNumber, message);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private File saveBase64ToFile(String base64Data, String fileName) throws IOException {
|
|
56
|
+
byte[] decodedBytes = Base64.decode(base64Data.split(",")[1], Base64.DEFAULT);
|
|
57
|
+
File directory = context.getExternalFilesDir(null);
|
|
58
|
+
File file = new File(directory, fileName);
|
|
59
|
+
try (FileOutputStream fos = new FileOutputStream(file)) {
|
|
60
|
+
fos.write(decodedBytes);
|
|
61
|
+
}
|
|
62
|
+
return file;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private void shareFile(Uri fileUri, String mimeType, String phoneNumber, String message) {
|
|
66
|
+
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
|
67
|
+
if (fileUri != null) {
|
|
68
|
+
shareIntent.setType(mimeType);
|
|
69
|
+
shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
|
70
|
+
} else {
|
|
71
|
+
shareIntent.setType("text/plain");
|
|
72
|
+
}
|
|
73
|
+
if (message != null) {
|
|
74
|
+
shareIntent.putExtra(Intent.EXTRA_TEXT, message);
|
|
75
|
+
}
|
|
76
|
+
shareIntent.setPackage("com.whatsapp.w4b");
|
|
77
|
+
if (phoneNumber != null && !phoneNumber.isEmpty()) {
|
|
78
|
+
shareIntent.putExtra("jid", phoneNumber + "@s.whatsapp.net");
|
|
79
|
+
}
|
|
80
|
+
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
context.startActivity(Intent.createChooser(shareIntent, "Share with"));
|
|
84
|
+
} catch (android.content.ActivityNotFoundException e) {
|
|
85
|
+
e.printStackTrace();
|
|
86
|
+
Toast.makeText(context, "No app found to handle this action", Toast.LENGTH_SHORT).show();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// package com.pareshgami.shareto;
|
|
2
|
+
|
|
3
|
+
// import com.getcapacitor.JSObject;
|
|
4
|
+
// import com.getcapacitor.Plugin;
|
|
5
|
+
// import com.getcapacitor.PluginCall;
|
|
6
|
+
// import com.getcapacitor.PluginMethod;
|
|
7
|
+
// import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
|
+
|
|
9
|
+
// @CapacitorPlugin(name = "Shareto")
|
|
10
|
+
// public class SharetoPlugin extends Plugin {
|
|
11
|
+
|
|
12
|
+
// private Shareto implementation = new Shareto();
|
|
13
|
+
|
|
14
|
+
// @PluginMethod
|
|
15
|
+
// public void echo(PluginCall call) {
|
|
16
|
+
// String value = call.getString("value");
|
|
17
|
+
|
|
18
|
+
// JSObject ret = new JSObject();
|
|
19
|
+
// ret.put("value", implementation.echo(value));
|
|
20
|
+
// call.resolve(ret);
|
|
21
|
+
// }
|
|
22
|
+
// }
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
package com.pareshgami.shareto;
|
|
26
|
+
|
|
27
|
+
import com.getcapacitor.JSObject;
|
|
28
|
+
import com.getcapacitor.Plugin;
|
|
29
|
+
import com.getcapacitor.PluginCall;
|
|
30
|
+
import com.getcapacitor.PluginMethod;
|
|
31
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
32
|
+
import java.io.IOException;
|
|
33
|
+
|
|
34
|
+
@CapacitorPlugin(name = "Shareto")
|
|
35
|
+
public class SharetoPlugin extends Plugin {
|
|
36
|
+
|
|
37
|
+
private Shareto implementation;
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public void load() {
|
|
41
|
+
implementation = new Shareto(getContext());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@PluginMethod
|
|
45
|
+
public void shareImage(PluginCall call) {
|
|
46
|
+
String base64 = call.getString("base64");
|
|
47
|
+
String fileName = call.getString("fileName");
|
|
48
|
+
String phoneNumber = call.getString("phoneNumber");
|
|
49
|
+
String message = call.getString("message");
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
implementation.shareImage(base64, fileName, phoneNumber, message);
|
|
53
|
+
call.resolve();
|
|
54
|
+
} catch (IOException e) {
|
|
55
|
+
call.reject("Error sharing image: " + e.getMessage());
|
|
56
|
+
} catch (IllegalArgumentException e) {
|
|
57
|
+
call.reject(e.getMessage());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@PluginMethod
|
|
62
|
+
public void sharePdf(PluginCall call) {
|
|
63
|
+
String base64 = call.getString("base64");
|
|
64
|
+
String fileName = call.getString("fileName");
|
|
65
|
+
String phoneNumber = call.getString("phoneNumber");
|
|
66
|
+
String message = call.getString("message");
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
implementation.sharePdf(base64, fileName, phoneNumber, message);
|
|
70
|
+
call.resolve();
|
|
71
|
+
} catch (IOException e) {
|
|
72
|
+
call.reject("Error sharing PDF: " + e.getMessage());
|
|
73
|
+
} catch (IllegalArgumentException e) {
|
|
74
|
+
call.reject(e.getMessage());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "SharetoPlugin",
|
|
4
|
+
"slug": "sharetoplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "shareImage",
|
|
10
|
+
"signature": "(options: { base64?: string; fileName?: string; phoneNumber?: string; message?: string; }) => Promise<void>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "{ base64?: string | undefined; fileName?: string | undefined; phoneNumber?: string | undefined; message?: string | undefined; }"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<void>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "",
|
|
21
|
+
"complexTypes": [],
|
|
22
|
+
"slug": "shareimage"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "sharePdf",
|
|
26
|
+
"signature": "(options: { base64?: string; fileName?: string; phoneNumber?: string; message?: string; }) => Promise<void>",
|
|
27
|
+
"parameters": [
|
|
28
|
+
{
|
|
29
|
+
"name": "options",
|
|
30
|
+
"docs": "",
|
|
31
|
+
"type": "{ base64?: string | undefined; fileName?: string | undefined; phoneNumber?: string | undefined; message?: string | undefined; }"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"returns": "Promise<void>",
|
|
35
|
+
"tags": [],
|
|
36
|
+
"docs": "",
|
|
37
|
+
"complexTypes": [],
|
|
38
|
+
"slug": "sharepdf"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"properties": []
|
|
42
|
+
},
|
|
43
|
+
"interfaces": [],
|
|
44
|
+
"enums": [],
|
|
45
|
+
"typeAliases": [],
|
|
46
|
+
"pluginConfigs": []
|
|
47
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SharetoPlugin {
|
|
2
|
+
shareImage(options: {
|
|
3
|
+
base64?: string;
|
|
4
|
+
fileName?: string;
|
|
5
|
+
phoneNumber?: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
sharePdf(options: {
|
|
9
|
+
base64?: string;
|
|
10
|
+
fileName?: string;
|
|
11
|
+
phoneNumber?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kEAAkE;AAClE,IAAI","sourcesContent":["// export interface SharetoPlugin {\n// echo(options: { value: string }): Promise<{ value: string }>;\n// }\n\n\nexport interface SharetoPlugin {\n shareImage(options: { base64?: string, fileName?: string, phoneNumber?: string, message?: string }): Promise<void>;\n sharePdf(options: { base64?: string, fileName?: string, phoneNumber?: string, message?: string }): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,OAAO,GAAG,cAAc,CAAgB,SAAS,EAAE;IACvD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;CACzD,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { SharetoPlugin } from './definitions';\n\nconst Shareto = registerPlugin<SharetoPlugin>('Shareto', {\n web: () => import('./web').then(m => new m.SharetoWeb()),\n});\n\nexport * from './definitions';\nexport { Shareto };\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { SharetoPlugin } from './definitions';
|
|
3
|
+
export declare class SharetoWeb extends WebPlugin implements SharetoPlugin {
|
|
4
|
+
shareImage(options: {
|
|
5
|
+
base64: string;
|
|
6
|
+
fileName?: string;
|
|
7
|
+
phoneNumber: string;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
sharePdf(options: {
|
|
10
|
+
base64: string;
|
|
11
|
+
fileName?: string;
|
|
12
|
+
phoneNumber: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class SharetoWeb extends WebPlugin {
|
|
3
|
+
async shareImage(options) {
|
|
4
|
+
console.log('shareImage', options);
|
|
5
|
+
// Implement web sharing logic if needed
|
|
6
|
+
}
|
|
7
|
+
async sharePdf(options) {
|
|
8
|
+
console.log('sharePdf', options);
|
|
9
|
+
// Implement web sharing logic if needed
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,UAAW,SAAQ,SAAS;IACvC,KAAK,CAAC,UAAU,CAAC,OAAmE;QAClF,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,wCAAwC;IAC1C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAmE;QAChF,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACjC,wCAAwC;IAC1C,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { SharetoPlugin } from './definitions';\n\nexport class SharetoWeb extends WebPlugin implements SharetoPlugin {\n async shareImage(options: { base64: string; fileName?: string; phoneNumber: string }): Promise<void> {\n console.log('shareImage', options);\n // Implement web sharing logic if needed\n }\n\n async sharePdf(options: { base64: string; fileName?: string; phoneNumber: string }): Promise<void> {\n console.log('sharePdf', options);\n // Implement web sharing logic if needed\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const Shareto = core.registerPlugin('Shareto', {
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.SharetoWeb()),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
class SharetoWeb extends core.WebPlugin {
|
|
12
|
+
async shareImage(options) {
|
|
13
|
+
console.log('shareImage', options);
|
|
14
|
+
// Implement web sharing logic if needed
|
|
15
|
+
}
|
|
16
|
+
async sharePdf(options) {
|
|
17
|
+
console.log('sharePdf', options);
|
|
18
|
+
// Implement web sharing logic if needed
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
23
|
+
__proto__: null,
|
|
24
|
+
SharetoWeb: SharetoWeb
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
exports.Shareto = Shareto;
|
|
28
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Shareto = registerPlugin('Shareto', {\n web: () => import('./web').then(m => new m.SharetoWeb()),\n});\nexport * from './definitions';\nexport { Shareto };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class SharetoWeb extends WebPlugin {\n async shareImage(options) {\n console.log('shareImage', options);\n // Implement web sharing logic if needed\n }\n async sharePdf(options) {\n console.log('sharePdf', options);\n // Implement web sharing logic if needed\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;AAC1C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;AAC5D,CAAC;;ACFM,MAAM,UAAU,SAASC,cAAS,CAAC;AAC1C,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;AAC9B,QAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC3C;AACA,KAAK;AACL,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACzC;AACA,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var capacitorShareto = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Shareto = core.registerPlugin('Shareto', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.SharetoWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class SharetoWeb extends core.WebPlugin {
|
|
9
|
+
async shareImage(options) {
|
|
10
|
+
console.log('shareImage', options);
|
|
11
|
+
// Implement web sharing logic if needed
|
|
12
|
+
}
|
|
13
|
+
async sharePdf(options) {
|
|
14
|
+
console.log('sharePdf', options);
|
|
15
|
+
// Implement web sharing logic if needed
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
20
|
+
__proto__: null,
|
|
21
|
+
SharetoWeb: SharetoWeb
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
exports.Shareto = Shareto;
|
|
25
|
+
|
|
26
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
27
|
+
|
|
28
|
+
return exports;
|
|
29
|
+
|
|
30
|
+
})({}, capacitorExports);
|
|
31
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Shareto = registerPlugin('Shareto', {\n web: () => import('./web').then(m => new m.SharetoWeb()),\n});\nexport * from './definitions';\nexport { Shareto };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class SharetoWeb extends WebPlugin {\n async shareImage(options) {\n console.log('shareImage', options);\n // Implement web sharing logic if needed\n }\n async sharePdf(options) {\n console.log('sharePdf', options);\n // Implement web sharing logic if needed\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,OAAO,GAAGA,mBAAc,CAAC,SAAS,EAAE;IAC1C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5D,CAAC;;ICFM,MAAM,UAAU,SAASC,cAAS,CAAC;IAC1C,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE;IAC9B,QAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3C;IACA,KAAK;IACL,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACzC;IACA,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
//! Project version number for Plugin.
|
|
4
|
+
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
+
|
|
6
|
+
//! Project version string for Plugin.
|
|
7
|
+
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
+
|
|
9
|
+
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <Capacitor/Capacitor.h>
|
|
3
|
+
|
|
4
|
+
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
+
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
+
CAP_PLUGIN(SharetoPlugin, "Shareto",
|
|
7
|
+
CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
|
|
8
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
6
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
|
+
*/
|
|
8
|
+
@objc(SharetoPlugin)
|
|
9
|
+
public class SharetoPlugin: CAPPlugin {
|
|
10
|
+
private let implementation = Shareto()
|
|
11
|
+
|
|
12
|
+
@objc func echo(_ call: CAPPluginCall) {
|
|
13
|
+
let value = call.getString("value") ?? ""
|
|
14
|
+
call.resolve([
|
|
15
|
+
"value": implementation.echo(value)
|
|
16
|
+
])
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "share-to-whatsapp",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "The share-to-whatsapp plugin allows you to easily share images and PDF files directly to a specified WhatsApp number from your Ionic/Capacitor application.",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Plugin/",
|
|
14
|
+
"ShareToWhatsapp.podspec"
|
|
15
|
+
],
|
|
16
|
+
"author": "Paresh Gami",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/ruhiverse-official/share-to-whatsapp.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/ruhiverse-official/share-to-whatsapp/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"capacitor",
|
|
27
|
+
"plugin",
|
|
28
|
+
"native"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
32
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
|
|
33
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
34
|
+
"verify:web": "npm run build",
|
|
35
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
36
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
37
|
+
"eslint": "eslint . --ext ts",
|
|
38
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
39
|
+
"swiftlint": "node-swiftlint",
|
|
40
|
+
"docgen": "docgen --api SharetoPlugin --output-readme README.md --output-json dist/docs.json",
|
|
41
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
|
42
|
+
"clean": "rimraf ./dist",
|
|
43
|
+
"watch": "tsc --watch",
|
|
44
|
+
"prepublishOnly": "npm run build"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@capacitor/android": "^4.0.0",
|
|
48
|
+
"@capacitor/core": "^4.0.0",
|
|
49
|
+
"@capacitor/docgen": "^0.0.18",
|
|
50
|
+
"@capacitor/ios": "^4.0.0",
|
|
51
|
+
"@ionic/eslint-config": "^0.3.0",
|
|
52
|
+
"@ionic/prettier-config": "^1.0.1",
|
|
53
|
+
"@ionic/swiftlint-config": "^1.1.2",
|
|
54
|
+
"eslint": "^7.11.0",
|
|
55
|
+
"prettier": "~2.3.0",
|
|
56
|
+
"prettier-plugin-java": "~1.0.2",
|
|
57
|
+
"rimraf": "^3.0.2",
|
|
58
|
+
"rollup": "^2.32.0",
|
|
59
|
+
"swiftlint": "^1.0.1",
|
|
60
|
+
"typescript": "~4.1.5"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@capacitor/core": "^4.0.0"
|
|
64
|
+
},
|
|
65
|
+
"prettier": "@ionic/prettier-config",
|
|
66
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
67
|
+
"eslintConfig": {
|
|
68
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
69
|
+
},
|
|
70
|
+
"capacitor": {
|
|
71
|
+
"ios": {
|
|
72
|
+
"src": "ios"
|
|
73
|
+
},
|
|
74
|
+
"android": {
|
|
75
|
+
"src": "android"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|