@capgo/capacitor-ricoh360 8.0.21 → 8.0.22
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/Package.swift
CHANGED
|
@@ -10,16 +10,14 @@ let package = Package(
|
|
|
10
10
|
targets: ["Ricoh360CameraPlugin"])
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
|
|
14
|
-
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.10.2")
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
|
|
15
14
|
],
|
|
16
15
|
targets: [
|
|
17
16
|
.target(
|
|
18
17
|
name: "Ricoh360CameraPlugin",
|
|
19
18
|
dependencies: [
|
|
20
19
|
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
21
|
-
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
22
|
-
"Alamofire"
|
|
20
|
+
.product(name: "Cordova", package: "capacitor-swift-pm")
|
|
23
21
|
],
|
|
24
22
|
path: "ios/Sources/Ricoh360CameraPlugin"),
|
|
25
23
|
.testTarget(
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
|
-
import Alamofire
|
|
4
3
|
import AVKit
|
|
5
4
|
import UIKit
|
|
6
5
|
import Network
|
|
@@ -11,7 +10,7 @@ import Network
|
|
|
11
10
|
*/
|
|
12
11
|
@objc(Ricoh360CameraPlugin)
|
|
13
12
|
public class Ricoh360CameraPlugin: CAPPlugin, CAPBridgedPlugin, URLSessionDataDelegate { // swiftlint:disable:this type_body_length
|
|
14
|
-
private let pluginVersion: String = "8.0.
|
|
13
|
+
private let pluginVersion: String = "8.0.22"
|
|
15
14
|
public let identifier = "Ricoh360CameraPlugin"
|
|
16
15
|
public let jsName = "Ricoh360Camera"
|
|
17
16
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -208,22 +207,38 @@ public class Ricoh360CameraPlugin: CAPPlugin, CAPBridgedPlugin, URLSessionDataDe
|
|
|
208
207
|
|
|
209
208
|
requestLocalNetworkPermission { [weak self] granted in
|
|
210
209
|
if granted {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
210
|
+
guard let url = URL(string: infoUrl) else {
|
|
211
|
+
call.reject("Camera is not reachable or info could not be retrieved")
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
var request = URLRequest(url: url)
|
|
215
|
+
request.httpMethod = "GET"
|
|
216
|
+
request.timeoutInterval = 60
|
|
217
|
+
|
|
218
|
+
let task = URLSession.shared.dataTask(with: request) { data, response, error in
|
|
219
|
+
if error != nil {
|
|
220
|
+
call.reject("Camera is not reachable or info could not be retrieved")
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
guard let httpResponse = response as? HTTPURLResponse,
|
|
225
|
+
(200...299).contains(httpResponse.statusCode),
|
|
226
|
+
let data = data else {
|
|
227
|
+
call.reject("Camera is not reachable or info could not be retrieved")
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
do {
|
|
232
|
+
if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
233
|
+
call.resolve(["session": "Initialized", "info": json])
|
|
234
|
+
} else {
|
|
221
235
|
call.reject("Camera is not reachable or info could not be retrieved")
|
|
222
236
|
}
|
|
223
|
-
|
|
237
|
+
} catch {
|
|
224
238
|
call.reject("Camera is not reachable or info could not be retrieved")
|
|
225
239
|
}
|
|
226
240
|
}
|
|
241
|
+
task.resume()
|
|
227
242
|
} else {
|
|
228
243
|
call.reject("Permission not granted")
|
|
229
244
|
}
|