@hanwha-ss1/plugin 0.5.4 → 0.5.6
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/AndroidManifest.xml +1 -1
- package/ios/Plugin/Download/DownloadPlugin.swift +50 -0
- package/ios/Plugin/EdgeSwipe/EdgeSwipePlugin.swift +0 -2
- package/ios/Plugin/Plugin.m +1 -0
- package/ios/Plugin/Plugin.swift +4 -0
- package/package.json +2 -2
- package/ios/Plugin/EdgeSwipe/EdgeSwipeService.swift +0 -10
|
@@ -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
|
+
|
package/ios/Plugin/Plugin.m
CHANGED
package/ios/Plugin/Plugin.swift
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanwha-ss1/plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Plugin",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -76,4 +76,4 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"gitHead": "dbc41811fcd3e5956cc77c6df41d831c9370c1b3"
|
|
79
|
-
}
|
|
79
|
+
}
|