@hanwha-ss1/plugin 0.5.3 → 0.5.5
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/android/src/main/java/com/plugin/download/FileDownload.java +130 -0
- package/android/src/main/java/com/plugin/download/FileDownloadPlugin.java +21 -0
- package/android/src/main/java/com/plugin/linker/LinkerPlugin.java +31 -0
- package/dist/esm/definitions.d.ts +9 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Download/DownloadPlugin.swift +50 -0
- package/ios/Plugin/EdgeSwipe/EdgeSwipePlugin.swift +0 -2
- package/ios/Plugin/OpenBrowser/ViewController.swift +3 -0
- package/ios/Plugin/Plugin.m +1 -0
- package/ios/Plugin/Plugin.swift +4 -0
- package/package.json +1 -1
- package/ios/Plugin/EdgeSwipe/EdgeSwipeService.swift +0 -10
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
package com.plugin.download;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.ContentValues;
|
|
5
|
+
import android.net.Uri;
|
|
6
|
+
import android.os.Build;
|
|
7
|
+
import android.os.Environment;
|
|
8
|
+
import android.provider.MediaStore;
|
|
9
|
+
import android.util.Log;
|
|
10
|
+
|
|
11
|
+
import java.io.File;
|
|
12
|
+
import java.io.FileOutputStream;
|
|
13
|
+
import java.io.IOException;
|
|
14
|
+
import java.io.OutputStream;
|
|
15
|
+
import java.net.URLConnection;
|
|
16
|
+
|
|
17
|
+
public class FileDownload {
|
|
18
|
+
|
|
19
|
+
public String echo(String value) {
|
|
20
|
+
Log.i("Echo", value);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public interface OnResult {
|
|
25
|
+
void onSuccess(String path);
|
|
26
|
+
void onFail(String message);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public void download(Activity activity, String params, OnResult result) {
|
|
30
|
+
if(params != null ) {
|
|
31
|
+
fileDownload(activity, params, result);
|
|
32
|
+
} else {
|
|
33
|
+
if(result != null) {
|
|
34
|
+
result.onFail("잘못 된 파라미터 입니다.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
private void fileDownload(Activity activity, String param, OnResult result){
|
|
41
|
+
|
|
42
|
+
String[] strArray = param.split(";");
|
|
43
|
+
String fileName = strArray[0];
|
|
44
|
+
|
|
45
|
+
String base64BinaryString = param.replace(fileName + ";","");
|
|
46
|
+
base64BinaryString= base64BinaryString.replace("data:application/octet-stream;base64,","");
|
|
47
|
+
|
|
48
|
+
byte[] decodedString = android.util.Base64.decode(base64BinaryString, android.util.Base64.DEFAULT);
|
|
49
|
+
|
|
50
|
+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
|
|
51
|
+
ContentValues values = new ContentValues();
|
|
52
|
+
|
|
53
|
+
//2022.03.13 sangsik : mimeType이 application/octet-stream 으로만 전달되므로 사용불가하여 파일 확장자로 구분
|
|
54
|
+
String mimeType = URLConnection.guessContentTypeFromName(fileName);
|
|
55
|
+
|
|
56
|
+
Uri uri;
|
|
57
|
+
if(null != mimeType && mimeType.contains("image/")){
|
|
58
|
+
values.put(MediaStore.Images.Media.DISPLAY_NAME, fileName);
|
|
59
|
+
values.put(MediaStore.Images.Media.MIME_TYPE, mimeType);
|
|
60
|
+
values.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES);
|
|
61
|
+
uri = activity.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
|
62
|
+
} else if(null != mimeType && mimeType.contains("audio/")) {
|
|
63
|
+
values.put(MediaStore.Audio.Media.DISPLAY_NAME, fileName);
|
|
64
|
+
values.put(MediaStore.Audio.Media.MIME_TYPE, mimeType);
|
|
65
|
+
values.put(MediaStore.Audio.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES);
|
|
66
|
+
uri = activity.getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values);
|
|
67
|
+
} else if(null != mimeType && mimeType.contains("video/")) {
|
|
68
|
+
values.put(MediaStore.Video.Media.DISPLAY_NAME, fileName);
|
|
69
|
+
values.put(MediaStore.Video.Media.MIME_TYPE, mimeType);
|
|
70
|
+
values.put(MediaStore.Video.Media.RELATIVE_PATH, Environment.DIRECTORY_MOVIES);
|
|
71
|
+
uri = activity.getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);
|
|
72
|
+
} else {
|
|
73
|
+
values.put(MediaStore.Downloads.DISPLAY_NAME, fileName);
|
|
74
|
+
values.put(MediaStore.Downloads.MIME_TYPE, mimeType);
|
|
75
|
+
values.put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS);
|
|
76
|
+
uri = activity.getContentResolver().insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, values);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if(uri != null) {
|
|
80
|
+
OutputStream imageOutStream = null;
|
|
81
|
+
try {
|
|
82
|
+
imageOutStream = activity.getContentResolver().openOutputStream(uri);
|
|
83
|
+
if(imageOutStream != null) {
|
|
84
|
+
imageOutStream.write(decodedString);
|
|
85
|
+
} else {
|
|
86
|
+
Log.e(getClass().getSimpleName(), "imageOutStream is null");
|
|
87
|
+
}
|
|
88
|
+
} catch (IOException e) {
|
|
89
|
+
Log.e(getClass().getSimpleName(), e.getMessage());
|
|
90
|
+
} finally {
|
|
91
|
+
try {
|
|
92
|
+
if(imageOutStream != null) {
|
|
93
|
+
imageOutStream.close();
|
|
94
|
+
}
|
|
95
|
+
} catch (IOException e) {
|
|
96
|
+
Log.e(getClass().getSimpleName(), e.getMessage());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
Log.e(getClass().getSimpleName(), "url is null");
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
File file= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
|
104
|
+
File dest = new File(file, fileName);
|
|
105
|
+
FileOutputStream out = null;
|
|
106
|
+
try {
|
|
107
|
+
out = new FileOutputStream(dest);
|
|
108
|
+
out.write(decodedString);
|
|
109
|
+
out.flush();
|
|
110
|
+
out.close();
|
|
111
|
+
if(result != null) {
|
|
112
|
+
result.onSuccess(dest.getAbsolutePath());
|
|
113
|
+
}
|
|
114
|
+
} catch (Exception e) {
|
|
115
|
+
// e.printStackTrace();
|
|
116
|
+
if(result != null) {
|
|
117
|
+
result.onFail("파일 다운로드에 실패하였습니다.");
|
|
118
|
+
}
|
|
119
|
+
} finally {
|
|
120
|
+
if(out != null) {
|
|
121
|
+
try {
|
|
122
|
+
out.close();
|
|
123
|
+
} catch (IOException e) {
|
|
124
|
+
Log.e(getClass().getSimpleName(), e.getMessage());
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.plugin.download;
|
|
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 = "Plugin")
|
|
10
|
+
public class FileDownloadPlugin extends Plugin {
|
|
11
|
+
private FileDownload implementation = new FileDownload();
|
|
12
|
+
|
|
13
|
+
@PluginMethod
|
|
14
|
+
public void echo(PluginCall call) {
|
|
15
|
+
String value = call.getString("value");
|
|
16
|
+
|
|
17
|
+
JSObject ret = new JSObject();
|
|
18
|
+
ret.put("value", implementation.echo(value));
|
|
19
|
+
call.resolve(ret);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -7,6 +7,7 @@ import com.getcapacitor.PluginMethod;
|
|
|
7
7
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
8
8
|
import com.plugin.bio.Bio;
|
|
9
9
|
import com.plugin.contact.Contact;
|
|
10
|
+
import com.plugin.download.FileDownload;
|
|
10
11
|
import com.plugin.openbrowser.OpenBrowser;
|
|
11
12
|
import com.plugin.opencamera.OpenCamera;
|
|
12
13
|
|
|
@@ -18,6 +19,7 @@ public class LinkerPlugin extends Plugin{
|
|
|
18
19
|
private Contact contactImplementation = new Contact();
|
|
19
20
|
private OpenBrowser openBrowserImplementation = new OpenBrowser();
|
|
20
21
|
private OpenCamera openCameraImplementation = new OpenCamera();
|
|
22
|
+
private FileDownload fileDownloadImplementation = new FileDownload();
|
|
21
23
|
|
|
22
24
|
@PluginMethod
|
|
23
25
|
public void echo(PluginCall call) {
|
|
@@ -126,4 +128,33 @@ public class LinkerPlugin extends Plugin{
|
|
|
126
128
|
}
|
|
127
129
|
openCameraImplementation.openCamera(getActivity());
|
|
128
130
|
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@PluginMethod
|
|
135
|
+
public void fileDownload(PluginCall call) {
|
|
136
|
+
|
|
137
|
+
String file = call.getString("file");
|
|
138
|
+
|
|
139
|
+
if(fileDownloadImplementation == null) {
|
|
140
|
+
fileDownloadImplementation = new FileDownload();
|
|
141
|
+
}
|
|
142
|
+
fileDownloadImplementation.download(getActivity(), file, new FileDownload.OnResult() {
|
|
143
|
+
@Override
|
|
144
|
+
public void onSuccess(String path) {
|
|
145
|
+
JSObject ret = new JSObject();
|
|
146
|
+
ret.put("result", true);
|
|
147
|
+
ret.put("message", "완료");
|
|
148
|
+
call.resolve(ret);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@Override
|
|
152
|
+
public void onFail(String message) {
|
|
153
|
+
JSObject ret = new JSObject();
|
|
154
|
+
ret.put("result", false);
|
|
155
|
+
ret.put("message", message);
|
|
156
|
+
call.resolve(ret);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
129
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Plugin {\n /**\n * 앱 실행\n * @param options package : 패키지명\n */\n executeApp(options: {\n package: string;\n }): Promise<{ value: string }>;\n\n /**\n * 연락처 저장\n * @param options name : 성명\n * @param options phone : 전화번호\n * @param options email : 이메일\n * @param options dept : 소속\n * @param options ext : 내선번호\n */\n addContact(options: {\n name: string;\n phone: string;\n email: string;\n dept: string;\n ext: string;\n }): Promise<{ value: string }>;\n\n /**\n * TouchID, FaceID\n */\n auth(): Promise<{ value: string }>;\n\n /**\n * 시스템에 설정된 지역이 서울인지 확인\n */\n checkSeoulTimeZone(): Promise<{ value: string }>;\n\n timezone(): Promise<{ value: string }>;\n\n /**\n *\n * @param options url : \"웹 페이지 주소\"\n * @param options ext : false(내부 웹뷰), true(외부 브라우저)\n */\n open(options: { url: string; ext: boolean; isCloseBtn?: boolean; clear?: boolean }): Promise<{ value: string }>;\n\n /**\n * EdgeSwipe 허용\n * @see default false\n */\n edgeSwipe(options: {on: boolean}): Promise<{ value: string }>;\n\n\n /**\n * 카메라앱 열기\n * @see default false\n */\n openCamera(): Promise<{ value: string }>;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Plugin {\n /**\n * 앱 실행\n * @param options package : 패키지명\n */\n executeApp(options: {\n package: string;\n }): Promise<{ value: string }>;\n\n /**\n * 연락처 저장\n * @param options name : 성명\n * @param options phone : 전화번호\n * @param options email : 이메일\n * @param options dept : 소속\n * @param options ext : 내선번호\n */\n addContact(options: {\n name: string;\n phone: string;\n email: string;\n dept: string;\n ext: string;\n }): Promise<{ value: string }>;\n\n /**\n * TouchID, FaceID\n */\n auth(): Promise<{ value: string }>;\n\n /**\n * 시스템에 설정된 지역이 서울인지 확인\n */\n checkSeoulTimeZone(): Promise<{ value: string }>;\n\n timezone(): Promise<{ value: string }>;\n\n /**\n *\n * @param options url : \"웹 페이지 주소\"\n * @param options ext : false(내부 웹뷰), true(외부 브라우저)\n */\n open(options: { url: string; ext: boolean; isCloseBtn?: boolean; clear?: boolean }): Promise<{ value: string }>;\n\n /**\n * EdgeSwipe 허용\n * @see default false\n */\n edgeSwipe(options: {on: boolean}): Promise<{ value: string }>;\n\n\n /**\n * 카메라앱 열기\n * @see default false\n */\n openCamera(): Promise<{ value: string }>;\n\n\n /**\n * 파일 다운로드\n * @see default false\n */\n fileDownload(options: {file: string; }): Promise<{ value: string }>;\n}\n\n"]}
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAGrD,MAAM,OAAO,SAAU,SAAQ,SAAS;IAEtC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAA8E;QACvF,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAAyB;QACvC,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;YACrC,OAAO,OAAO,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC;SAC9D;QACD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {Capacitor, WebPlugin} from '@capacitor/core';\nimport type {Plugin} from './definitions';\n\nexport class PluginWeb extends WebPlugin implements Plugin {\n\n async executeApp(): Promise<any> {\n return { results: {} };\n }\n\n async addContact(): Promise<any> {\n return { results: {} };\n }\n\n async auth(): Promise<any> {\n return { results: {} };\n }\n\n async checkSeoulTimeZone(): Promise<any> {\n return { results: {} };\n }\n\n async timezone(): Promise<any> {\n return { results: {} };\n }\n\n async open(_options: { url: string, ext: boolean, isCloseBtn?: boolean; clear?: boolean }): Promise<any> {\n return { results: {} };\n }\n\n async edgeSwipe(_options: { on: boolean }): Promise<any> {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('edgeSwipe is only supported on iOS.');\n }\n return { results: {} };\n }\n\n async openCamera(): Promise<any> {\n return { results: {} };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAGrD,MAAM,OAAO,SAAU,SAAQ,SAAS;IAEtC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAA8E;QACvF,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAAyB;QACvC,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;YACrC,OAAO,OAAO,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC;SAC9D;QACD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAyB;QAC1C,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {Capacitor, WebPlugin} from '@capacitor/core';\nimport type {Plugin} from './definitions';\n\nexport class PluginWeb extends WebPlugin implements Plugin {\n\n async executeApp(): Promise<any> {\n return { results: {} };\n }\n\n async addContact(): Promise<any> {\n return { results: {} };\n }\n\n async auth(): Promise<any> {\n return { results: {} };\n }\n\n async checkSeoulTimeZone(): Promise<any> {\n return { results: {} };\n }\n\n async timezone(): Promise<any> {\n return { results: {} };\n }\n\n async open(_options: { url: string, ext: boolean, isCloseBtn?: boolean; clear?: boolean }): Promise<any> {\n return { results: {} };\n }\n\n async edgeSwipe(_options: { on: boolean }): Promise<any> {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('edgeSwipe is only supported on iOS.');\n }\n return { results: {} };\n }\n\n async openCamera(): Promise<any> {\n return { results: {} };\n }\n\n async fileDownload(_options: { file: string}): Promise<any> {\n return { results: {} };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst HanwhaPlugin = registerPlugin('Plugin', {\n web: () => import('./web').then(m => new m.PluginWeb()),\n});\nexport * from './definitions';\nexport { HanwhaPlugin };\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Capacitor, WebPlugin } from '@capacitor/core';\nexport class PluginWeb extends WebPlugin {\n async executeApp() {\n return { results: {} };\n }\n async addContact() {\n return { results: {} };\n }\n async auth() {\n return { results: {} };\n }\n async checkSeoulTimeZone() {\n return { results: {} };\n }\n async timezone() {\n return { results: {} };\n }\n async open(_options) {\n return { results: {} };\n }\n async edgeSwipe(_options) {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('edgeSwipe is only supported on iOS.');\n }\n return { results: {} };\n }\n async openCamera() {\n return { results: {} };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","Capacitor"],"mappings":";;;;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC3D,CAAC;;ACHD;AAEO,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;AACzB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;AAC9B,QAAQ,IAAIC,cAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;AAC/C,YAAY,OAAO,OAAO,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC;AACzE,SAAS;AACT,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst HanwhaPlugin = registerPlugin('Plugin', {\n web: () => import('./web').then(m => new m.PluginWeb()),\n});\nexport * from './definitions';\nexport { HanwhaPlugin };\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Capacitor, WebPlugin } from '@capacitor/core';\nexport class PluginWeb extends WebPlugin {\n async executeApp() {\n return { results: {} };\n }\n async addContact() {\n return { results: {} };\n }\n async auth() {\n return { results: {} };\n }\n async checkSeoulTimeZone() {\n return { results: {} };\n }\n async timezone() {\n return { results: {} };\n }\n async open(_options) {\n return { results: {} };\n }\n async edgeSwipe(_options) {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('edgeSwipe is only supported on iOS.');\n }\n return { results: {} };\n }\n async openCamera() {\n return { results: {} };\n }\n async fileDownload(_options) {\n return { results: {} };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","Capacitor"],"mappings":";;;;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC3D,CAAC;;ACHD;AAEO,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;AACzB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;AAC9B,QAAQ,IAAIC,cAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;AAC/C,YAAY,OAAO,OAAO,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC;AACzE,SAAS;AACT,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;AACjC,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst HanwhaPlugin = registerPlugin('Plugin', {\n web: () => import('./web').then(m => new m.PluginWeb()),\n});\nexport * from './definitions';\nexport { HanwhaPlugin };\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Capacitor, WebPlugin } from '@capacitor/core';\nexport class PluginWeb extends WebPlugin {\n async executeApp() {\n return { results: {} };\n }\n async addContact() {\n return { results: {} };\n }\n async auth() {\n return { results: {} };\n }\n async checkSeoulTimeZone() {\n return { results: {} };\n }\n async timezone() {\n return { results: {} };\n }\n async open(_options) {\n return { results: {} };\n }\n async edgeSwipe(_options) {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('edgeSwipe is only supported on iOS.');\n }\n return { results: {} };\n }\n async openCamera() {\n return { results: {} };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","Capacitor"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,CAAC;;ICHD;IAEO,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,QAAQ,GAAG;IACrB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;IACzB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;IAC9B,QAAQ,IAAIC,cAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;IAC/C,YAAY,OAAO,OAAO,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC;IACzE,SAAS;IACT,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst HanwhaPlugin = registerPlugin('Plugin', {\n web: () => import('./web').then(m => new m.PluginWeb()),\n});\nexport * from './definitions';\nexport { HanwhaPlugin };\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Capacitor, WebPlugin } from '@capacitor/core';\nexport class PluginWeb extends WebPlugin {\n async executeApp() {\n return { results: {} };\n }\n async addContact() {\n return { results: {} };\n }\n async auth() {\n return { results: {} };\n }\n async checkSeoulTimeZone() {\n return { results: {} };\n }\n async timezone() {\n return { results: {} };\n }\n async open(_options) {\n return { results: {} };\n }\n async edgeSwipe(_options) {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('edgeSwipe is only supported on iOS.');\n }\n return { results: {} };\n }\n async openCamera() {\n return { results: {} };\n }\n async fileDownload(_options) {\n return { results: {} };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin","Capacitor"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,CAAC;;ICHD;IAEO,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,QAAQ,GAAG;IACrB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;IACzB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;IAC9B,QAAQ,IAAIC,cAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;IAC/C,YAAY,OAAO,OAAO,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC;IACzE,SAAS;IACT,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
import Foundation
|
|
3
|
+
import Capacitor
|
|
4
|
+
|
|
5
|
+
public class DownloadPlugin: CAPPlugin {
|
|
6
|
+
|
|
7
|
+
@objc public func doDownload(_ call: CAPPluginCall, _bridge: CAPBridgeProtocol) {
|
|
8
|
+
let body = call.getString("body") ?? ""
|
|
9
|
+
|
|
10
|
+
let aSplit = body.components(separatedBy: ";")
|
|
11
|
+
|
|
12
|
+
if aSplit.count > 2 {
|
|
13
|
+
let fileName = aSplit[0]
|
|
14
|
+
let sData1 = "\(aSplit[1])\(aSplit[2])"
|
|
15
|
+
let aData2 = sData1.components(separatedBy: ",")
|
|
16
|
+
|
|
17
|
+
if aData2.count > 1, let sData = aData2[1] {
|
|
18
|
+
if let data = Data(base64Encoded: sData, options: .ignoreUnknownCharacters) {
|
|
19
|
+
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
|
|
20
|
+
let documentsDirectory = paths[0]
|
|
21
|
+
let filePath = documentsDirectory.appendingPathComponent(fileName)
|
|
22
|
+
|
|
23
|
+
DispatchQueue.global(qos: .userInitiated).async {
|
|
24
|
+
do {
|
|
25
|
+
try data.write(to: filePath)
|
|
26
|
+
DispatchQueue.main.async {
|
|
27
|
+
call.resolve([
|
|
28
|
+
"result": true,
|
|
29
|
+
])
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
DispatchQueue.main.async {
|
|
33
|
+
call.resolve([
|
|
34
|
+
"result": false,
|
|
35
|
+
])
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
DispatchQueue.main.async {
|
|
41
|
+
call.resolve([
|
|
42
|
+
"result": false,
|
|
43
|
+
])
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -42,6 +42,9 @@ class ViewController: UIViewController {
|
|
|
42
42
|
wkWebview.uiDelegate = self
|
|
43
43
|
wkWebview.navigationDelegate = self
|
|
44
44
|
wkWebview.load(URLRequest.init(url: URL(string: url)!))
|
|
45
|
+
|
|
46
|
+
let userAgent = WKWebView().value(forKey: "userAgent");
|
|
47
|
+
wkWebview.customUserAgent = userAgent as? String;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
|
package/ios/Plugin/Plugin.m
CHANGED
package/ios/Plugin/Plugin.swift
CHANGED
package/package.json
CHANGED