@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,503 @@
|
|
|
1
|
+
import AVFoundation
|
|
2
|
+
import CoreBluetooth
|
|
3
|
+
import CoreLocation
|
|
4
|
+
import Foundation
|
|
5
|
+
import UIKit
|
|
6
|
+
import UserNotifications
|
|
7
|
+
import Capacitor
|
|
8
|
+
|
|
9
|
+
@objc(PixlivePlugin)
|
|
10
|
+
// swiftlint:disable:next type_body_length
|
|
11
|
+
public class PixlivePlugin: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
|
|
12
|
+
public let identifier = "PixlivePlugin"
|
|
13
|
+
public let jsName = "Pixlive"
|
|
14
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
15
|
+
CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise),
|
|
16
|
+
CAPPluginMethod(name: "checkPermissions", returnType: CAPPluginReturnPromise),
|
|
17
|
+
CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise),
|
|
18
|
+
CAPPluginMethod(name: "synchronize", returnType: CAPPluginReturnPromise),
|
|
19
|
+
CAPPluginMethod(name: "synchronizeWithToursAndContexts", returnType: CAPPluginReturnPromise),
|
|
20
|
+
CAPPluginMethod(name: "updateTagMapping", returnType: CAPPluginReturnPromise),
|
|
21
|
+
CAPPluginMethod(name: "enableContextsWithTags", returnType: CAPPluginReturnPromise),
|
|
22
|
+
CAPPluginMethod(name: "getContexts", returnType: CAPPluginReturnPromise),
|
|
23
|
+
CAPPluginMethod(name: "getContext", returnType: CAPPluginReturnPromise),
|
|
24
|
+
CAPPluginMethod(name: "activateContext", returnType: CAPPluginReturnPromise),
|
|
25
|
+
CAPPluginMethod(name: "stopContext", returnType: CAPPluginReturnPromise),
|
|
26
|
+
CAPPluginMethod(name: "getNearbyGPSPoints", returnType: CAPPluginReturnPromise),
|
|
27
|
+
CAPPluginMethod(name: "getGPSPointsInBoundingBox", returnType: CAPPluginReturnPromise),
|
|
28
|
+
CAPPluginMethod(name: "getNearbyBeacons", returnType: CAPPluginReturnPromise),
|
|
29
|
+
CAPPluginMethod(name: "startNearbyGPSDetection", returnType: CAPPluginReturnPromise),
|
|
30
|
+
CAPPluginMethod(name: "stopNearbyGPSDetection", returnType: CAPPluginReturnPromise),
|
|
31
|
+
CAPPluginMethod(name: "startGPSNotifications", returnType: CAPPluginReturnPromise),
|
|
32
|
+
CAPPluginMethod(name: "stopGPSNotifications", returnType: CAPPluginReturnPromise),
|
|
33
|
+
CAPPluginMethod(name: "setNotificationsSupport", returnType: CAPPluginReturnPromise),
|
|
34
|
+
CAPPluginMethod(name: "setInterfaceLanguage", returnType: CAPPluginReturnPromise),
|
|
35
|
+
CAPPluginMethod(name: "createARView", returnType: CAPPluginReturnPromise),
|
|
36
|
+
CAPPluginMethod(name: "destroyARView", returnType: CAPPluginReturnPromise),
|
|
37
|
+
CAPPluginMethod(name: "resizeARView", returnType: CAPPluginReturnPromise),
|
|
38
|
+
CAPPluginMethod(name: "setARViewTouchEnabled", returnType: CAPPluginReturnPromise),
|
|
39
|
+
CAPPluginMethod(name: "setARViewTouchHole", returnType: CAPPluginReturnPromise),
|
|
40
|
+
CAPPluginMethod(name: "getVersion", returnType: CAPPluginReturnPromise)
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
public static let tag = "Pixlive"
|
|
44
|
+
|
|
45
|
+
private var implementation: Pixlive?
|
|
46
|
+
private var locationManager: CLLocationManager?
|
|
47
|
+
private var locationPermissionCallback: (() -> Void)?
|
|
48
|
+
|
|
49
|
+
override public func load() {
|
|
50
|
+
implementation = Pixlive(self)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@objc func initialize(_ call: CAPPluginCall) {
|
|
54
|
+
implementation?.initialize(completion: { error in
|
|
55
|
+
if let error = error {
|
|
56
|
+
self.rejectCall(call, error)
|
|
57
|
+
} else {
|
|
58
|
+
self.resolveCall(call)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@objc override public func checkPermissions(_ call: CAPPluginCall) {
|
|
64
|
+
var result = JSObject()
|
|
65
|
+
result["bluetooth"] = mapBluetoothPermissionState()
|
|
66
|
+
result["camera"] = mapCameraPermissionState()
|
|
67
|
+
result["location"] = mapLocationPermissionState()
|
|
68
|
+
result["notifications"] = "prompt"
|
|
69
|
+
UNUserNotificationCenter.current().getNotificationSettings { settings in
|
|
70
|
+
result["notifications"] = self.mapNotificationPermissionState(settings.authorizationStatus)
|
|
71
|
+
call.resolve(result)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@objc override public func requestPermissions(_ call: CAPPluginCall) {
|
|
76
|
+
let permissions = call.getArray("permissions", String.self) ?? ["bluetooth", "camera", "location", "notifications"]
|
|
77
|
+
let group = DispatchGroup()
|
|
78
|
+
|
|
79
|
+
if permissions.contains("camera") {
|
|
80
|
+
group.enter()
|
|
81
|
+
AVCaptureDevice.requestAccess(for: .video) { _ in
|
|
82
|
+
group.leave()
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if permissions.contains("location") {
|
|
87
|
+
group.enter()
|
|
88
|
+
DispatchQueue.main.async {
|
|
89
|
+
if self.locationManager == nil {
|
|
90
|
+
self.locationManager = CLLocationManager()
|
|
91
|
+
}
|
|
92
|
+
self.locationManager?.delegate = self
|
|
93
|
+
let status = CLLocationManager.authorizationStatus()
|
|
94
|
+
if status != .notDetermined {
|
|
95
|
+
group.leave()
|
|
96
|
+
} else {
|
|
97
|
+
self.locationPermissionCallback = {
|
|
98
|
+
group.leave()
|
|
99
|
+
}
|
|
100
|
+
self.locationManager?.requestAlwaysAuthorization()
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if permissions.contains("notifications") {
|
|
106
|
+
group.enter()
|
|
107
|
+
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { _, _ in
|
|
108
|
+
group.leave()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
group.notify(queue: .main) {
|
|
113
|
+
self.checkPermissions(call)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@objc func synchronize(_ call: CAPPluginCall) {
|
|
118
|
+
do {
|
|
119
|
+
let options = try SynchronizeOptions(call)
|
|
120
|
+
implementation?.synchronize(options, completion: { error in
|
|
121
|
+
if let error = error {
|
|
122
|
+
self.rejectCall(call, error)
|
|
123
|
+
} else {
|
|
124
|
+
self.resolveCall(call)
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
} catch {
|
|
128
|
+
rejectCall(call, error)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@objc func synchronizeWithToursAndContexts(_ call: CAPPluginCall) {
|
|
133
|
+
do {
|
|
134
|
+
let options = try SynchronizeWithToursAndContextsOptions(call)
|
|
135
|
+
implementation?.synchronizeWithToursAndContexts(options, completion: { error in
|
|
136
|
+
if let error = error {
|
|
137
|
+
self.rejectCall(call, error)
|
|
138
|
+
} else {
|
|
139
|
+
self.resolveCall(call)
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
} catch {
|
|
143
|
+
rejectCall(call, error)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@objc func updateTagMapping(_ call: CAPPluginCall) {
|
|
148
|
+
do {
|
|
149
|
+
let options = try UpdateTagMappingOptions(call)
|
|
150
|
+
implementation?.updateTagMapping(options, completion: { error in
|
|
151
|
+
if let error = error {
|
|
152
|
+
self.rejectCall(call, error)
|
|
153
|
+
} else {
|
|
154
|
+
self.resolveCall(call)
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
} catch {
|
|
158
|
+
rejectCall(call, error)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@objc func enableContextsWithTags(_ call: CAPPluginCall) {
|
|
163
|
+
do {
|
|
164
|
+
let options = try EnableContextsWithTagsOptions(call)
|
|
165
|
+
implementation?.enableContextsWithTags(options, completion: { error in
|
|
166
|
+
if let error = error {
|
|
167
|
+
self.rejectCall(call, error)
|
|
168
|
+
} else {
|
|
169
|
+
self.resolveCall(call)
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
} catch {
|
|
173
|
+
rejectCall(call, error)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@objc func getContexts(_ call: CAPPluginCall) {
|
|
178
|
+
implementation?.getContexts(completion: { result, error in
|
|
179
|
+
if let error = error {
|
|
180
|
+
self.rejectCall(call, error)
|
|
181
|
+
} else {
|
|
182
|
+
self.resolveCall(call, result)
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@objc func getContext(_ call: CAPPluginCall) {
|
|
188
|
+
do {
|
|
189
|
+
let options = try GetContextOptions(call)
|
|
190
|
+
implementation?.getContext(options, completion: { result, error in
|
|
191
|
+
if let error = error {
|
|
192
|
+
self.rejectCall(call, error)
|
|
193
|
+
} else {
|
|
194
|
+
self.resolveCall(call, result)
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
} catch {
|
|
198
|
+
rejectCall(call, error)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@objc func activateContext(_ call: CAPPluginCall) {
|
|
203
|
+
do {
|
|
204
|
+
let options = try ActivateContextOptions(call)
|
|
205
|
+
implementation?.activateContext(options, completion: { error in
|
|
206
|
+
if let error = error {
|
|
207
|
+
self.rejectCall(call, error)
|
|
208
|
+
} else {
|
|
209
|
+
self.resolveCall(call)
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
} catch {
|
|
213
|
+
rejectCall(call, error)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@objc func stopContext(_ call: CAPPluginCall) {
|
|
218
|
+
implementation?.stopContext(completion: { error in
|
|
219
|
+
if let error = error {
|
|
220
|
+
self.rejectCall(call, error)
|
|
221
|
+
} else {
|
|
222
|
+
self.resolveCall(call)
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@objc func getNearbyGPSPoints(_ call: CAPPluginCall) {
|
|
228
|
+
do {
|
|
229
|
+
let options = try GetNearbyGPSPointsOptions(call)
|
|
230
|
+
implementation?.getNearbyGPSPoints(options, completion: { result, error in
|
|
231
|
+
if let error = error {
|
|
232
|
+
self.rejectCall(call, error)
|
|
233
|
+
} else {
|
|
234
|
+
self.resolveCall(call, result)
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
} catch {
|
|
238
|
+
rejectCall(call, error)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@objc func getGPSPointsInBoundingBox(_ call: CAPPluginCall) {
|
|
243
|
+
do {
|
|
244
|
+
let options = try GetGPSPointsInBoundingBoxOptions(call)
|
|
245
|
+
implementation?.getGPSPointsInBoundingBox(options, completion: { result, error in
|
|
246
|
+
if let error = error {
|
|
247
|
+
self.rejectCall(call, error)
|
|
248
|
+
} else {
|
|
249
|
+
self.resolveCall(call, result)
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
} catch {
|
|
253
|
+
rejectCall(call, error)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@objc func getNearbyBeacons(_ call: CAPPluginCall) {
|
|
258
|
+
implementation?.getNearbyBeacons(completion: { result, error in
|
|
259
|
+
if let error = error {
|
|
260
|
+
self.rejectCall(call, error)
|
|
261
|
+
} else {
|
|
262
|
+
self.resolveCall(call, result)
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
@objc func startNearbyGPSDetection(_ call: CAPPluginCall) {
|
|
268
|
+
implementation?.startNearbyGPSDetection(completion: { error in
|
|
269
|
+
if let error = error {
|
|
270
|
+
self.rejectCall(call, error)
|
|
271
|
+
} else {
|
|
272
|
+
self.resolveCall(call)
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
@objc func stopNearbyGPSDetection(_ call: CAPPluginCall) {
|
|
278
|
+
implementation?.stopNearbyGPSDetection(completion: { error in
|
|
279
|
+
if let error = error {
|
|
280
|
+
self.rejectCall(call, error)
|
|
281
|
+
} else {
|
|
282
|
+
self.resolveCall(call)
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@objc func startGPSNotifications(_ call: CAPPluginCall) {
|
|
288
|
+
implementation?.startGPSNotifications(completion: { error in
|
|
289
|
+
if let error = error {
|
|
290
|
+
self.rejectCall(call, error)
|
|
291
|
+
} else {
|
|
292
|
+
self.resolveCall(call)
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
@objc func stopGPSNotifications(_ call: CAPPluginCall) {
|
|
298
|
+
implementation?.stopGPSNotifications(completion: { error in
|
|
299
|
+
if let error = error {
|
|
300
|
+
self.rejectCall(call, error)
|
|
301
|
+
} else {
|
|
302
|
+
self.resolveCall(call)
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@objc func setNotificationsSupport(_ call: CAPPluginCall) {
|
|
308
|
+
do {
|
|
309
|
+
let options = try SetNotificationsSupportOptions(call)
|
|
310
|
+
implementation?.setNotificationsSupport(options, completion: { error in
|
|
311
|
+
if let error = error {
|
|
312
|
+
self.rejectCall(call, error)
|
|
313
|
+
} else {
|
|
314
|
+
self.resolveCall(call)
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
} catch {
|
|
318
|
+
rejectCall(call, error)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@objc func setInterfaceLanguage(_ call: CAPPluginCall) {
|
|
323
|
+
do {
|
|
324
|
+
let options = try SetInterfaceLanguageOptions(call)
|
|
325
|
+
implementation?.setInterfaceLanguage(options, completion: { error in
|
|
326
|
+
if let error = error {
|
|
327
|
+
self.rejectCall(call, error)
|
|
328
|
+
} else {
|
|
329
|
+
self.resolveCall(call)
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
} catch {
|
|
333
|
+
rejectCall(call, error)
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
@objc func createARView(_ call: CAPPluginCall) {
|
|
338
|
+
do {
|
|
339
|
+
let options = try CreateARViewOptions(call)
|
|
340
|
+
implementation?.createARView(options, completion: { error in
|
|
341
|
+
if let error = error {
|
|
342
|
+
self.rejectCall(call, error)
|
|
343
|
+
} else {
|
|
344
|
+
self.resolveCall(call)
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
} catch {
|
|
348
|
+
rejectCall(call, error)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
@objc func destroyARView(_ call: CAPPluginCall) {
|
|
353
|
+
implementation?.destroyARView(completion: { error in
|
|
354
|
+
if let error = error {
|
|
355
|
+
self.rejectCall(call, error)
|
|
356
|
+
} else {
|
|
357
|
+
self.resolveCall(call)
|
|
358
|
+
}
|
|
359
|
+
})
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
@objc func resizeARView(_ call: CAPPluginCall) {
|
|
363
|
+
do {
|
|
364
|
+
let options = try ResizeARViewOptions(call)
|
|
365
|
+
implementation?.resizeARView(options, completion: { error in
|
|
366
|
+
if let error = error {
|
|
367
|
+
self.rejectCall(call, error)
|
|
368
|
+
} else {
|
|
369
|
+
self.resolveCall(call)
|
|
370
|
+
}
|
|
371
|
+
})
|
|
372
|
+
} catch {
|
|
373
|
+
rejectCall(call, error)
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
@objc func setARViewTouchEnabled(_ call: CAPPluginCall) {
|
|
378
|
+
do {
|
|
379
|
+
let options = try SetARViewTouchEnabledOptions(call)
|
|
380
|
+
implementation?.setARViewTouchEnabled(options, completion: { error in
|
|
381
|
+
if let error = error {
|
|
382
|
+
self.rejectCall(call, error)
|
|
383
|
+
} else {
|
|
384
|
+
self.resolveCall(call)
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
} catch {
|
|
388
|
+
rejectCall(call, error)
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
@objc func setARViewTouchHole(_ call: CAPPluginCall) {
|
|
393
|
+
do {
|
|
394
|
+
let options = try SetARViewTouchHoleOptions(call)
|
|
395
|
+
implementation?.setARViewTouchHole(options, completion: { error in
|
|
396
|
+
if let error = error {
|
|
397
|
+
self.rejectCall(call, error)
|
|
398
|
+
} else {
|
|
399
|
+
self.resolveCall(call)
|
|
400
|
+
}
|
|
401
|
+
})
|
|
402
|
+
} catch {
|
|
403
|
+
rejectCall(call, error)
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
@objc func getVersion(_ call: CAPPluginCall) {
|
|
408
|
+
implementation?.getVersion(completion: { result, error in
|
|
409
|
+
if let error = error {
|
|
410
|
+
self.rejectCall(call, error)
|
|
411
|
+
} else {
|
|
412
|
+
self.resolveCall(call, result)
|
|
413
|
+
}
|
|
414
|
+
})
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
|
|
418
|
+
let status = CLLocationManager.authorizationStatus()
|
|
419
|
+
if status == .notDetermined {
|
|
420
|
+
return
|
|
421
|
+
}
|
|
422
|
+
if let callback = locationPermissionCallback {
|
|
423
|
+
locationPermissionCallback = nil
|
|
424
|
+
callback()
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
public func notifyListenersFromImplementation(_ eventName: String, data: JSObject) {
|
|
429
|
+
notifyListeners(eventName, data: data)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
private func mapBluetoothPermissionState() -> String {
|
|
433
|
+
if #available(iOS 13.1, *) {
|
|
434
|
+
switch CBCentralManager.authorization {
|
|
435
|
+
case .allowedAlways:
|
|
436
|
+
return "granted"
|
|
437
|
+
case .denied, .restricted:
|
|
438
|
+
return "denied"
|
|
439
|
+
case .notDetermined:
|
|
440
|
+
return "prompt"
|
|
441
|
+
@unknown default:
|
|
442
|
+
return "prompt"
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return "granted"
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
private func mapLocationPermissionState() -> String {
|
|
449
|
+
switch CLLocationManager.authorizationStatus() {
|
|
450
|
+
case .authorizedAlways, .authorizedWhenInUse:
|
|
451
|
+
return "granted"
|
|
452
|
+
case .denied, .restricted:
|
|
453
|
+
return "denied"
|
|
454
|
+
case .notDetermined:
|
|
455
|
+
return "prompt"
|
|
456
|
+
@unknown default:
|
|
457
|
+
return "prompt"
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
private func mapCameraPermissionState() -> String {
|
|
462
|
+
switch AVCaptureDevice.authorizationStatus(for: .video) {
|
|
463
|
+
case .authorized:
|
|
464
|
+
return "granted"
|
|
465
|
+
case .denied, .restricted:
|
|
466
|
+
return "denied"
|
|
467
|
+
case .notDetermined:
|
|
468
|
+
return "prompt"
|
|
469
|
+
@unknown default:
|
|
470
|
+
return "prompt"
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
private func mapNotificationPermissionState(_ status: UNAuthorizationStatus) -> String {
|
|
475
|
+
switch status {
|
|
476
|
+
case .authorized, .provisional, .ephemeral:
|
|
477
|
+
return "granted"
|
|
478
|
+
case .denied:
|
|
479
|
+
return "denied"
|
|
480
|
+
case .notDetermined:
|
|
481
|
+
return "prompt"
|
|
482
|
+
@unknown default:
|
|
483
|
+
return "prompt"
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
private func rejectCall(_ call: CAPPluginCall, _ error: Error) {
|
|
488
|
+
CAPLog.print("[", PixlivePlugin.tag, "] ", error)
|
|
489
|
+
call.reject(error.localizedDescription)
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
private func resolveCall(_ call: CAPPluginCall) {
|
|
493
|
+
call.resolve()
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
private func resolveCall(_ call: CAPPluginCall, _ result: Result?) {
|
|
497
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
498
|
+
call.resolve(result)
|
|
499
|
+
} else {
|
|
500
|
+
call.resolve()
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
class TouchForwarderView: UIView {
|
|
4
|
+
|
|
5
|
+
var touchEnabled = false
|
|
6
|
+
var touchHole: CGRect?
|
|
7
|
+
weak var arView: UIView?
|
|
8
|
+
|
|
9
|
+
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
|
10
|
+
guard touchEnabled, let arView = arView, arView.superview != nil, !arView.isHidden else {
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
13
|
+
let arPoint = convert(point, to: arView)
|
|
14
|
+
if touchHole != nil && touchHole!.contains(arPoint) {
|
|
15
|
+
return true
|
|
16
|
+
}
|
|
17
|
+
if arPoint.x >= 0 && arPoint.y >= 0
|
|
18
|
+
&& arPoint.x < arView.frame.size.width
|
|
19
|
+
&& arPoint.y < arView.frame.size.height {
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capawesome/capacitor-pixlive",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Unofficial Capacitor plugin for Pixlive SDK.",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Plugin/",
|
|
14
|
+
"CapawesomeCapacitorPixlive.podspec",
|
|
15
|
+
"Package.swift"
|
|
16
|
+
],
|
|
17
|
+
"author": "Robin Genz <mail@robingenz.dev>",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/capawesome-team/capacitor-plugins.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/capawesome-team/capacitor-plugins/issues"
|
|
25
|
+
},
|
|
26
|
+
"funding": [
|
|
27
|
+
{
|
|
28
|
+
"type": "github",
|
|
29
|
+
"url": "https://github.com/sponsors/capawesome-team/"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "opencollective",
|
|
33
|
+
"url": "https://opencollective.com/capawesome"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"keywords": [
|
|
37
|
+
"capacitor",
|
|
38
|
+
"plugin",
|
|
39
|
+
"native"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
43
|
+
"verify:ios": "if [ \"$CI\" = \"true\" ]; then echo 'Skipping iOS verify (SDK not available in CI)'; else cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..; fi",
|
|
44
|
+
"verify:android": "if [ \"$CI\" = \"true\" ]; then echo 'Skipping Android verify (SDK not available in CI)'; else cd android && ./gradlew clean build test && cd ..; fi",
|
|
45
|
+
"verify:web": "npm run build",
|
|
46
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
47
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
48
|
+
"eslint": "eslint . --ext ts",
|
|
49
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
50
|
+
"swiftlint": "node-swiftlint",
|
|
51
|
+
"docgen": "docgen --api PixlivePlugin --output-readme README.md --output-json dist/docs.json",
|
|
52
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
53
|
+
"clean": "rimraf ./dist",
|
|
54
|
+
"watch": "tsc --watch",
|
|
55
|
+
"ios:pod:install": "cd ios && pod install --repo-update && cd ..",
|
|
56
|
+
"ios:spm:install": "cd ios && swift package resolve && cd ..",
|
|
57
|
+
"prepublishOnly": "npm run build"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@capacitor/android": "8.0.0",
|
|
61
|
+
"@capacitor/cli": "8.0.0",
|
|
62
|
+
"@capacitor/core": "8.0.0",
|
|
63
|
+
"@capacitor/docgen": "0.3.1",
|
|
64
|
+
"@capacitor/ios": "8.0.0",
|
|
65
|
+
"@ionic/eslint-config": "0.4.0",
|
|
66
|
+
"@ionic/swiftlint-config": "2.0.0",
|
|
67
|
+
"eslint": "8.57.0",
|
|
68
|
+
"prettier": "3.4.2",
|
|
69
|
+
"prettier-plugin-java": "2.6.7",
|
|
70
|
+
"rimraf": "6.1.2",
|
|
71
|
+
"rollup": "4.53.3",
|
|
72
|
+
"swiftlint": "2.0.0",
|
|
73
|
+
"typescript": "5.9.3"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"@capacitor/core": ">=8.0.0"
|
|
77
|
+
},
|
|
78
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
79
|
+
"eslintConfig": {
|
|
80
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
81
|
+
},
|
|
82
|
+
"capacitor": {
|
|
83
|
+
"ios": {
|
|
84
|
+
"src": "ios"
|
|
85
|
+
},
|
|
86
|
+
"android": {
|
|
87
|
+
"src": "android"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"publishConfig": {
|
|
91
|
+
"access": "public"
|
|
92
|
+
}
|
|
93
|
+
}
|