@woosmap/react-native-plugin-geofencing 0.1.4 → 0.1.7
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/README.md +219 -20
- package/android/build.gradle +7 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +328 -35
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +20 -3
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapTask.java +299 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +108 -0
- package/ios/DataDistance.swift +14 -23
- package/ios/DataLocation.swift +16 -0
- package/ios/DataPOI.swift +11 -0
- package/ios/DataRegion.swift +32 -29
- package/ios/MarketingCloudEvents.swift +6 -6
- package/ios/PluginGeofencing.m +43 -0
- package/ios/PluginGeofencing.swift +380 -26
- package/ios/WoosmapGeofenceMessage.swift +12 -0
- package/ios/WoosmapGeofenceService.swift +203 -30
- package/lib/commonjs/index.js +171 -68
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/{Airship.js → internal/Airship.js} +0 -0
- package/lib/commonjs/{Airship.js.map → internal/Airship.js.map} +0 -0
- package/lib/commonjs/{Location.js → internal/Location.js} +0 -0
- package/lib/commonjs/{Location.js.map → internal/Location.js.map} +0 -0
- package/lib/commonjs/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
- package/lib/commonjs/{MarketingCloud.js.map → internal/MarketingCloud.js.map} +0 -0
- package/lib/{module → commonjs/internal}/Poi.js +10 -1
- package/lib/commonjs/internal/Poi.js.map +1 -0
- package/lib/commonjs/{Region.js → internal/Region.js} +0 -0
- package/lib/commonjs/{Region.js.map → internal/Region.js.map} +0 -0
- package/lib/commonjs/{Visit.js → internal/Visit.js} +0 -0
- package/lib/commonjs/{Visit.js.map → internal/Visit.js.map} +0 -0
- package/lib/commonjs/{Zoi.js → internal/Zoi.js} +0 -0
- package/lib/commonjs/{Zoi.js.map → internal/Zoi.js.map} +0 -0
- package/lib/commonjs/internal/nativeInterface.js +18 -0
- package/lib/commonjs/internal/nativeInterface.js.map +1 -0
- package/lib/commonjs/internal/types.js +2 -0
- package/lib/commonjs/internal/types.js.map +1 -0
- package/lib/module/index.js +155 -53
- package/lib/module/index.js.map +1 -1
- package/lib/module/{Airship.js → internal/Airship.js} +0 -0
- package/lib/module/{Airship.js.map → internal/Airship.js.map} +0 -0
- package/lib/module/{Location.js → internal/Location.js} +0 -0
- package/lib/module/{Location.js.map → internal/Location.js.map} +0 -0
- package/lib/module/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
- package/lib/module/{MarketingCloud.js.map → internal/MarketingCloud.js.map} +0 -0
- package/lib/{commonjs → module/internal}/Poi.js +2 -3
- package/lib/module/internal/Poi.js.map +1 -0
- package/lib/module/{Region.js → internal/Region.js} +0 -0
- package/lib/module/{Region.js.map → internal/Region.js.map} +0 -0
- package/lib/module/{Visit.js → internal/Visit.js} +0 -0
- package/lib/module/{Visit.js.map → internal/Visit.js.map} +0 -0
- package/lib/module/{Zoi.js → internal/Zoi.js} +0 -0
- package/lib/module/{Zoi.js.map → internal/Zoi.js.map} +0 -0
- package/lib/module/internal/nativeInterface.js +9 -0
- package/lib/module/internal/nativeInterface.js.map +1 -0
- package/lib/module/internal/types.js +2 -0
- package/lib/module/internal/types.js.map +1 -0
- package/lib/typescript/index.d.ts +63 -4
- package/lib/typescript/{Airship.d.ts → internal/Airship.d.ts} +0 -0
- package/lib/typescript/{Location.d.ts → internal/Location.d.ts} +0 -0
- package/lib/typescript/{MarketingCloud.d.ts → internal/MarketingCloud.d.ts} +0 -0
- package/lib/typescript/{Poi.d.ts → internal/Poi.d.ts} +4 -2
- package/lib/typescript/{Region.d.ts → internal/Region.d.ts} +0 -0
- package/lib/typescript/{Visit.d.ts → internal/Visit.d.ts} +0 -0
- package/lib/typescript/{Zoi.d.ts → internal/Zoi.d.ts} +0 -0
- package/lib/typescript/internal/nativeInterface.d.ts +2 -0
- package/lib/typescript/internal/types.d.ts +18 -0
- package/package.json +1 -1
- package/src/index.tsx +173 -53
- package/src/{Airship.tsx → internal/Airship.tsx} +0 -0
- package/src/{Location.tsx → internal/Location.tsx} +0 -0
- package/src/{MarketingCloud.tsx → internal/MarketingCloud.tsx} +0 -0
- package/src/{Poi.tsx → internal/Poi.tsx} +4 -3
- package/src/{Region.tsx → internal/Region.tsx} +0 -0
- package/src/{Visit.tsx → internal/Visit.tsx} +0 -0
- package/src/{Zoi.tsx → internal/Zoi.tsx} +0 -0
- package/src/internal/nativeInterface.tsx +8 -0
- package/src/internal/types.tsx +20 -0
- package/lib/commonjs/Poi.js.map +0 -1
- package/lib/module/Poi.js.map +0 -1
|
@@ -17,7 +17,14 @@ import AirshipCore
|
|
|
17
17
|
@objc(WoosmapGeofenceService) public class WoosmapGeofenceService: NSObject {
|
|
18
18
|
|
|
19
19
|
/// Share object for WoosmapGeofenceService
|
|
20
|
-
@objc static var shared: WoosmapGeofenceService?
|
|
20
|
+
@objc static var shared: WoosmapGeofenceService? {
|
|
21
|
+
get {
|
|
22
|
+
return _shared
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
private static var _shared: WoosmapGeofenceService?
|
|
21
28
|
private var woosmapKey: String = ""
|
|
22
29
|
private var defaultProfile: String = ""
|
|
23
30
|
private let dataLocation = DataLocation()
|
|
@@ -27,7 +34,7 @@ import AirshipCore
|
|
|
27
34
|
private let dataVisit = DataVisit()
|
|
28
35
|
private let airshipEvents = AirshipEvents()
|
|
29
36
|
private let marketingCloudEvents = MarketingCloudEvents()
|
|
30
|
-
|
|
37
|
+
|
|
31
38
|
private var defaultPOIRadius: String {
|
|
32
39
|
get {
|
|
33
40
|
let defaults = UserDefaults.standard
|
|
@@ -39,7 +46,7 @@ import AirshipCore
|
|
|
39
46
|
defaults.set(newValue, forKey: "WoosmapGeofenceService.poiradius")
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
|
-
|
|
49
|
+
|
|
43
50
|
/// Status of search api On/Off
|
|
44
51
|
@objc public var searchAPIRequestEnable: Bool {
|
|
45
52
|
get {
|
|
@@ -160,14 +167,15 @@ import AirshipCore
|
|
|
160
167
|
/// - configurationProfile: configuration profile
|
|
161
168
|
@objc public static func setup(woosmapKey: String, configurationProfile: String) {
|
|
162
169
|
DispatchQueue.main.async {
|
|
163
|
-
|
|
170
|
+
_shared = WoosmapGeofenceService.init( woosmapKey, configurationProfile)
|
|
171
|
+
|
|
164
172
|
}
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
/// Creating instance for woosGeofencing service
|
|
168
176
|
@objc public static func setup() {
|
|
169
177
|
DispatchQueue.main.async {
|
|
170
|
-
|
|
178
|
+
_shared = WoosmapGeofenceService.init( "", "")
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
181
|
|
|
@@ -179,8 +187,9 @@ import AirshipCore
|
|
|
179
187
|
throw WoosGeofenceError(WoosmapGeofenceMessage.invalidWoosmapKey)
|
|
180
188
|
} else {
|
|
181
189
|
self.woosmapKey = key
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
DispatchQueue.main.async {
|
|
191
|
+
WoosmapGeofencing.shared.setWoosmapAPIKey(key: self.woosmapKey)
|
|
192
|
+
}
|
|
184
193
|
let defaults = UserDefaults.standard
|
|
185
194
|
defaults.set(key, forKey: "WoosmapGeofenceService.woosmap")
|
|
186
195
|
}
|
|
@@ -191,7 +200,9 @@ import AirshipCore
|
|
|
191
200
|
/// - Throws: in case of wrong profile provided it return error invalidProfile
|
|
192
201
|
public func startTracking(profile: String) throws {
|
|
193
202
|
if let savedProfile = ConfigurationProfile(rawValue: profile) {
|
|
194
|
-
|
|
203
|
+
DispatchQueue.main.async {
|
|
204
|
+
WoosmapGeofencing.shared.startTracking(configurationProfile: savedProfile)
|
|
205
|
+
}
|
|
195
206
|
self.defaultProfile = profile
|
|
196
207
|
let defaults = UserDefaults.standard
|
|
197
208
|
defaults.set(profile, forKey: "WoosmapGeofenceService.profile")
|
|
@@ -202,7 +213,7 @@ import AirshipCore
|
|
|
202
213
|
defaults.set(self.defaultProfile, forKey: "WoosmapGeofenceService.profile")
|
|
203
214
|
throw WoosGeofenceError(WoosmapGeofenceMessage.invalidProfile)
|
|
204
215
|
}
|
|
205
|
-
print ("Highfrequency \(WoosmapGeofencing.shared.getModeHighfrequencyLocation()) , TrackingState \(WoosmapGeofencing.shared.getTrackingState()) ")
|
|
216
|
+
// print ("Highfrequency \(WoosmapGeofencing.shared.getModeHighfrequencyLocation()) , TrackingState \(WoosmapGeofencing.shared.getTrackingState()) ")
|
|
206
217
|
}
|
|
207
218
|
|
|
208
219
|
/// Stop tracking
|
|
@@ -226,25 +237,25 @@ import AirshipCore
|
|
|
226
237
|
|
|
227
238
|
// Set delagate for Airship Cloud
|
|
228
239
|
WoosmapGeofencing.shared.getLocationService().airshipEventsDelegate = airshipEvents
|
|
229
|
-
|
|
240
|
+
|
|
230
241
|
|
|
231
242
|
// Set delagate for Marketing Cloud
|
|
232
243
|
WoosmapGeofencing.shared.getLocationService().marketingCloudEventsDelegate = marketingCloudEvents
|
|
233
244
|
if defaultPOIRadius != "" {
|
|
234
245
|
WoosmapGeofencing.shared.setPoiRadius(radius: formatedRadius(radius: defaultPOIRadius))
|
|
235
246
|
}
|
|
236
|
-
|
|
247
|
+
|
|
237
248
|
if let savedProfile = ConfigurationProfile(rawValue: defaultProfile) {
|
|
238
249
|
WoosmapGeofencing.shared.startTracking(configurationProfile: savedProfile)
|
|
239
250
|
}
|
|
240
|
-
else{ //Default tracking
|
|
241
|
-
WoosmapGeofencing.shared.startTracking(configurationProfile: ConfigurationProfile.passiveTracking)
|
|
242
|
-
}
|
|
251
|
+
// else{ //Default tracking
|
|
252
|
+
// WoosmapGeofencing.shared.startTracking(configurationProfile: ConfigurationProfile.passiveTracking)
|
|
253
|
+
// }
|
|
243
254
|
// Check if the authorization Status of location Manager
|
|
244
255
|
if CLLocationManager.authorizationStatus() != .notDetermined {
|
|
245
256
|
WoosmapGeofencing.shared.startMonitoringInBackground()
|
|
246
257
|
}
|
|
247
|
-
|
|
258
|
+
|
|
248
259
|
NotificationCenter.default.addObserver(self,
|
|
249
260
|
selector: #selector(appDidBecomeActive),
|
|
250
261
|
name: UIApplication.didBecomeActiveNotification,
|
|
@@ -255,12 +266,10 @@ import AirshipCore
|
|
|
255
266
|
NotificationCenter.default.addObserver(self, selector: #selector(appWillTerminate), name: UIApplication.willTerminateNotification, object: nil)
|
|
256
267
|
|
|
257
268
|
// MARK: Only for testing
|
|
258
|
-
self.searchAPIRequestEnable = true
|
|
259
|
-
self.distanceAPIRequestEnable = true
|
|
260
|
-
self.searchAPICreationRegionEnable = true
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
print ("\(WoosmapGeofencing.shared.getModeHighfrequencyLocation()) \(WoosmapGeofencing.shared.getTrackingState()) ")
|
|
269
|
+
// self.searchAPIRequestEnable = true
|
|
270
|
+
// self.distanceAPIRequestEnable = true
|
|
271
|
+
// self.searchAPICreationRegionEnable = true
|
|
272
|
+
// print ("\(WoosmapGeofencing.shared.getModeHighfrequencyLocation()) \(WoosmapGeofencing.shared.getTrackingState()) ")
|
|
264
273
|
}
|
|
265
274
|
|
|
266
275
|
/// Adding new region
|
|
@@ -268,9 +277,10 @@ import AirshipCore
|
|
|
268
277
|
/// - identifier: Region id
|
|
269
278
|
/// - center: geoLocation point
|
|
270
279
|
/// - radius: radius of region
|
|
280
|
+
/// - type: String circle/isochrone
|
|
271
281
|
/// - Returns: Status for reagion created or not and new region id from system
|
|
272
|
-
public func addRegion(identifier: String, center: CLLocationCoordinate2D, radius:
|
|
273
|
-
return WoosmapGeofencing.shared.locationService.addRegion(identifier: identifier, center: center, radius: radius)
|
|
282
|
+
public func addRegion(identifier: String, center: CLLocationCoordinate2D, radius: Int, type: String) -> (isCreate: Bool, identifier: String) {
|
|
283
|
+
return WoosmapGeofencing.shared.locationService.addRegion(identifier: identifier, center: center, radius: radius, type:type)
|
|
274
284
|
}
|
|
275
285
|
|
|
276
286
|
/// Remove region from system
|
|
@@ -332,6 +342,11 @@ import AirshipCore
|
|
|
332
342
|
let locations = DataLocation().readLocations()
|
|
333
343
|
return locations
|
|
334
344
|
}
|
|
345
|
+
|
|
346
|
+
public func getLocations(id:String) -> Location? {
|
|
347
|
+
let locations = DataLocation().readLocations(id: id)
|
|
348
|
+
return locations
|
|
349
|
+
}
|
|
335
350
|
|
|
336
351
|
/// List all POIs capture by system
|
|
337
352
|
/// - Returns: Array of POIs
|
|
@@ -339,6 +354,13 @@ import AirshipCore
|
|
|
339
354
|
let poi = DataPOI().readPOI()
|
|
340
355
|
return poi
|
|
341
356
|
}
|
|
357
|
+
|
|
358
|
+
/// List all POIs capture by system
|
|
359
|
+
/// - Returns: Array of POIs
|
|
360
|
+
public func getPOIs(id:String) -> POI? {
|
|
361
|
+
let poi = DataPOI().readPOI(id: id)
|
|
362
|
+
return poi
|
|
363
|
+
}
|
|
342
364
|
|
|
343
365
|
/// List all intrest zone capture by system
|
|
344
366
|
/// - Returns: Array of zones
|
|
@@ -350,10 +372,80 @@ import AirshipCore
|
|
|
350
372
|
/// List all region capture by system
|
|
351
373
|
/// - Returns: Array of regions
|
|
352
374
|
public func getRegions() -> [Region] {
|
|
353
|
-
|
|
375
|
+
var regions = DataRegion().readRegions()
|
|
376
|
+
let IsochroneRegion = DataRegion().readIsochroneRegions()
|
|
377
|
+
IsochroneRegion.forEach { item in
|
|
378
|
+
let customRegion = Region()
|
|
379
|
+
customRegion.identifier = item.identifier ?? "-"
|
|
380
|
+
customRegion.latitude = item.latitude
|
|
381
|
+
customRegion.longitude = item.longitude
|
|
382
|
+
customRegion.radius = Double(item.radius)
|
|
383
|
+
customRegion.type = item.type
|
|
384
|
+
regions.append(customRegion)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if let locationService = WoosmapGeofencing.shared.locationService{
|
|
388
|
+
if let customRegion = locationService.locationManager?.monitoredRegions{
|
|
389
|
+
customRegion.forEach { item in
|
|
390
|
+
if(locationService.getRegionType(identifier: item.identifier) == LocationService.RegionType.custom){
|
|
391
|
+
let customRegion = Region()
|
|
392
|
+
customRegion.identifier = item.identifier
|
|
393
|
+
if let circleRegion = item as? CLCircularRegion{
|
|
394
|
+
customRegion.latitude = circleRegion.center.latitude
|
|
395
|
+
customRegion.longitude = circleRegion.center.longitude
|
|
396
|
+
customRegion.radius = circleRegion.radius
|
|
397
|
+
customRegion.type = "circle"
|
|
398
|
+
}
|
|
399
|
+
regions.append(customRegion)
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
354
404
|
return regions
|
|
355
405
|
}
|
|
356
|
-
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
/// Return region info
|
|
409
|
+
/// - Parameter id: region id
|
|
410
|
+
/// - Returns: Region
|
|
411
|
+
public func getRegions(id:String) -> Region? {
|
|
412
|
+
if let locationService = WoosmapGeofencing.shared.locationService{
|
|
413
|
+
if(locationService.getRegionType(identifier: id) == LocationService.RegionType.custom){
|
|
414
|
+
if let customRegions = locationService.locationManager?.monitoredRegions{
|
|
415
|
+
if let watchRegion = customRegions.first(where: { item in
|
|
416
|
+
return item.identifier == id
|
|
417
|
+
}){
|
|
418
|
+
let customRegion = Region()
|
|
419
|
+
customRegion.identifier = watchRegion.identifier
|
|
420
|
+
if let circleRegion = watchRegion as? CLCircularRegion{
|
|
421
|
+
customRegion.latitude = circleRegion.center.latitude
|
|
422
|
+
customRegion.longitude = circleRegion.center.longitude
|
|
423
|
+
customRegion.radius = circleRegion.radius
|
|
424
|
+
customRegion.type = "circle"
|
|
425
|
+
}
|
|
426
|
+
return customRegion
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if let regions = DataRegion().readRegions(id: id){
|
|
433
|
+
return regions
|
|
434
|
+
}
|
|
435
|
+
if let regions = DataRegion().readIsochroneRegions(id: id){
|
|
436
|
+
|
|
437
|
+
let customRegion = Region()
|
|
438
|
+
customRegion.identifier = regions.identifier ?? "-"
|
|
439
|
+
customRegion.latitude = regions.latitude
|
|
440
|
+
customRegion.longitude = regions.longitude
|
|
441
|
+
customRegion.radius = Double(regions.radius)
|
|
442
|
+
customRegion.type = regions.type
|
|
443
|
+
return customRegion
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return nil
|
|
447
|
+
}
|
|
448
|
+
|
|
357
449
|
/// List all visits capture by system
|
|
358
450
|
/// - Returns: Array of visits
|
|
359
451
|
public func getVisits() -> [Visit] {
|
|
@@ -370,9 +462,13 @@ import AirshipCore
|
|
|
370
462
|
public func deleteZoi() {
|
|
371
463
|
DataZOI().eraseZOIs()
|
|
372
464
|
}
|
|
465
|
+
/// Delete all POI from system
|
|
466
|
+
public func deletePOI() {
|
|
467
|
+
DataPOI().erasePOI()
|
|
468
|
+
}
|
|
373
469
|
|
|
374
470
|
/// Delete all location from system
|
|
375
|
-
public func
|
|
471
|
+
public func deleteAllLocations() {
|
|
376
472
|
DataLocation().eraseLocations()
|
|
377
473
|
// Native SDK Works independently
|
|
378
474
|
// DataPOI().erasePOI()
|
|
@@ -388,10 +484,24 @@ import AirshipCore
|
|
|
388
484
|
WoosmapGeofencing.shared.locationService.removeRegions(type: LocationService.RegionType.poi)
|
|
389
485
|
}
|
|
390
486
|
|
|
487
|
+
/// Delete regions by id
|
|
488
|
+
/// - Parameter id: region id
|
|
489
|
+
/// - Returns: deleted
|
|
490
|
+
public func deleteRegions(id:String) throws {
|
|
491
|
+
if isRegionIDExist(id: id){
|
|
492
|
+
DataRegion().eraseRegions(id: id)
|
|
493
|
+
WoosmapGeofencing.shared.locationService.removeRegion(identifier: id)
|
|
494
|
+
}
|
|
495
|
+
else{
|
|
496
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.regionid_notexist )
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
}
|
|
500
|
+
|
|
391
501
|
/// Delete all regions
|
|
392
502
|
public func deleteAllRegion() {
|
|
393
|
-
WoosmapGeofencing.shared.locationService.removeRegions(type: LocationService.RegionType.none)
|
|
394
503
|
DataRegion().eraseRegions()
|
|
504
|
+
WoosmapGeofencing.shared.locationService.removeRegions(type: LocationService.RegionType.none)
|
|
395
505
|
}
|
|
396
506
|
|
|
397
507
|
@objc static public func mockdata() {
|
|
@@ -400,7 +510,7 @@ import AirshipCore
|
|
|
400
510
|
}
|
|
401
511
|
MockDataVisit().mockVisitData()
|
|
402
512
|
}
|
|
403
|
-
|
|
513
|
+
|
|
404
514
|
/// Setting up SFMCCredentials
|
|
405
515
|
/// - Parameter credentials: Key/value pair for credentials settings
|
|
406
516
|
/// - Throws: Error for required keys
|
|
@@ -437,7 +547,7 @@ import AirshipCore
|
|
|
437
547
|
self.defaultPOIRadius = radius
|
|
438
548
|
WoosmapGeofencing.shared.setPoiRadius(radius: formatedRadius(radius: radius))
|
|
439
549
|
}
|
|
440
|
-
|
|
550
|
+
|
|
441
551
|
/// Format String value to proper datatype
|
|
442
552
|
/// - Parameter radius: radius of POI
|
|
443
553
|
/// - Returns: Formatted radius
|
|
@@ -452,11 +562,74 @@ import AirshipCore
|
|
|
452
562
|
return radius
|
|
453
563
|
}
|
|
454
564
|
}
|
|
565
|
+
private func isRegionIDExist(id: String) -> Bool{
|
|
566
|
+
if let _ = getRegions(id: id){
|
|
567
|
+
return true
|
|
568
|
+
}
|
|
569
|
+
return false
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
public func startCustomTracking(mode: String, source:String, completion: @escaping (_ Value: Bool, _ Error: WoosGeofenceError?)->()){
|
|
573
|
+
DispatchQueue.main.async {
|
|
574
|
+
if(mode == "local"){
|
|
575
|
+
let bundle = Bundle.main //Bundle(for: Self.self)
|
|
576
|
+
if let url = bundle.url(forResource: source, withExtension: nil){
|
|
577
|
+
let (status,errors) = WoosmapGeofencing.shared.startCustomTracking(url: url.absoluteString)
|
|
578
|
+
if(status == false){
|
|
579
|
+
completion(false,WoosGeofenceError(errors[0]))
|
|
580
|
+
}
|
|
581
|
+
else{
|
|
582
|
+
completion(true,nil)
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
else{
|
|
586
|
+
completion(false,WoosGeofenceError(WoosmapGeofenceMessage.invalid_profilefile))
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
else if(mode == "external"){
|
|
590
|
+
let (status,errors) = WoosmapGeofencing.shared.startCustomTracking(url: source)
|
|
591
|
+
if(status == false){
|
|
592
|
+
completion(false,WoosGeofenceError(errors[0]))
|
|
593
|
+
}
|
|
594
|
+
else{
|
|
595
|
+
completion(true,nil)
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
else{
|
|
599
|
+
completion(false,WoosGeofenceError(WoosmapGeofenceMessage.invalid_profilesourcetype))
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
public func startCustomTracking1(mode: String, source:String) throws{
|
|
605
|
+
if(mode == "local"){
|
|
606
|
+
let bundle = Bundle.main //Bundle(for: Self.self)
|
|
607
|
+
if let url = bundle.url(forResource: source, withExtension: nil){
|
|
608
|
+
let (status,errors) = WoosmapGeofencing.shared.startCustomTracking(url: url.absoluteString)
|
|
609
|
+
if(status == false){
|
|
610
|
+
throw WoosGeofenceError(errors[0])
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
else{
|
|
614
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.invalid_profilefile)
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
else if(mode == "external"){
|
|
618
|
+
let (status,errors) = WoosmapGeofencing.shared.startCustomTracking(url: source)
|
|
619
|
+
if(status == false){
|
|
620
|
+
throw WoosGeofenceError(errors[0])
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
else{
|
|
624
|
+
throw WoosGeofenceError(WoosmapGeofenceMessage.invalid_profilesourcetype )
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
}
|
|
455
628
|
|
|
456
629
|
}
|
|
457
630
|
|
|
458
631
|
/// WoosGeofense error
|
|
459
|
-
struct WoosGeofenceError: Error {
|
|
632
|
+
public struct WoosGeofenceError: Error {
|
|
460
633
|
|
|
461
634
|
/// Error info
|
|
462
635
|
let message: String
|