@hanwha-ss1/plugin 0.6.8 → 0.6.9
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 +142 -0
- package/android/src/main/java/com/plugin/linker/LinkerPlugin.java +35 -0
- package/dist/esm/definitions.d.ts +18 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +10 -1
- package/dist/esm/web.js +3 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Download/DownloadPlugin.swift +72 -27
- package/ios/Plugin/Plugin.m +0 -2
- package/ios/Plugin/Plugin.swift +0 -55
- package/package.json +1 -1
|
@@ -12,9 +12,27 @@ import java.io.File;
|
|
|
12
12
|
import java.io.FileOutputStream;
|
|
13
13
|
import java.io.IOException;
|
|
14
14
|
import java.io.OutputStream;
|
|
15
|
+
import java.io.RandomAccessFile;
|
|
15
16
|
import java.net.URLConnection;
|
|
17
|
+
import java.util.concurrent.ConcurrentHashMap;
|
|
16
18
|
|
|
17
19
|
public class FileDownload {
|
|
20
|
+
|
|
21
|
+
// 청크 다운로드를 위한 임시 파일 관리
|
|
22
|
+
private static final ConcurrentHashMap<String, ChunkDownloadInfo> chunkDownloads = new ConcurrentHashMap<>();
|
|
23
|
+
|
|
24
|
+
private static class ChunkDownloadInfo {
|
|
25
|
+
File tempFile;
|
|
26
|
+
int totalChunks;
|
|
27
|
+
int receivedChunks;
|
|
28
|
+
RandomAccessFile randomAccessFile;
|
|
29
|
+
|
|
30
|
+
ChunkDownloadInfo(File tempFile, int totalChunks) {
|
|
31
|
+
this.tempFile = tempFile;
|
|
32
|
+
this.totalChunks = totalChunks;
|
|
33
|
+
this.receivedChunks = 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
18
36
|
|
|
19
37
|
public String echo(String value) {
|
|
20
38
|
Log.i("Echo", value);
|
|
@@ -36,6 +54,79 @@ public class FileDownload {
|
|
|
36
54
|
}
|
|
37
55
|
}
|
|
38
56
|
|
|
57
|
+
public void downloadChunk(Activity activity, String fileName, String chunkData, int chunkIndex, int totalChunks, boolean isLastChunk, OnResult result) {
|
|
58
|
+
try {
|
|
59
|
+
// Base64 디코딩
|
|
60
|
+
byte[] decodedChunk = android.util.Base64.decode(chunkData, android.util.Base64.DEFAULT);
|
|
61
|
+
|
|
62
|
+
// 첫 번째 청크인 경우 임시 파일 생성
|
|
63
|
+
if (chunkIndex == 0) {
|
|
64
|
+
File tempDir = new File(activity.getCacheDir(), "chunk_downloads");
|
|
65
|
+
if (!tempDir.exists()) {
|
|
66
|
+
tempDir.mkdirs();
|
|
67
|
+
}
|
|
68
|
+
File tempFile = new File(tempDir, fileName + ".tmp");
|
|
69
|
+
|
|
70
|
+
ChunkDownloadInfo downloadInfo = new ChunkDownloadInfo(tempFile, totalChunks);
|
|
71
|
+
try {
|
|
72
|
+
downloadInfo.randomAccessFile = new RandomAccessFile(tempFile, "rw");
|
|
73
|
+
chunkDownloads.put(fileName, downloadInfo);
|
|
74
|
+
} catch (IOException e) {
|
|
75
|
+
if (result != null) {
|
|
76
|
+
result.onFail("임시 파일 생성 실패: " + e.getMessage());
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ChunkDownloadInfo downloadInfo = chunkDownloads.get(fileName);
|
|
83
|
+
if (downloadInfo == null) {
|
|
84
|
+
if (result != null) {
|
|
85
|
+
result.onFail("청크 다운로드 정보를 찾을 수 없습니다.");
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 청크 데이터를 파일에 쓰기
|
|
91
|
+
synchronized (downloadInfo) {
|
|
92
|
+
try {
|
|
93
|
+
downloadInfo.randomAccessFile.write(decodedChunk);
|
|
94
|
+
downloadInfo.receivedChunks++;
|
|
95
|
+
|
|
96
|
+
// 모든 청크를 받았거나 마지막 청크인 경우
|
|
97
|
+
if (isLastChunk || downloadInfo.receivedChunks >= downloadInfo.totalChunks) {
|
|
98
|
+
downloadInfo.randomAccessFile.close();
|
|
99
|
+
|
|
100
|
+
// 최종 파일로 이동
|
|
101
|
+
String finalPath = moveToFinalLocation(activity, downloadInfo.tempFile, fileName);
|
|
102
|
+
|
|
103
|
+
// 정리
|
|
104
|
+
chunkDownloads.remove(fileName);
|
|
105
|
+
downloadInfo.tempFile.delete();
|
|
106
|
+
|
|
107
|
+
if (result != null) {
|
|
108
|
+
result.onSuccess(finalPath);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
// 중간 청크 완료
|
|
112
|
+
if (result != null) {
|
|
113
|
+
result.onSuccess("청크 " + chunkIndex + " 완료");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} catch (IOException e) {
|
|
117
|
+
if (result != null) {
|
|
118
|
+
result.onFail("청크 쓰기 실패: " + e.getMessage());
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
} catch (Exception e) {
|
|
124
|
+
if (result != null) {
|
|
125
|
+
result.onFail("청크 다운로드 실패: " + e.getMessage());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
39
130
|
|
|
40
131
|
private void fileDownload(Activity activity, String param, OnResult result){
|
|
41
132
|
|
|
@@ -127,4 +218,55 @@ public class FileDownload {
|
|
|
127
218
|
}
|
|
128
219
|
}
|
|
129
220
|
}
|
|
221
|
+
|
|
222
|
+
private String moveToFinalLocation(Activity activity, File tempFile, String fileName) throws IOException {
|
|
223
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
224
|
+
ContentValues values = new ContentValues();
|
|
225
|
+
String mimeType = URLConnection.guessContentTypeFromName(fileName);
|
|
226
|
+
|
|
227
|
+
Uri uri;
|
|
228
|
+
if (null != mimeType &&
|
|
229
|
+
(mimeType.contains("image") || mimeType.contains("video"))) {
|
|
230
|
+
uri = MediaStore.Downloads.EXTERNAL_CONTENT_URI;
|
|
231
|
+
} else {
|
|
232
|
+
uri = MediaStore.Downloads.EXTERNAL_CONTENT_URI;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
values.put(MediaStore.Downloads.DISPLAY_NAME, fileName);
|
|
236
|
+
values.put(MediaStore.Downloads.MIME_TYPE, mimeType != null ? mimeType : "application/octet-stream");
|
|
237
|
+
values.put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS);
|
|
238
|
+
|
|
239
|
+
Uri insertedUri = activity.getContentResolver().insert(uri, values);
|
|
240
|
+
if (insertedUri != null) {
|
|
241
|
+
try (OutputStream out = activity.getContentResolver().openOutputStream(insertedUri);
|
|
242
|
+
java.io.FileInputStream in = new java.io.FileInputStream(tempFile)) {
|
|
243
|
+
|
|
244
|
+
byte[] buffer = new byte[8192];
|
|
245
|
+
int bytesRead;
|
|
246
|
+
while ((bytesRead = in.read(buffer)) != -1) {
|
|
247
|
+
out.write(buffer, 0, bytesRead);
|
|
248
|
+
}
|
|
249
|
+
out.flush();
|
|
250
|
+
}
|
|
251
|
+
return insertedUri.toString();
|
|
252
|
+
} else {
|
|
253
|
+
throw new IOException("파일 생성 실패");
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
File downloadDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
|
257
|
+
File finalFile = new File(downloadDir, fileName);
|
|
258
|
+
|
|
259
|
+
try (java.io.FileInputStream in = new java.io.FileInputStream(tempFile);
|
|
260
|
+
FileOutputStream out = new FileOutputStream(finalFile)) {
|
|
261
|
+
|
|
262
|
+
byte[] buffer = new byte[8192];
|
|
263
|
+
int bytesRead;
|
|
264
|
+
while ((bytesRead = in.read(buffer)) != -1) {
|
|
265
|
+
out.write(buffer, 0, bytesRead);
|
|
266
|
+
}
|
|
267
|
+
out.flush();
|
|
268
|
+
}
|
|
269
|
+
return finalFile.getAbsolutePath();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
130
272
|
}
|
|
@@ -161,6 +161,41 @@ public class LinkerPlugin extends Plugin{
|
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
@PluginMethod
|
|
165
|
+
public void fileDownloadChunk(PluginCall call) {
|
|
166
|
+
String fileName = call.getString("fileName");
|
|
167
|
+
String chunkData = call.getString("chunkData");
|
|
168
|
+
Integer chunkIndex = call.getInt("chunkIndex");
|
|
169
|
+
Integer totalChunks = call.getInt("totalChunks");
|
|
170
|
+
Boolean isLastChunk = call.getBoolean("isLastChunk");
|
|
171
|
+
|
|
172
|
+
if(fileDownloadImplementation == null) {
|
|
173
|
+
fileDownloadImplementation = new FileDownload();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fileDownloadImplementation.downloadChunk(getActivity(), fileName, chunkData,
|
|
177
|
+
chunkIndex != null ? chunkIndex : 0,
|
|
178
|
+
totalChunks != null ? totalChunks : 1,
|
|
179
|
+
isLastChunk != null ? isLastChunk : false,
|
|
180
|
+
new FileDownload.OnResult() {
|
|
181
|
+
@Override
|
|
182
|
+
public void onSuccess(String path) {
|
|
183
|
+
JSObject ret = new JSObject();
|
|
184
|
+
ret.put("result", true);
|
|
185
|
+
ret.put("message", "청크 다운로드 완료");
|
|
186
|
+
call.resolve(ret);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@Override
|
|
190
|
+
public void onFail(String message) {
|
|
191
|
+
JSObject ret = new JSObject();
|
|
192
|
+
ret.put("result", false);
|
|
193
|
+
ret.put("message", message);
|
|
194
|
+
call.resolve(ret);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
164
199
|
public void handleDocumentsViewer(String filePath) {
|
|
165
200
|
Handler handler = new Handler(Looper.getMainLooper()) {
|
|
166
201
|
@Override
|
|
@@ -25,7 +25,6 @@ export interface Plugin {
|
|
|
25
25
|
}): Promise<{
|
|
26
26
|
value: string;
|
|
27
27
|
}>;
|
|
28
|
-
getCertificateProvisioning(): Promise<any>;
|
|
29
28
|
/**
|
|
30
29
|
* TouchID, FaceID
|
|
31
30
|
*/
|
|
@@ -79,6 +78,24 @@ export interface Plugin {
|
|
|
79
78
|
}): Promise<{
|
|
80
79
|
value: string;
|
|
81
80
|
}>;
|
|
81
|
+
/**
|
|
82
|
+
* 파일 청크 다운로드
|
|
83
|
+
* @param options fileName : 파일명
|
|
84
|
+
* @param options chunkData : 청크 데이터 (base64)
|
|
85
|
+
* @param options chunkIndex : 청크 인덱스
|
|
86
|
+
* @param options totalChunks : 전체 청크 수
|
|
87
|
+
* @param options isLastChunk : 마지막 청크 여부
|
|
88
|
+
*/
|
|
89
|
+
fileDownloadChunk(options: {
|
|
90
|
+
fileName: string;
|
|
91
|
+
chunkData: string;
|
|
92
|
+
chunkIndex: number;
|
|
93
|
+
totalChunks: number;
|
|
94
|
+
isLastChunk: boolean;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
result: boolean;
|
|
97
|
+
message: string;
|
|
98
|
+
}>;
|
|
82
99
|
/**
|
|
83
100
|
* iOS 캡쳐 방지
|
|
84
101
|
* @see default false
|
|
@@ -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
|
|
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 * 파일 청크 다운로드\n * @param options fileName : 파일명\n * @param options chunkData : 청크 데이터 (base64)\n * @param options chunkIndex : 청크 인덱스\n * @param options totalChunks : 전체 청크 수\n * @param options isLastChunk : 마지막 청크 여부\n */\n fileDownloadChunk(options: {\n fileName: string;\n chunkData: string;\n chunkIndex: number;\n totalChunks: number;\n isLastChunk: boolean;\n }): Promise<{ result: boolean; message: string }>;\n\n /**\n * iOS 캡쳐 방지\n * @see default false\n */\n doDisabledCapture(options: {disabled: boolean; }): Promise<{ value: string }>;\n /**\n * iOS 키보드 메뉴 바\n */\n addKeyboardMenu():any;\n removeKeyboardMenu():any;\n}"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export declare class PluginWeb extends WebPlugin implements Plugin {
|
|
|
6
6
|
addKeyboardMenu(): any;
|
|
7
7
|
removeKeyboardMenu(): any;
|
|
8
8
|
auth(): Promise<any>;
|
|
9
|
-
getCertificateProvisioning(): Promise<any>;
|
|
10
9
|
checkSeoulTimeZone(): Promise<any>;
|
|
11
10
|
timezone(): Promise<any>;
|
|
12
11
|
open(_options: {
|
|
@@ -22,6 +21,16 @@ export declare class PluginWeb extends WebPlugin implements Plugin {
|
|
|
22
21
|
fileDownload(_options: {
|
|
23
22
|
file: string;
|
|
24
23
|
}): Promise<any>;
|
|
24
|
+
fileDownloadChunk(_options: {
|
|
25
|
+
fileName: string;
|
|
26
|
+
chunkData: string;
|
|
27
|
+
chunkIndex: number;
|
|
28
|
+
totalChunks: number;
|
|
29
|
+
isLastChunk: boolean;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
result: boolean;
|
|
32
|
+
message: string;
|
|
33
|
+
}>;
|
|
25
34
|
doDisabledCapture(_options: {
|
|
26
35
|
disabled: boolean;
|
|
27
36
|
}): Promise<any>;
|
package/dist/esm/web.js
CHANGED
|
@@ -16,9 +16,6 @@ export class PluginWeb extends WebPlugin {
|
|
|
16
16
|
async auth() {
|
|
17
17
|
return { results: {} };
|
|
18
18
|
}
|
|
19
|
-
async getCertificateProvisioning() {
|
|
20
|
-
return { result: false };
|
|
21
|
-
}
|
|
22
19
|
async checkSeoulTimeZone() {
|
|
23
20
|
return { results: {} };
|
|
24
21
|
}
|
|
@@ -40,6 +37,9 @@ export class PluginWeb extends WebPlugin {
|
|
|
40
37
|
async fileDownload(_options) {
|
|
41
38
|
return { results: {} };
|
|
42
39
|
}
|
|
40
|
+
async fileDownloadChunk(_options) {
|
|
41
|
+
return { result: true, message: '웹에서는 청크 다운로드가 지원되지 않습니다.' };
|
|
42
|
+
}
|
|
43
43
|
async doDisabledCapture(_options) {
|
|
44
44
|
if (Capacitor.getPlatform() !== 'ios') {
|
|
45
45
|
return Promise.reject('doDisabledCapture is only supported on iOS.');
|
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;IACD,eAAe;QACb,OAAO;IACT,CAAC;IACD,kBAAkB;QAChB,OAAO;IACT,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;
|
|
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;IACD,eAAe;QACb,OAAO;IACT,CAAC;IACD,kBAAkB;QAChB,OAAO;IACT,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;IAED,KAAK,CAAC,iBAAiB,CAAC,QAMvB;QACC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,QAA8B;QACpD,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;YACrC,OAAO,OAAO,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAC;SACtE;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 addKeyboardMenu():any {\n return;\n }\n removeKeyboardMenu():any {\n return;\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 async fileDownloadChunk(_options: {\n fileName: string;\n chunkData: string;\n chunkIndex: number;\n totalChunks: number;\n isLastChunk: boolean;\n }): Promise<{ result: boolean; message: string }> {\n return { result: true, message: '웹에서는 청크 다운로드가 지원되지 않습니다.' };\n }\n\n async doDisabledCapture(_options: { disabled: boolean}): Promise<any> {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('doDisabledCapture is only supported on iOS.');\n }\n return { results: {} };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -25,9 +25,6 @@ class PluginWeb extends core.WebPlugin {
|
|
|
25
25
|
async auth() {
|
|
26
26
|
return { results: {} };
|
|
27
27
|
}
|
|
28
|
-
async getCertificateProvisioning() {
|
|
29
|
-
return { result: false };
|
|
30
|
-
}
|
|
31
28
|
async checkSeoulTimeZone() {
|
|
32
29
|
return { results: {} };
|
|
33
30
|
}
|
|
@@ -49,6 +46,9 @@ class PluginWeb extends core.WebPlugin {
|
|
|
49
46
|
async fileDownload(_options) {
|
|
50
47
|
return { results: {} };
|
|
51
48
|
}
|
|
49
|
+
async fileDownloadChunk(_options) {
|
|
50
|
+
return { result: true, message: '웹에서는 청크 다운로드가 지원되지 않습니다.' };
|
|
51
|
+
}
|
|
52
52
|
async doDisabledCapture(_options) {
|
|
53
53
|
if (core.Capacitor.getPlatform() !== 'ios') {
|
|
54
54
|
return Promise.reject('doDisabledCapture is only supported on iOS.');
|
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 addKeyboardMenu() {\n return;\n }\n removeKeyboardMenu() {\n return;\n }\n async auth() {\n return { results: {} };\n }\n async
|
|
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 addKeyboardMenu() {\n return;\n }\n removeKeyboardMenu() {\n return;\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 async fileDownloadChunk(_options) {\n return { result: true, message: '웹에서는 청크 다운로드가 지원되지 않습니다.' };\n }\n async doDisabledCapture(_options) {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('doDisabledCapture is only supported on iOS.');\n }\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,eAAe,GAAG;AACtB,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,kBAAkB,GAAG;AACzB,QAAQ,OAAO;AACf,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,IAAI,MAAM,iBAAiB,CAAC,QAAQ,EAAE;AACtC,QAAQ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACrE,KAAK;AACL,IAAI,MAAM,iBAAiB,CAAC,QAAQ,EAAE;AACtC,QAAQ,IAAIA,cAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;AAC/C,YAAY,OAAO,OAAO,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAC;AACjF,SAAS;AACT,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -22,9 +22,6 @@ var capacitorContact = (function (exports, core) {
|
|
|
22
22
|
async auth() {
|
|
23
23
|
return { results: {} };
|
|
24
24
|
}
|
|
25
|
-
async getCertificateProvisioning() {
|
|
26
|
-
return { result: false };
|
|
27
|
-
}
|
|
28
25
|
async checkSeoulTimeZone() {
|
|
29
26
|
return { results: {} };
|
|
30
27
|
}
|
|
@@ -46,6 +43,9 @@ var capacitorContact = (function (exports, core) {
|
|
|
46
43
|
async fileDownload(_options) {
|
|
47
44
|
return { results: {} };
|
|
48
45
|
}
|
|
46
|
+
async fileDownloadChunk(_options) {
|
|
47
|
+
return { result: true, message: '웹에서는 청크 다운로드가 지원되지 않습니다.' };
|
|
48
|
+
}
|
|
49
49
|
async doDisabledCapture(_options) {
|
|
50
50
|
if (core.Capacitor.getPlatform() !== 'ios') {
|
|
51
51
|
return Promise.reject('doDisabledCapture is only supported on iOS.');
|
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 addKeyboardMenu() {\n return;\n }\n removeKeyboardMenu() {\n return;\n }\n async auth() {\n return { results: {} };\n }\n async
|
|
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 addKeyboardMenu() {\n return;\n }\n removeKeyboardMenu() {\n return;\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 async fileDownloadChunk(_options) {\n return { result: true, message: '웹에서는 청크 다운로드가 지원되지 않습니다.' };\n }\n async doDisabledCapture(_options) {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('doDisabledCapture is only supported on iOS.');\n }\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,eAAe,GAAG;IACtB,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,kBAAkB,GAAG;IACzB,QAAQ,OAAO;IACf,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,IAAI,MAAM,iBAAiB,CAAC,QAAQ,EAAE;IACtC,QAAQ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACrE,KAAK;IACL,IAAI,MAAM,iBAAiB,CAAC,QAAQ,EAAE;IACtC,QAAQ,IAAIA,cAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;IAC/C,YAAY,OAAO,OAAO,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAC;IACjF,SAAS;IACT,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -4,49 +4,94 @@ import Capacitor
|
|
|
4
4
|
|
|
5
5
|
public class DownloadPlugin: CAPPlugin {
|
|
6
6
|
|
|
7
|
-
@objc public func doDownload(_ call: CAPPluginCall,
|
|
7
|
+
@objc public func doDownload(_ call: CAPPluginCall, _ bridge: CAPBridgeProtocol) {
|
|
8
8
|
let body = call.getString("file") ?? ""
|
|
9
|
-
|
|
10
9
|
let aSplit = body.components(separatedBy: ";")
|
|
11
|
-
|
|
10
|
+
|
|
12
11
|
if aSplit.count > 2 {
|
|
13
12
|
let fileName = aSplit[0]
|
|
14
13
|
let sData1 = "\(aSplit[1])\(aSplit[2])"
|
|
15
14
|
let aData2 = sData1.components(separatedBy: ",")
|
|
16
15
|
|
|
17
16
|
if aData2.count > 1 {
|
|
18
|
-
let sData = aData2[1]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
let sData = aData2[1] // Base64 본문만 추출
|
|
18
|
+
|
|
19
|
+
// 저장 경로
|
|
20
|
+
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
|
|
21
|
+
let documentsDirectory = paths[0]
|
|
22
|
+
let filePath = documentsDirectory.appendingPathComponent(fileName)
|
|
23
|
+
|
|
24
|
+
DispatchQueue.global(qos: .userInitiated).async {
|
|
25
|
+
let success = self.decodeBase64ToFile(base64: sData, fileURL: filePath)
|
|
24
26
|
|
|
25
|
-
DispatchQueue.global(qos: .userInitiated).async {
|
|
26
|
-
do {
|
|
27
|
-
try data.write(to: filePath)
|
|
28
|
-
DispatchQueue.main.async {
|
|
29
|
-
call.resolve([
|
|
30
|
-
"result": true,
|
|
31
|
-
])
|
|
32
|
-
}
|
|
33
|
-
} catch {
|
|
34
|
-
DispatchQueue.main.async {
|
|
35
|
-
call.resolve([
|
|
36
|
-
"result": false,
|
|
37
|
-
])
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
27
|
DispatchQueue.main.async {
|
|
43
28
|
call.resolve([
|
|
44
|
-
"result":
|
|
29
|
+
"result": success
|
|
45
30
|
])
|
|
46
31
|
}
|
|
47
32
|
}
|
|
48
33
|
}
|
|
49
34
|
}
|
|
50
35
|
}
|
|
36
|
+
|
|
37
|
+
/// 대용량 Base64 문자열을 스트리밍 방식으로 파일로 변환
|
|
38
|
+
private func decodeBase64ToFile(base64: String, fileURL: URL) -> Bool {
|
|
39
|
+
guard let inputData = base64.data(using: .utf8) else {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let inputStream = InputStream(data: inputData)
|
|
44
|
+
inputStream.open()
|
|
45
|
+
|
|
46
|
+
guard let outputStream = OutputStream(url: fileURL, append: false) else {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
outputStream.open()
|
|
50
|
+
|
|
51
|
+
let bufferSize = 1024 * 64 // 64KB 단위 처리
|
|
52
|
+
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: bufferSize)
|
|
53
|
+
|
|
54
|
+
var base64Buffer = Data()
|
|
55
|
+
var success = true
|
|
56
|
+
|
|
57
|
+
while inputStream.hasBytesAvailable {
|
|
58
|
+
let read = inputStream.read(buffer, maxLength: bufferSize)
|
|
59
|
+
if read > 0 {
|
|
60
|
+
base64Buffer.append(buffer, count: read)
|
|
61
|
+
|
|
62
|
+
// Base64는 4의 배수 단위로 끊어서 처리 가능
|
|
63
|
+
let validLength = (base64Buffer.count / 4) * 4
|
|
64
|
+
if validLength > 0 {
|
|
65
|
+
let chunk = base64Buffer.prefix(validLength)
|
|
66
|
+
base64Buffer.removeFirst(validLength)
|
|
67
|
+
|
|
68
|
+
if let decoded = Data(base64Encoded: chunk, options: .ignoreUnknownCharacters) {
|
|
69
|
+
decoded.withUnsafeBytes {
|
|
70
|
+
_ = outputStream.write($0.bindMemory(to: UInt8.self).baseAddress!, maxLength: decoded.count)
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
success = false
|
|
74
|
+
break
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
break
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 남은 데이터 처리
|
|
83
|
+
if base64Buffer.count > 0,
|
|
84
|
+
let decoded = Data(base64Encoded: base64Buffer, options: .ignoreUnknownCharacters) {
|
|
85
|
+
decoded.withUnsafeBytes {
|
|
86
|
+
_ = outputStream.write($0.bindMemory(to: UInt8.self).baseAddress!, maxLength: decoded.count)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
buffer.deallocate()
|
|
91
|
+
inputStream.close()
|
|
92
|
+
outputStream.close()
|
|
93
|
+
|
|
94
|
+
return success
|
|
95
|
+
}
|
|
51
96
|
}
|
|
52
97
|
|
package/ios/Plugin/Plugin.m
CHANGED
|
@@ -16,6 +16,4 @@ CAP_PLUGIN(Plugin, "Plugin",
|
|
|
16
16
|
CAP_PLUGIN_METHOD(addKeyboardMenu, CAPPluginReturnPromise);
|
|
17
17
|
CAP_PLUGIN_METHOD(removeKeyboardMenu, CAPPluginReturnPromise);
|
|
18
18
|
CAP_PLUGIN_METHOD(executeApp, CAPPluginReturnPromise);
|
|
19
|
-
CAP_PLUGIN_METHOD(getCertificateProvisioning, CAPPluginReturnPromise);
|
|
20
|
-
|
|
21
19
|
)
|
package/ios/Plugin/Plugin.swift
CHANGED
|
@@ -30,61 +30,6 @@ public class Plugin: CAPPlugin {
|
|
|
30
30
|
let keyboardSize = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue.size
|
|
31
31
|
// data 매개변수에 keyboardsize를 전달
|
|
32
32
|
self.notifyListeners(notification.name.rawValue, data: ["size": keyboardSize.height])
|
|
33
|
-
}
|
|
34
|
-
// ios 인증서 만료일을 가져온다
|
|
35
|
-
@objc func getCertificateProvisioning(_ call: CAPPluginCall){
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
guard let path = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision"),
|
|
39
|
-
let content = try? Data(contentsOf: URL(fileURLWithPath: path)) else {
|
|
40
|
-
print("embedded.mobileprovision not found")
|
|
41
|
-
call.resolve([
|
|
42
|
-
"result": false,
|
|
43
|
-
"message": "embedded.mobileprovision not found"
|
|
44
|
-
])
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 구형기기에서는 ascii, 최신기기는 isoLatin1
|
|
49
|
-
guard let contentString = String(data: content, encoding: .isoLatin1) ?? String(data: content, encoding: .ascii),
|
|
50
|
-
let startRange = contentString.range(of: "<plist"),
|
|
51
|
-
let endRange = contentString.range(of: "</plist>") else {
|
|
52
|
-
print("Failed to parse plist from provisioning profile")
|
|
53
|
-
call.resolve([
|
|
54
|
-
"result": false,
|
|
55
|
-
"message": "Failed to parse plist from provisioning profile"
|
|
56
|
-
])
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let plistString = String(contentString[startRange.lowerBound...endRange.upperBound])
|
|
61
|
-
guard let plistData = plistString.data(using: .utf8) else { call.resolve([
|
|
62
|
-
"result": false
|
|
63
|
-
])
|
|
64
|
-
return; }
|
|
65
|
-
|
|
66
|
-
do {
|
|
67
|
-
if let plist = try PropertyListSerialization.propertyList(from: plistData, options: [], format: nil) as? [String: Any],
|
|
68
|
-
let expirationDate = plist["ExpirationDate"] as? Date {
|
|
69
|
-
// Date를 timestamp로 변환
|
|
70
|
-
let timestamp = expirationDate.timeIntervalSince1970
|
|
71
|
-
|
|
72
|
-
call.resolve([
|
|
73
|
-
"result": true,
|
|
74
|
-
"timestamp": timestamp,
|
|
75
|
-
"date": expirationDate.description,
|
|
76
|
-
])
|
|
77
|
-
return;
|
|
78
|
-
// return expirationDate
|
|
79
|
-
}
|
|
80
|
-
} catch {
|
|
81
|
-
print("Plist parsing failed: \(error)")
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
33
|
}
|
|
89
34
|
|
|
90
35
|
@objc func handleDocumentViewRequest(_ notification: Notification) {
|