@capawesome/capacitor-pixlive 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/CapawesomeCapacitorPixlive.podspec +30 -0
- package/Package.swift +28 -0
- package/README.md +1012 -0
- package/android/build.gradle +64 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/Pixlive.java +704 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/PixliveHelper.java +112 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/PixlivePlugin.java +691 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/TouchInterceptorView.java +94 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/CustomExceptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/ActivateContextOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/CreateARViewOptions.java +68 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/EnableContextsWithTagsOptions.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/GetContextOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/GetGPSPointsInBoundingBoxOptions.java +68 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/GetNearbyGPSPointsOptions.java +40 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/ResizeARViewOptions.java +68 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SetARViewTouchEnabledOptions.java +26 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SetARViewTouchHoleOptions.java +68 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SetInterfaceLanguageOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SetNotificationsSupportOptions.java +26 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SynchronizeOptions.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/SynchronizeWithToursAndContextsOptions.java +66 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/options/UpdateTagMappingOptions.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetContextResult.java +23 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetContextsResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetGPSPointsInBoundingBoxResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetNearbyBeaconsResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetNearbyGPSPointsResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/classes/results/GetVersionResult.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/EmptyCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/NonEmptyCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/pixlive/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +2107 -0
- package/dist/esm/definitions.d.ts +825 -0
- package/dist/esm/definitions.js +2 -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 +31 -0
- package/dist/esm/web.js +85 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +99 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +102 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/CapacitorARViewController.swift +17 -0
- package/ios/Plugin/Classes/Options/ActivateContextOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/CreateARViewOptions.swift +47 -0
- package/ios/Plugin/Classes/Options/EnableContextsWithTagsOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/GetContextOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/GetGPSPointsInBoundingBoxOptions.swift +43 -0
- package/ios/Plugin/Classes/Options/GetNearbyGPSPointsOptions.swift +25 -0
- package/ios/Plugin/Classes/Options/ResizeARViewOptions.swift +47 -0
- package/ios/Plugin/Classes/Options/SetARViewTouchEnabledOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/SetARViewTouchHoleOptions.swift +43 -0
- package/ios/Plugin/Classes/Options/SetInterfaceLanguageOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/SetNotificationsSupportOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/SynchronizeOptions.swift +16 -0
- package/ios/Plugin/Classes/Options/SynchronizeWithToursAndContextsOptions.swift +34 -0
- package/ios/Plugin/Classes/Options/UpdateTagMappingOptions.swift +16 -0
- package/ios/Plugin/Classes/Results/GetContextResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetContextsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetGPSPointsInBoundingBoxResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetNearbyBeaconsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetNearbyGPSPointsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetVersionResult.swift +16 -0
- package/ios/Plugin/Enums/CustomError.swift +86 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Pixlive.swift +495 -0
- package/ios/Plugin/PixliveHelper.swift +91 -0
- package/ios/Plugin/PixlivePlugin.swift +503 -0
- package/ios/Plugin/Protocols/Result.swift +6 -0
- package/ios/Plugin/TouchForwarderView.swift +24 -0
- package/package.json +93 -0
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import Capacitor
|
|
4
|
+
import VDARSDK
|
|
5
|
+
|
|
6
|
+
// swiftlint:disable:next type_body_length
|
|
7
|
+
@objc public class Pixlive: NSObject, VDARSDKControllerDelegate, RemoteControllerDelegate {
|
|
8
|
+
|
|
9
|
+
private weak var plugin: PixlivePlugin?
|
|
10
|
+
private var arViewController: VDARLiveAnnotationViewController?
|
|
11
|
+
private var touchForwarderView: TouchForwarderView?
|
|
12
|
+
private var currentContext: VDARContext?
|
|
13
|
+
private var isInitialized = false
|
|
14
|
+
|
|
15
|
+
public init(_ plugin: PixlivePlugin) {
|
|
16
|
+
self.plugin = plugin
|
|
17
|
+
super.init()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@objc public func initialize(completion: @escaping (_ error: Error?) -> Void) {
|
|
21
|
+
guard let plugin = plugin else { return }
|
|
22
|
+
let licenseKey = plugin.getConfig().getString("licenseKey") ?? ""
|
|
23
|
+
let apiUrl = plugin.getConfig().getString("apiUrl")
|
|
24
|
+
let sdkUrl = plugin.getConfig().getString("sdkUrl")
|
|
25
|
+
|
|
26
|
+
guard let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first else { return }
|
|
27
|
+
let storagePath = (documentsPath as NSString).appendingPathComponent("pixliveSDK")
|
|
28
|
+
let fileManager = FileManager.default
|
|
29
|
+
if !fileManager.fileExists(atPath: storagePath) {
|
|
30
|
+
try? fileManager.createDirectory(atPath: storagePath, withIntermediateDirectories: true)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
DispatchQueue.main.async {
|
|
34
|
+
VDARSDKController.startSDK(storagePath, withLicenseKey: licenseKey)
|
|
35
|
+
guard let controller = VDARSDKController.sharedInstance() else { return }
|
|
36
|
+
if let apiUrl = apiUrl {
|
|
37
|
+
VDARRemoteController.sharedInstance()?.customAPIServer = apiUrl
|
|
38
|
+
}
|
|
39
|
+
if let sdkUrl = sdkUrl {
|
|
40
|
+
VDARRemoteController.sharedInstance()?.customSdkServer = sdkUrl
|
|
41
|
+
}
|
|
42
|
+
controller.enableCodesRecognition = true
|
|
43
|
+
let cameraSender = VDARCameraImageSource()
|
|
44
|
+
controller.imageSender = cameraSender
|
|
45
|
+
controller.detectionDelegates.add(self)
|
|
46
|
+
controller.enableGPSNotifications()
|
|
47
|
+
VDARRemoteController.sharedInstance()?.delegate = self
|
|
48
|
+
self.isInitialized = true
|
|
49
|
+
completion(nil)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@objc public func synchronize(_ options: SynchronizeOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
54
|
+
guard isInitialized else {
|
|
55
|
+
completion(CustomError.notInitialized)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
let priors = PixliveHelper.buildTagPriors(options.tags)
|
|
59
|
+
VDARRemoteController.sharedInstance()?.syncRemoteModelsAsynchronously(withPriors: priors, withCompletionBlock: { _, err in
|
|
60
|
+
if let err = err {
|
|
61
|
+
completion(err)
|
|
62
|
+
} else {
|
|
63
|
+
completion(nil)
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@objc public func synchronizeWithToursAndContexts(_ options: SynchronizeWithToursAndContextsOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
69
|
+
guard isInitialized else {
|
|
70
|
+
completion(CustomError.notInitialized)
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
let priors = PixliveHelper.buildFullPriors(tags: options.tags, tourIds: options.tourIds, contextIds: options.contextIds)
|
|
74
|
+
VDARRemoteController.sharedInstance()?.syncRemoteModelsAsynchronously(withPriors: priors, withCompletionBlock: { _, err in
|
|
75
|
+
if let err = err {
|
|
76
|
+
completion(err)
|
|
77
|
+
} else {
|
|
78
|
+
completion(nil)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@objc public func updateTagMapping(_ options: UpdateTagMappingOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
84
|
+
guard isInitialized else {
|
|
85
|
+
completion(CustomError.notInitialized)
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
VDARRemoteController.sharedInstance()?.syncTagContexts(options.tags, withCompletionBlock: { _, err in
|
|
89
|
+
if let err = err {
|
|
90
|
+
completion(err)
|
|
91
|
+
} else {
|
|
92
|
+
completion(nil)
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@objc public func enableContextsWithTags(_ options: EnableContextsWithTagsOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
98
|
+
guard isInitialized else {
|
|
99
|
+
completion(CustomError.notInitialized)
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
VDARSDKController.sharedInstance()?.disableContexts()
|
|
103
|
+
VDARSDKController.sharedInstance()?.enableContexts(withTags: options.tags)
|
|
104
|
+
completion(nil)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@objc public func getContexts(completion: @escaping (_ result: GetContextsResult?, _ error: Error?) -> Void) {
|
|
108
|
+
guard isInitialized else {
|
|
109
|
+
completion(nil, CustomError.notInitialized)
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
guard let controller = VDARSDKController.sharedInstance() else {
|
|
113
|
+
completion(nil, CustomError.notInitialized)
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
var contextsArray = JSArray()
|
|
117
|
+
if let contextIds = controller.contextIDs as? [String] {
|
|
118
|
+
for contextId in contextIds {
|
|
119
|
+
if let context = controller.getContext(contextId) {
|
|
120
|
+
contextsArray.append(PixliveHelper.contextToJSObject(context))
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
completion(GetContextsResult(contexts: contextsArray), nil)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@objc public func getContext(_ options: GetContextOptions, completion: @escaping (_ result: GetContextResult?, _ error: Error?) -> Void) {
|
|
128
|
+
guard isInitialized else {
|
|
129
|
+
completion(nil, CustomError.notInitialized)
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
guard let controller = VDARSDKController.sharedInstance() else {
|
|
133
|
+
completion(nil, CustomError.notInitialized)
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
guard let context = controller.getContext(options.contextId) else {
|
|
137
|
+
completion(nil, CustomError.contextNotFound)
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
completion(GetContextResult(context: PixliveHelper.contextToJSObject(context)), nil)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@objc public func activateContext(_ options: ActivateContextOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
144
|
+
guard isInitialized else {
|
|
145
|
+
completion(CustomError.notInitialized)
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
guard let controller = VDARSDKController.sharedInstance() else {
|
|
149
|
+
completion(CustomError.notInitialized)
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
if let context = controller.getContext(options.contextId) {
|
|
153
|
+
context.activate()
|
|
154
|
+
}
|
|
155
|
+
completion(nil)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@objc public func stopContext(completion: @escaping (_ error: Error?) -> Void) {
|
|
159
|
+
guard isInitialized else {
|
|
160
|
+
completion(CustomError.notInitialized)
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
if let context = currentContext {
|
|
164
|
+
context.stop()
|
|
165
|
+
}
|
|
166
|
+
completion(nil)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@objc public func getNearbyGPSPoints(_ options: GetNearbyGPSPointsOptions, completion: @escaping (_ result: GetNearbyGPSPointsResult?, _ error: Error?) -> Void) {
|
|
170
|
+
guard isInitialized else {
|
|
171
|
+
completion(nil, CustomError.notInitialized)
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
guard let controller = VDARSDKController.sharedInstance() else {
|
|
175
|
+
completion(nil, CustomError.notInitialized)
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
let points = controller.getNearbyGPSPointsfromLat(options.latitude, lon: options.longitude)
|
|
179
|
+
var pointsArray = JSArray()
|
|
180
|
+
if let points = points {
|
|
181
|
+
for point in points {
|
|
182
|
+
pointsArray.append(PixliveHelper.gpsPointToJSObject(point))
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
completion(GetNearbyGPSPointsResult(points: pointsArray), nil)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@objc public func getGPSPointsInBoundingBox(_ options: GetGPSPointsInBoundingBoxOptions, completion: @escaping (_ result: GetGPSPointsInBoundingBoxResult?, _ error: Error?) -> Void) {
|
|
189
|
+
guard isInitialized else {
|
|
190
|
+
completion(nil, CustomError.notInitialized)
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
guard let controller = VDARSDKController.sharedInstance() else {
|
|
194
|
+
completion(nil, CustomError.notInitialized)
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
let points = controller.getGPSPoints(
|
|
198
|
+
inBoundingBoxOfMinLat: options.minLatitude, minLon: options.minLongitude,
|
|
199
|
+
maxLat: options.maxLatitude, maxLon: options.maxLongitude
|
|
200
|
+
)
|
|
201
|
+
var pointsArray = JSArray()
|
|
202
|
+
if let points = points {
|
|
203
|
+
for point in points {
|
|
204
|
+
pointsArray.append(PixliveHelper.gpsPointToJSObject(point))
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
completion(GetGPSPointsInBoundingBoxResult(points: pointsArray), nil)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@objc public func getNearbyBeacons(completion: @escaping (_ result: GetNearbyBeaconsResult?, _ error: Error?) -> Void) {
|
|
211
|
+
guard isInitialized else {
|
|
212
|
+
completion(nil, CustomError.notInitialized)
|
|
213
|
+
return
|
|
214
|
+
}
|
|
215
|
+
guard let controller = VDARSDKController.sharedInstance() else {
|
|
216
|
+
completion(nil, CustomError.notInitialized)
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
let beaconContextIds = controller.getNearbyBeacons()
|
|
220
|
+
var contextsArray = JSArray()
|
|
221
|
+
if let beaconContextIds = beaconContextIds {
|
|
222
|
+
for contextId in beaconContextIds {
|
|
223
|
+
if let context = controller.getContext(contextId) {
|
|
224
|
+
contextsArray.append(PixliveHelper.contextToJSObject(context))
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
completion(GetNearbyBeaconsResult(contexts: contextsArray), nil)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@objc public func startNearbyGPSDetection(completion: @escaping (_ error: Error?) -> Void) {
|
|
232
|
+
guard isInitialized else {
|
|
233
|
+
completion(CustomError.notInitialized)
|
|
234
|
+
return
|
|
235
|
+
}
|
|
236
|
+
VDARSDKController.sharedInstance()?.startNearbyGPSDetection()
|
|
237
|
+
completion(nil)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@objc public func stopNearbyGPSDetection(completion: @escaping (_ error: Error?) -> Void) {
|
|
241
|
+
guard isInitialized else {
|
|
242
|
+
completion(CustomError.notInitialized)
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
VDARSDKController.sharedInstance()?.stopNearbyGPSDetection()
|
|
246
|
+
completion(nil)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
@objc public func startGPSNotifications(completion: @escaping (_ error: Error?) -> Void) {
|
|
250
|
+
guard isInitialized else {
|
|
251
|
+
completion(CustomError.notInitialized)
|
|
252
|
+
return
|
|
253
|
+
}
|
|
254
|
+
VDARSDKController.sharedInstance()?.startGPSNotifications()
|
|
255
|
+
completion(nil)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
@objc public func stopGPSNotifications(completion: @escaping (_ error: Error?) -> Void) {
|
|
259
|
+
guard isInitialized else {
|
|
260
|
+
completion(CustomError.notInitialized)
|
|
261
|
+
return
|
|
262
|
+
}
|
|
263
|
+
VDARSDKController.sharedInstance()?.stopGPSNotifications()
|
|
264
|
+
completion(nil)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
@objc public func setNotificationsSupport(_ options: SetNotificationsSupportOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
268
|
+
guard isInitialized else {
|
|
269
|
+
completion(CustomError.notInitialized)
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
VDARSDKController.sharedInstance()?.isNotificationsEnabled = options.enabled
|
|
273
|
+
completion(nil)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
@objc public func setInterfaceLanguage(_ options: SetInterfaceLanguageOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
277
|
+
guard isInitialized else {
|
|
278
|
+
completion(CustomError.notInitialized)
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
VDARSDKController.sharedInstance()?.forceLanguage(options.language)
|
|
282
|
+
completion(nil)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
@objc public func createARView(_ options: CreateARViewOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
286
|
+
guard isInitialized else {
|
|
287
|
+
completion(CustomError.notInitialized)
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
if arViewController != nil {
|
|
291
|
+
completion(CustomError.arViewAlreadyExists)
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
guard let plugin = plugin else { return }
|
|
295
|
+
DispatchQueue.main.async {
|
|
296
|
+
guard let webView = plugin.webView, let superview = webView.superview else { return }
|
|
297
|
+
let arVC = CapacitorARViewController()
|
|
298
|
+
arVC.pixlive = self
|
|
299
|
+
self.arViewController = arVC
|
|
300
|
+
_ = arVC.view
|
|
301
|
+
arVC.viewDidLoad()
|
|
302
|
+
let frame = CGRect(x: options.x, y: options.y, width: options.width, height: options.height)
|
|
303
|
+
arVC.view.frame = frame
|
|
304
|
+
webView.isOpaque = false
|
|
305
|
+
webView.backgroundColor = .clear
|
|
306
|
+
webView.scrollView.backgroundColor = .clear
|
|
307
|
+
|
|
308
|
+
let forwarder = TouchForwarderView(frame: webView.frame)
|
|
309
|
+
forwarder.autoresizingMask = webView.autoresizingMask
|
|
310
|
+
superview.insertSubview(forwarder, aboveSubview: webView)
|
|
311
|
+
webView.removeFromSuperview()
|
|
312
|
+
forwarder.addSubview(webView)
|
|
313
|
+
webView.frame = forwarder.bounds
|
|
314
|
+
webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
315
|
+
|
|
316
|
+
forwarder.arView = arVC.view
|
|
317
|
+
self.touchForwarderView = forwarder
|
|
318
|
+
|
|
319
|
+
superview.insertSubview(arVC.view, belowSubview: forwarder)
|
|
320
|
+
arVC.viewWillAppear(false)
|
|
321
|
+
arVC.viewDidAppear(false)
|
|
322
|
+
completion(nil)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@objc public func destroyARView(completion: @escaping (_ error: Error?) -> Void) {
|
|
327
|
+
guard isInitialized else {
|
|
328
|
+
completion(CustomError.notInitialized)
|
|
329
|
+
return
|
|
330
|
+
}
|
|
331
|
+
guard let arVC = arViewController else {
|
|
332
|
+
completion(CustomError.arViewNotFound)
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
DispatchQueue.main.async {
|
|
336
|
+
guard let plugin = self.plugin, let webView = plugin.webView else { return }
|
|
337
|
+
webView.isOpaque = true
|
|
338
|
+
webView.backgroundColor = .white
|
|
339
|
+
webView.scrollView.backgroundColor = .white
|
|
340
|
+
arVC.viewWillDisappear(false)
|
|
341
|
+
arVC.view.removeFromSuperview()
|
|
342
|
+
arVC.viewDidDisappear(false)
|
|
343
|
+
arVC.stopAndUnload()
|
|
344
|
+
self.arViewController = nil
|
|
345
|
+
|
|
346
|
+
if let forwarder = self.touchForwarderView, let superview = forwarder.superview {
|
|
347
|
+
webView.removeFromSuperview()
|
|
348
|
+
let savedFrame = forwarder.frame
|
|
349
|
+
let savedMask = forwarder.autoresizingMask
|
|
350
|
+
superview.insertSubview(webView, aboveSubview: forwarder)
|
|
351
|
+
forwarder.removeFromSuperview()
|
|
352
|
+
webView.frame = savedFrame
|
|
353
|
+
webView.autoresizingMask = savedMask
|
|
354
|
+
self.touchForwarderView = nil
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
completion(nil)
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
@objc public func resizeARView(_ options: ResizeARViewOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
362
|
+
guard isInitialized else {
|
|
363
|
+
completion(CustomError.notInitialized)
|
|
364
|
+
return
|
|
365
|
+
}
|
|
366
|
+
guard let arVC = arViewController else {
|
|
367
|
+
completion(CustomError.arViewNotFound)
|
|
368
|
+
return
|
|
369
|
+
}
|
|
370
|
+
DispatchQueue.main.async {
|
|
371
|
+
let frame = CGRect(x: options.x, y: options.y, width: options.width, height: options.height)
|
|
372
|
+
arVC.view.frame = frame
|
|
373
|
+
completion(nil)
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
@objc public func setARViewTouchEnabled(_ options: SetARViewTouchEnabledOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
378
|
+
guard isInitialized else {
|
|
379
|
+
completion(CustomError.notInitialized)
|
|
380
|
+
return
|
|
381
|
+
}
|
|
382
|
+
DispatchQueue.main.async {
|
|
383
|
+
self.touchForwarderView?.touchEnabled = options.enabled
|
|
384
|
+
}
|
|
385
|
+
completion(nil)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
@objc public func setARViewTouchHole(_ options: SetARViewTouchHoleOptions, completion: @escaping (_ error: Error?) -> Void) {
|
|
389
|
+
guard isInitialized else {
|
|
390
|
+
completion(CustomError.notInitialized)
|
|
391
|
+
return
|
|
392
|
+
}
|
|
393
|
+
let hole = CGRect(
|
|
394
|
+
x: options.left,
|
|
395
|
+
y: options.top,
|
|
396
|
+
width: options.right - options.left,
|
|
397
|
+
height: options.bottom - options.top
|
|
398
|
+
)
|
|
399
|
+
DispatchQueue.main.async {
|
|
400
|
+
self.touchForwarderView?.touchHole = hole
|
|
401
|
+
}
|
|
402
|
+
completion(nil)
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
@objc public func getVersion(completion: @escaping (_ result: GetVersionResult?, _ error: Error?) -> Void) {
|
|
406
|
+
guard let version = VDARSDKController.vdarsdkVersion() else {
|
|
407
|
+
completion(nil, CustomError.versionNotExists)
|
|
408
|
+
return
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
completion(GetVersionResult(version: version), nil)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// MARK: - CapacitorARViewController
|
|
415
|
+
|
|
416
|
+
func annotationViewDidBecomeEmpty() {
|
|
417
|
+
plugin?.notifyListenersFromImplementation("hideAnnotations", data: JSObject())
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
func annotationViewDidPresentAnnotations() {
|
|
421
|
+
plugin?.notifyListenersFromImplementation("presentAnnotations", data: JSObject())
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// MARK: - VDARSDKControllerDelegate
|
|
425
|
+
|
|
426
|
+
// swiftlint:disable:next implicitly_unwrapped_optional
|
|
427
|
+
@objc public func didEnter(_ context: VDARContext!) {
|
|
428
|
+
guard let context = context else { return }
|
|
429
|
+
self.currentContext = context
|
|
430
|
+
var data = JSObject()
|
|
431
|
+
data["contextId"] = context.remoteID ?? ""
|
|
432
|
+
plugin?.notifyListenersFromImplementation("enterContext", data: data)
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// swiftlint:disable:next implicitly_unwrapped_optional
|
|
436
|
+
@objc public func didExit(_ context: VDARContext!) {
|
|
437
|
+
guard let context = context else { return }
|
|
438
|
+
context.stop()
|
|
439
|
+
self.currentContext = nil
|
|
440
|
+
var data = JSObject()
|
|
441
|
+
data["contextId"] = context.remoteID ?? ""
|
|
442
|
+
plugin?.notifyListenersFromImplementation("exitContext", data: data)
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// swiftlint:disable:next implicitly_unwrapped_optional
|
|
446
|
+
@objc public func codesDetected(_ codes: [VDARCode]!) {
|
|
447
|
+
guard let codes = codes else { return }
|
|
448
|
+
for code in codes {
|
|
449
|
+
if code.isSpecialCode {
|
|
450
|
+
continue
|
|
451
|
+
}
|
|
452
|
+
var data = JSObject()
|
|
453
|
+
data["code"] = code.codeData ?? ""
|
|
454
|
+
data["type"] = PixliveHelper.codeTypeToString(code.codeType)
|
|
455
|
+
plugin?.notifyListenersFromImplementation("codeRecognize", data: data)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// swiftlint:disable:next implicitly_unwrapped_optional
|
|
460
|
+
@objc public func errorOccurred(onModelManager err: Error!) {
|
|
461
|
+
// Required delegate method - no action needed
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// swiftlint:disable:next implicitly_unwrapped_optional
|
|
465
|
+
@objc public func didDispatchEvent(inApp eventName: String!, withParams eventParams: String!) {
|
|
466
|
+
guard let eventName = eventName else { return }
|
|
467
|
+
var data = JSObject()
|
|
468
|
+
data["name"] = eventName
|
|
469
|
+
data["params"] = eventParams ?? ""
|
|
470
|
+
plugin?.notifyListenersFromImplementation("eventFromContent", data: data)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// swiftlint:disable:next implicitly_unwrapped_optional
|
|
474
|
+
@objc public func contextDidRequireSynchronization(_ priors: [VDARPrior]!) {
|
|
475
|
+
guard let priors = priors else { return }
|
|
476
|
+
var tags: [String] = []
|
|
477
|
+
for prior in priors {
|
|
478
|
+
if let tagPrior = prior as? VDARTagPrior {
|
|
479
|
+
tags.append(tagPrior.tagName)
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
var data = JSObject()
|
|
483
|
+
data["tags"] = tags
|
|
484
|
+
plugin?.notifyListenersFromImplementation("requireSync", data: data)
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// MARK: - RemoteControllerDelegate
|
|
488
|
+
|
|
489
|
+
// swiftlint:disable:next implicitly_unwrapped_optional
|
|
490
|
+
@objc public func remoteController(_ controller: VDARRemoteController!, didProgress prc: Float, isReady: Bool, folder: String!) {
|
|
491
|
+
var data = JSObject()
|
|
492
|
+
data["progress"] = prc
|
|
493
|
+
plugin?.notifyListenersFromImplementation("syncProgress", data: data)
|
|
494
|
+
}
|
|
495
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import VDARSDK
|
|
4
|
+
|
|
5
|
+
public class PixliveHelper {
|
|
6
|
+
|
|
7
|
+
static func buildTagPriors(_ tags: [[String]]) -> [VDARPrior] {
|
|
8
|
+
var priors: [VDARPrior] = []
|
|
9
|
+
for tagGroup in tags {
|
|
10
|
+
var innerPriors: [VDARPrior] = []
|
|
11
|
+
for tag in tagGroup {
|
|
12
|
+
innerPriors.append(VDARTagPrior(tagName: tag))
|
|
13
|
+
}
|
|
14
|
+
priors.append(VDARIntersectionPrior(priors: innerPriors))
|
|
15
|
+
}
|
|
16
|
+
return priors
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static func buildFullPriors(tags: [[String]], tourIds: [Int], contextIds: [String]) -> [VDARPrior] {
|
|
20
|
+
var priors = buildTagPriors(tags)
|
|
21
|
+
for tourId in tourIds {
|
|
22
|
+
priors.append(VDARTourPrior.tour(withID: Int32(tourId)))
|
|
23
|
+
}
|
|
24
|
+
for contextId in contextIds {
|
|
25
|
+
priors.append(VDARContextPrior(contextID: contextId))
|
|
26
|
+
}
|
|
27
|
+
return priors
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static func contextToJSObject(_ context: VDARContext) -> JSObject {
|
|
31
|
+
var obj = JSObject()
|
|
32
|
+
obj["contextId"] = context.remoteID ?? ""
|
|
33
|
+
obj["name"] = context.name ?? ""
|
|
34
|
+
obj["description"] = context.contextDescription != nil ? context.contextDescription : NSNull()
|
|
35
|
+
if let lastmodif = context.lastmodif {
|
|
36
|
+
obj["lastUpdate"] = "\(lastmodif)"
|
|
37
|
+
} else {
|
|
38
|
+
obj["lastUpdate"] = ""
|
|
39
|
+
}
|
|
40
|
+
obj["imageThumbnailURL"] = context.imageThumbnailURL?.absoluteString ?? NSNull()
|
|
41
|
+
obj["imageHiResURL"] = context.imageHiResURL?.absoluteString ?? NSNull()
|
|
42
|
+
obj["notificationTitle"] = context.notificationTitle != nil ? context.notificationTitle : NSNull()
|
|
43
|
+
obj["notificationMessage"] = context.notificationMessage != nil ? context.notificationMessage : NSNull()
|
|
44
|
+
obj["tags"] = JSArray()
|
|
45
|
+
return obj
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static func gpsPointToJSObject(_ point: VDARGPSPoint) -> JSObject {
|
|
49
|
+
var obj = JSObject()
|
|
50
|
+
obj["contextId"] = point.contextId ?? ""
|
|
51
|
+
obj["category"] = point.category ?? ""
|
|
52
|
+
obj["label"] = point.label ?? ""
|
|
53
|
+
obj["latitude"] = point.lat
|
|
54
|
+
obj["longitude"] = point.lon
|
|
55
|
+
obj["detectionRadius"] = point.detectionRadius > 0 ? point.detectionRadius : NSNull()
|
|
56
|
+
obj["distanceFromCurrentPosition"] = point.distanceFromCurrentPos
|
|
57
|
+
return obj
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static func codeTypeToString(_ codeType: VDARCodeType) -> String {
|
|
61
|
+
if codeType.rawValue == VDAR_CODE_TYPE_NONE.rawValue {
|
|
62
|
+
return "none"
|
|
63
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_EAN2.rawValue {
|
|
64
|
+
return "ean2"
|
|
65
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_EAN5.rawValue {
|
|
66
|
+
return "ean5"
|
|
67
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_EAN8.rawValue {
|
|
68
|
+
return "ean8"
|
|
69
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_UPCE.rawValue {
|
|
70
|
+
return "upce"
|
|
71
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_ISBN10.rawValue {
|
|
72
|
+
return "isbn10"
|
|
73
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_UPCA.rawValue {
|
|
74
|
+
return "upca"
|
|
75
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_EAN13.rawValue {
|
|
76
|
+
return "ean13"
|
|
77
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_ISBN13.rawValue {
|
|
78
|
+
return "isbn13"
|
|
79
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_COMPOSITE.rawValue {
|
|
80
|
+
return "composite"
|
|
81
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_I25.rawValue {
|
|
82
|
+
return "i25"
|
|
83
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_CODE39.rawValue {
|
|
84
|
+
return "code39"
|
|
85
|
+
} else if codeType.rawValue == VDAR_CODE_TYPE_QRCODE.rawValue {
|
|
86
|
+
return "qrcode"
|
|
87
|
+
} else {
|
|
88
|
+
return "unknown"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|