@woosmap/react-native-plugin-geofencing 0.2.5 → 0.4.0

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.
Files changed (33) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +135 -5
  3. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +3 -0
  4. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapTask.java +50 -3
  5. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +35 -0
  6. package/ios/DataPOI.swift +6 -0
  7. package/ios/PluginGeofencing.m +10 -0
  8. package/ios/PluginGeofencing.swift +88 -0
  9. package/ios/WoosmapGeofenceMessage.swift +2 -0
  10. package/ios/WoosmapGeofenceService.swift +98 -68
  11. package/lib/commonjs/index.js +97 -8
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/internal/IndoorBeacon.js +76 -0
  14. package/lib/commonjs/internal/IndoorBeacon.js.map +1 -0
  15. package/lib/commonjs/internal/Location.js +1 -2
  16. package/lib/commonjs/internal/Location.js.map +1 -1
  17. package/lib/commonjs/internal/Poi.js +5 -4
  18. package/lib/commonjs/internal/Poi.js.map +1 -1
  19. package/lib/commonjs/internal/Region.js +1 -2
  20. package/lib/commonjs/internal/Region.js.map +1 -1
  21. package/lib/commonjs/internal/nativeInterface.js +1 -2
  22. package/lib/commonjs/internal/nativeInterface.js.map +1 -1
  23. package/lib/module/index.js +97 -7
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/internal/IndoorBeacon.js +70 -0
  26. package/lib/module/internal/IndoorBeacon.js.map +1 -0
  27. package/lib/module/internal/Poi.js +4 -2
  28. package/lib/module/internal/Poi.js.map +1 -1
  29. package/lib/typescript/index.d.ts +29 -1
  30. package/lib/typescript/internal/IndoorBeacon.d.ts +49 -0
  31. package/lib/typescript/internal/Poi.d.ts +2 -1
  32. package/package.json +3 -3
  33. package/react-native-plugin-geofencing.podspec +1 -1
@@ -48,10 +48,10 @@ import WoosmapGeofencing
48
48
  /// Status of search api On/Off
49
49
  @objc public var searchAPIRequestEnable: Bool {
50
50
  get {
51
- return WoosmapGeofencing.shared.getSearchAPIRequestEnable()
51
+ return WoosmapGeofenceManager.shared.getSearchAPIRequestEnable()
52
52
  }
53
53
  set {
54
- WoosmapGeofencing.shared.setSearchAPIRequestEnable(enable: newValue)
54
+ WoosmapGeofenceManager.shared.setSearchAPIRequestEnable(enable: newValue)
55
55
 
56
56
  }
57
57
  }
@@ -59,10 +59,10 @@ import WoosmapGeofencing
59
59
  /// Status of distance api On/Off
60
60
  @objc public var distanceAPIRequestEnable: Bool {
61
61
  get {
62
- return WoosmapGeofencing.shared.getDistanceAPIRequestEnable()
62
+ return WoosmapGeofenceManager.shared.getDistanceAPIRequestEnable()
63
63
  }
64
64
  set {
65
- WoosmapGeofencing.shared.setDistanceAPIRequestEnable(enable: newValue)
65
+ WoosmapGeofenceManager.shared.setDistanceAPIRequestEnable(enable: newValue)
66
66
 
67
67
  }
68
68
  }
@@ -70,10 +70,10 @@ import WoosmapGeofencing
70
70
  /// status of CreationRegionEnable. On/Off
71
71
  @objc public var searchAPICreationRegionEnable: Bool {
72
72
  get {
73
- return WoosmapGeofencing.shared.getSearchAPICreationRegionEnable()
73
+ return WoosmapGeofenceManager.shared.getSearchAPICreationRegionEnable()
74
74
  }
75
75
  set {
76
- WoosmapGeofencing.shared.setSearchAPICreationRegionEnable(enable: newValue)
76
+ WoosmapGeofenceManager.shared.setSearchAPICreationRegionEnable(enable: newValue)
77
77
 
78
78
  }
79
79
  }
@@ -81,20 +81,20 @@ import WoosmapGeofencing
81
81
  /// Status of HighfrequencyLocation Mode. On/Off
82
82
  @objc public var modeHighfrequencyLocation: Bool {
83
83
  get {
84
- return WoosmapGeofencing.shared.getModeHighfrequencyLocation()
84
+ return WoosmapGeofenceManager.shared.getModeHighfrequencyLocation()
85
85
  }
86
86
  set {
87
- WoosmapGeofencing.shared.setModeHighfrequencyLocation(enable: newValue)
87
+ WoosmapGeofenceManager.shared.setModeHighfrequencyLocation(enable: newValue)
88
88
  }
89
89
  }
90
90
 
91
91
  /// Status of tracking state. On/Off
92
92
  @objc public var trackingState: Bool {
93
93
  get {
94
- return WoosmapGeofencing.shared.getTrackingState()
94
+ return WoosmapGeofenceManager.shared.getTrackingState()
95
95
  }
96
96
  set {
97
- WoosmapGeofencing.shared.setTrackingEnable(enable: newValue)
97
+ WoosmapGeofenceManager.shared.setTrackingEnable(enable: newValue)
98
98
  }
99
99
  }
100
100
 
@@ -103,7 +103,7 @@ import WoosmapGeofencing
103
103
  /// This callback received when application become active
104
104
  @objc func appDidBecomeActive() {
105
105
  DispatchQueue.main.async {
106
- WoosmapGeofencing.shared.didBecomeActive()
106
+ WoosmapGeofenceManager.shared.didBecomeActive()
107
107
  }
108
108
  }
109
109
 
@@ -111,14 +111,14 @@ import WoosmapGeofencing
111
111
  @objc func appDidEnterBackground() {
112
112
  if CLLocationManager.authorizationStatus() != .notDetermined {
113
113
  DispatchQueue.main.async {
114
- WoosmapGeofencing.shared.startMonitoringInBackground()
114
+ WoosmapGeofenceManager.shared.startMonitoringInBackground()
115
115
  }
116
116
  }
117
117
  }
118
118
 
119
119
  /// This callback received when application is terminated
120
120
  @objc func appWillTerminate() {
121
- WoosmapGeofencing.shared.setModeHighfrequencyLocation(enable: false)
121
+ WoosmapGeofenceManager.shared.setModeHighfrequencyLocation(enable: false)
122
122
  }
123
123
  // MARK: Init
124
124
 
@@ -149,13 +149,27 @@ import WoosmapGeofencing
149
149
  /// - airshipEnable: To enable airship callback
150
150
  private init(_ woosmapKey: String, _ configurationProfile: String, _ airshipEnable: Bool = false) {
151
151
  super.init()
152
- self.woosmapKey = woosmapKey
153
- self.defaultProfile = configurationProfile
152
+ let defaults = UserDefaults.standard
153
+ if(woosmapKey == ""){
154
+ let lastSaved = defaults.string(forKey: "WoosmapGeofenceService.woosmap") ?? ""
155
+ self.woosmapKey = lastSaved
156
+ }
157
+ else{
158
+ self.woosmapKey = woosmapKey
159
+ }
160
+ if(configurationProfile == ""){
161
+ let lastSaved = defaults.string(forKey: "WoosmapGeofenceService.profile") ?? ""
162
+ self.defaultProfile = lastSaved
163
+ }
164
+ else {
165
+ self.defaultProfile = configurationProfile
166
+ }
167
+
154
168
  self.enableAirshipCallback = airshipEnable
155
169
  // Save it on preferences
156
- let defaults = UserDefaults.standard
157
- defaults.set(woosmapKey, forKey: "WoosmapGeofenceService.woosmap")
158
- defaults.set(configurationProfile, forKey: "WoosmapGeofenceService.profile")
170
+
171
+ defaults.set(self.woosmapKey, forKey: "WoosmapGeofenceService.woosmap")
172
+ defaults.set(self.defaultProfile, forKey: "WoosmapGeofenceService.profile")
159
173
  defaults.set(airshipEnable, forKey: "WoosmapGeofenceService.AirshipCallbackEnable")
160
174
 
161
175
  defaults.register(defaults: ["TrackingEnable": true,
@@ -203,7 +217,7 @@ import WoosmapGeofencing
203
217
  let group = DispatchGroup()
204
218
  group.enter()
205
219
  DispatchQueue.main.async {
206
- WoosmapGeofencing.shared.setWoosmapAPIKey(key: self.woosmapKey)
220
+ WoosmapGeofenceManager.shared.setWoosmapAPIKey(key: self.woosmapKey)
207
221
  group.leave()
208
222
  }
209
223
  group.wait()
@@ -220,7 +234,7 @@ import WoosmapGeofencing
220
234
  let group = DispatchGroup()
221
235
  group.enter()
222
236
  DispatchQueue.main.async {
223
- WoosmapGeofencing.shared.startTracking(configurationProfile: savedProfile)
237
+ WoosmapGeofenceManager.shared.startTracking(configurationProfile: savedProfile)
224
238
  group.leave()
225
239
  }
226
240
  group.wait()
@@ -234,47 +248,51 @@ import WoosmapGeofencing
234
248
  defaults.set(self.defaultProfile, forKey: "WoosmapGeofenceService.profile")
235
249
  throw WoosGeofenceError(WoosmapGeofenceMessage.invalidProfile)
236
250
  }
237
- // print ("Highfrequency \(WoosmapGeofencing.shared.getModeHighfrequencyLocation()) , TrackingState \(WoosmapGeofencing.shared.getTrackingState()) ")
251
+ // print ("Highfrequency \(WoosmapGeofenceManager.shared.getModeHighfrequencyLocation()) , TrackingState \(WoosmapGeofenceManager.shared.getTrackingState()) ")
238
252
  }
239
253
 
240
254
  /// Stop tracking
241
255
  public func stopTracking() {
242
- WoosmapGeofencing.shared.stopTracking()
256
+ WoosmapGeofenceManager.shared.stopTracking()
243
257
  }
244
258
 
245
259
  /// activating WoosmapGeofencing with default parameters
246
260
  private func activateGeofenceService() {
247
261
  // Set private Woosmap key API
248
- WoosmapGeofencing.shared.setWoosmapAPIKey(key: woosmapKey)
249
-
262
+ WoosmapGeofenceManager.shared.setWoosmapAPIKey(key: woosmapKey)
263
+ #if DEBUG
264
+ WoosmapGeofenceManager.shared.logLevel = .trace
265
+ #else
266
+ WoosmapGeofenceManager.shared.logLevel = .info
267
+ #endif
250
268
  // Set delegate of protocol Location, POI and Distance
251
- WoosmapGeofencing.shared.getLocationService().locationServiceDelegate = dataLocation
252
- WoosmapGeofencing.shared.getLocationService().searchAPIDataDelegate = dataPOI
253
- WoosmapGeofencing.shared.getLocationService().distanceAPIDataDelegate = dataDistance
254
- WoosmapGeofencing.shared.getLocationService().regionDelegate = dataRegion
269
+ WoosmapGeofenceManager.shared.getLocationService().locationServiceDelegate = dataLocation
270
+ WoosmapGeofenceManager.shared.getLocationService().searchAPIDataDelegate = dataPOI
271
+ WoosmapGeofenceManager.shared.getLocationService().distanceAPIDataDelegate = dataDistance
272
+ WoosmapGeofenceManager.shared.getLocationService().regionDelegate = dataRegion
255
273
 
256
274
  // Enable Visit and set delegate of protocol Visit
257
- WoosmapGeofencing.shared.getLocationService().visitDelegate = dataVisit
275
+ WoosmapGeofenceManager.shared.getLocationService().visitDelegate = dataVisit
258
276
  if(self.enableAirshipCallback){
259
277
  // Set delagate for Airship Cloud
260
- WoosmapGeofencing.shared.getLocationService().airshipEventsDelegate = airshipEvents
278
+ WoosmapGeofenceManager.shared.getLocationService().airshipEventsDelegate = airshipEvents
261
279
  }
262
280
 
263
281
  // Set delagate for Marketing Cloud
264
- WoosmapGeofencing.shared.getLocationService().marketingCloudEventsDelegate = marketingCloudEvents
282
+ WoosmapGeofenceManager.shared.getLocationService().marketingCloudEventsDelegate = marketingCloudEvents
265
283
  if defaultPOIRadius != "" {
266
- WoosmapGeofencing.shared.setPoiRadius(radius: formatedRadius(radius: defaultPOIRadius))
284
+ WoosmapGeofenceManager.shared.setPoiRadius(radius: formatedRadius(radius: defaultPOIRadius))
267
285
  }
268
286
 
269
287
  if let savedProfile = ConfigurationProfile(rawValue: defaultProfile) {
270
- WoosmapGeofencing.shared.startTracking(configurationProfile: savedProfile)
288
+ WoosmapGeofenceManager.shared.startTracking(configurationProfile: savedProfile)
271
289
  }
272
290
  // else{ //Default tracking
273
- // WoosmapGeofencing.shared.startTracking(configurationProfile: ConfigurationProfile.passiveTracking)
291
+ // WoosmapGeofenceManager.shared.startTracking(configurationProfile: ConfigurationProfile.passiveTracking)
274
292
  // }
275
293
  // Check if the authorization Status of location Manager
276
294
  if CLLocationManager.authorizationStatus() != .notDetermined {
277
- WoosmapGeofencing.shared.startMonitoringInBackground()
295
+ WoosmapGeofenceManager.shared.startMonitoringInBackground()
278
296
  }
279
297
 
280
298
  NotificationCenter.default.addObserver(self,
@@ -290,7 +308,7 @@ import WoosmapGeofencing
290
308
  // self.searchAPIRequestEnable = true
291
309
  // self.distanceAPIRequestEnable = true
292
310
  // self.searchAPICreationRegionEnable = true
293
- // print ("\(WoosmapGeofencing.shared.getModeHighfrequencyLocation()) \(WoosmapGeofencing.shared.getTrackingState()) ")
311
+ // print ("\(WoosmapGeofenceManager.shared.getModeHighfrequencyLocation()) \(WoosmapGeofenceManager.shared.getTrackingState()) ")
294
312
  }
295
313
 
296
314
  /// Adding new region
@@ -301,19 +319,19 @@ import WoosmapGeofencing
301
319
  /// - type: String circle/isochrone
302
320
  /// - Returns: Status for reagion created or not and new region id from system
303
321
  public func addRegion(identifier: String, center: CLLocationCoordinate2D, radius: Int, type: String) -> (isCreate: Bool, identifier: String) {
304
- return WoosmapGeofencing.shared.locationService.addRegion(identifier: identifier, center: center, radius: radius, type:type)
322
+ return WoosmapGeofenceManager.shared.locationService.addRegion(identifier: identifier, center: center, radius: radius, type:type)
305
323
  }
306
324
 
307
325
  /// Remove region from system
308
326
  /// - Parameter center: geoLocation point of region
309
327
  public func removeRegion(center: CLLocationCoordinate2D) {
310
- return WoosmapGeofencing.shared.locationService.removeRegion(center: center)
328
+ return WoosmapGeofenceManager.shared.locationService.removeRegion(center: center)
311
329
  }
312
330
 
313
331
  /// Remove region from system
314
332
  /// - Parameter identifier: region id assined for region
315
333
  public func removeRegion(identifier: String) {
316
- return WoosmapGeofencing.shared.locationService.removeRegion(identifier: identifier)
334
+ return WoosmapGeofenceManager.shared.locationService.removeRegion(identifier: identifier)
317
335
  }
318
336
 
319
337
  /// Get location information for geopoint from woos system
@@ -322,7 +340,7 @@ import WoosmapGeofencing
322
340
  /// - locationId: id recorded for that location
323
341
  public func searchAPIRequest(location: CLLocationCoordinate2D, locationId: String = "") {
324
342
  // TODO: Missing implementation
325
- //WoosmapGeofencing.shared.getLocationService().searchAPIRequest(location: CLLocation.init(latitude: location.latitude, longitude: location.longitude), locationId: locationId)
343
+ //WoosmapGeofenceManager.shared.getLocationService().searchAPIRequest(location: CLLocation.init(latitude: location.latitude, longitude: location.longitude), locationId: locationId)
326
344
  }
327
345
  // TODO: Missing implementation
328
346
  // /// Get distnce between location point and origin
@@ -335,7 +353,7 @@ import WoosmapGeofencing
335
353
  // let lngDest = coordinatesDest.coordinate.longitude
336
354
  // let originLocation = CLLocation.init(latitude: locationOrigin.latitude,
337
355
  // longitude: locationOrigin.longitude)
338
- // WoosmapGeofencing.shared.getLocationService().distanceAPIRequest(locationOrigin: originLocation,
356
+ // WoosmapGeofenceManager.shared.getLocationService().distanceAPIRequest(locationOrigin: originLocation,
339
357
  // coordinatesDest: [(latDest, lngDest)],
340
358
  // locationId: locationId)
341
359
  // }
@@ -350,7 +368,7 @@ import WoosmapGeofencing
350
368
  // let lngDest = poi.longitude
351
369
  // let originLocation = CLLocation.init(latitude: locationOrigin.latitude,
352
370
  // longitude: locationOrigin.longitude)
353
- // WoosmapGeofencing.shared.getLocationService().distanceAPIRequest(locationOrigin: originLocation,
371
+ // WoosmapGeofenceManager.shared.getLocationService().distanceAPIRequest(locationOrigin: originLocation,
354
372
  // coordinatesDest: [(latDest, lngDest)],
355
373
  // locationId: locationId)
356
374
  // }
@@ -382,6 +400,19 @@ import WoosmapGeofencing
382
400
  let poi = DataPOI().readPOI(id: id)
383
401
  return poi
384
402
  }
403
+
404
+ ///Fetch beacon info from storage
405
+ /// - Returns: Array of Beacon POIs
406
+ public func getIndoorBeacons(id:String?) -> [IndoorBeacon]? {
407
+ let info = DataPOI().readIndoorBeaconPOI(venueid: id)
408
+ return info
409
+ }
410
+
411
+ ///Delete Becaon info from storage
412
+ public func deleteIndoorBeacons() {
413
+ IndoorBeacons.deleteAll()
414
+ }
415
+
385
416
 
386
417
  /// List all intrest zone capture by system
387
418
  /// - Returns: Array of zones
@@ -396,28 +427,26 @@ import WoosmapGeofencing
396
427
  var regions = DataRegion().readRegions()
397
428
  let IsochroneRegion = DataRegion().readIsochroneRegions()
398
429
  IsochroneRegion.forEach { item in
399
- let customRegion = Region()
400
- customRegion.identifier = item.identifier ?? "-"
401
- customRegion.latitude = item.latitude
402
- customRegion.longitude = item.longitude
403
- customRegion.radius = Double(item.radius)
430
+ let customRegion = Region(latitude: item.latitude, longitude: item.latitude, radius: Double(item.radius), dateCaptured: Date(), identifier: item.identifier ?? "-", didEnter: false, fromPositionDetection: false, eventName: "")
404
431
  customRegion.type = item.type
405
432
  regions.append(customRegion)
406
433
  }
407
434
 
408
- if let locationService = WoosmapGeofencing.shared.locationService{
435
+ if let locationService = WoosmapGeofenceManager.shared.locationService{
409
436
  if let customRegion = locationService.locationManager?.monitoredRegions{
410
437
  customRegion.forEach { item in
411
438
  if(locationService.getRegionType(identifier: item.identifier) == RegionType.custom){
412
- let customRegion = Region()
413
- customRegion.identifier = item.identifier
439
+
440
+ let customRegionItem = Region(latitude: 0, longitude: 0, radius: 0, dateCaptured: Date(), identifier: item.identifier , didEnter: false, fromPositionDetection: false, eventName: "")
441
+
442
+ customRegionItem.identifier = item.identifier
414
443
  if let circleRegion = item as? CLCircularRegion{
415
- customRegion.latitude = circleRegion.center.latitude
416
- customRegion.longitude = circleRegion.center.longitude
417
- customRegion.radius = circleRegion.radius
418
- customRegion.type = "circle"
444
+ customRegionItem.latitude = circleRegion.center.latitude
445
+ customRegionItem.longitude = circleRegion.center.longitude
446
+ customRegionItem.radius = circleRegion.radius
447
+ customRegionItem.type = "circle"
419
448
  }
420
- regions.append(customRegion)
449
+ regions.append(customRegionItem)
421
450
  }
422
451
  }
423
452
  }
@@ -430,14 +459,15 @@ import WoosmapGeofencing
430
459
  /// - Parameter id: region id
431
460
  /// - Returns: Region
432
461
  public func getRegions(id:String) -> Region? {
433
- if let locationService = WoosmapGeofencing.shared.locationService{
462
+ if let locationService = WoosmapGeofenceManager.shared.locationService{
434
463
  let regiontype = locationService.getRegionType(identifier: id)
435
464
  if( regiontype == RegionType.custom){
436
465
  if let customRegions = locationService.locationManager?.monitoredRegions{
437
466
  if let watchRegion = customRegions.first(where: { item in
438
467
  return item.identifier == id
439
468
  }){
440
- let customRegion = Region()
469
+ let customRegion = Region(latitude: 0, longitude: 0, radius: 0, dateCaptured: Date(), identifier: "-", didEnter: false, fromPositionDetection: false, eventName: "")
470
+
441
471
  customRegion.identifier = watchRegion.identifier
442
472
  if let circleRegion = watchRegion as? CLCircularRegion{
443
473
  customRegion.latitude = circleRegion.center.latitude
@@ -456,7 +486,7 @@ import WoosmapGeofencing
456
486
  }
457
487
  if let regions = DataRegion().readIsochroneRegions(id: id){
458
488
 
459
- let customRegion = Region()
489
+ let customRegion = Region(latitude: 0, longitude: 0, radius: 0, dateCaptured: Date(), identifier: "-", didEnter: false, fromPositionDetection: false, eventName: "")
460
490
  customRegion.identifier = regions.identifier ?? "-"
461
491
  customRegion.latitude = regions.latitude
462
492
  customRegion.longitude = regions.longitude
@@ -498,12 +528,12 @@ import WoosmapGeofencing
498
528
 
499
529
  /// Delete all ZOI regions
500
530
  public func deleteAllZoiRegion() {
501
- WoosmapGeofencing.shared.locationService.removeRegions(type: RegionType.custom)
531
+ WoosmapGeofenceManager.shared.locationService.removeRegions(type: RegionType.custom)
502
532
  }
503
533
 
504
534
  /// Delete all POI regions
505
535
  public func deleteAllPoiRegion() {
506
- WoosmapGeofencing.shared.locationService.removeRegions(type: RegionType.poi)
536
+ WoosmapGeofenceManager.shared.locationService.removeRegions(type: RegionType.poi)
507
537
  }
508
538
 
509
539
  /// Delete regions by id
@@ -512,7 +542,7 @@ import WoosmapGeofencing
512
542
  public func deleteRegions(id:String) throws {
513
543
  if isRegionIDExist(id: id){
514
544
  DataRegion().eraseRegions(id: id)
515
- WoosmapGeofencing.shared.locationService.removeRegion(identifier: id)
545
+ WoosmapGeofenceManager.shared.locationService.removeRegion(identifier: id)
516
546
  }
517
547
  else{
518
548
  throw WoosGeofenceError(WoosmapGeofenceMessage.regionid_notexist )
@@ -523,7 +553,7 @@ import WoosmapGeofencing
523
553
  /// Delete all regions
524
554
  public func deleteAllRegion() {
525
555
  DataRegion().eraseRegions()
526
- WoosmapGeofencing.shared.locationService.removeRegions(type: RegionType.none)
556
+ WoosmapGeofenceManager.shared.locationService.removeRegions(type: RegionType.none)
527
557
  }
528
558
 
529
559
  @objc static public func mockdata() {
@@ -559,7 +589,7 @@ import WoosmapGeofencing
559
589
  throw WoosGeofenceError(WoosmapGeofenceMessage.required_contactKey)
560
590
  }
561
591
  if requiredSatisfied {
562
- WoosmapGeofencing.shared.setSFMCCredentials(credentials: credentials)
592
+ WoosmapGeofenceManager.shared.setSFMCCredentials(credentials: credentials)
563
593
  }
564
594
  }
565
595
 
@@ -567,7 +597,7 @@ import WoosmapGeofencing
567
597
  /// - Parameter radius: integer or string for radius value
568
598
  public func setPoiRadius(radius: String) {
569
599
  self.defaultPOIRadius = radius
570
- WoosmapGeofencing.shared.setPoiRadius(radius: formatedRadius(radius: radius))
600
+ WoosmapGeofenceManager.shared.setPoiRadius(radius: formatedRadius(radius: radius))
571
601
  }
572
602
 
573
603
  /// Format String value to proper datatype
@@ -598,7 +628,7 @@ import WoosmapGeofencing
598
628
  if(mode == "local"){
599
629
  let bundle = Bundle.main //Bundle(for: Self.self)
600
630
  if let url = bundle.url(forResource: source, withExtension: nil){
601
- let (status,errors) = WoosmapGeofencing.shared.startCustomTracking(url: url.absoluteString)
631
+ let (status,errors) = WoosmapGeofenceManager.shared.startCustomTracking(url: url.absoluteString)
602
632
 
603
633
  if(status == false){
604
634
  completion(false,WoosGeofenceError(errors[0]))
@@ -612,7 +642,7 @@ import WoosmapGeofencing
612
642
  }
613
643
  }
614
644
  else if(mode == "external"){
615
- let (status,errors) = WoosmapGeofencing.shared.startCustomTracking(url: source)
645
+ let (status,errors) = WoosmapGeofenceManager.shared.startCustomTracking(url: source)
616
646
  if(status == false){
617
647
  completion(false,WoosGeofenceError(errors[0]))
618
648
  }
@@ -632,7 +662,7 @@ import WoosmapGeofencing
632
662
  if(mode == "local"){
633
663
  let bundle = Bundle.main //Bundle(for: Self.self)
634
664
  if let url = bundle.url(forResource: source, withExtension: nil){
635
- let (status,errors) = WoosmapGeofencing.shared.startCustomTracking(url: url.absoluteString)
665
+ let (status,errors) = WoosmapGeofenceManager.shared.startCustomTracking(url: url.absoluteString)
636
666
  if(status == false){
637
667
  throw WoosGeofenceError(errors[0])
638
668
  }
@@ -642,7 +672,7 @@ import WoosmapGeofencing
642
672
  }
643
673
  }
644
674
  else if(mode == "external"){
645
- let (status,errors) = WoosmapGeofencing.shared.startCustomTracking(url: source)
675
+ let (status,errors) = WoosmapGeofenceManager.shared.startCustomTracking(url: source)
646
676
  if(status == false){
647
677
  throw WoosGeofenceError(errors[0])
648
678
  }
@@ -10,6 +10,7 @@ var _nativeInterface = _interopRequireDefault(require("./internal/nativeInterfac
10
10
  var _Location = _interopRequireDefault(require("./internal/Location"));
11
11
  var _Region = _interopRequireDefault(require("./internal/Region"));
12
12
  var _Poi = _interopRequireDefault(require("./internal/Poi"));
13
+ var _IndoorBeacon = _interopRequireDefault(require("./internal/IndoorBeacon"));
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  const eventEmitter = new _reactNative.NativeEventEmitter(_nativeInterface.default);
15
16
  let subscriptionsLocation = {};
@@ -68,6 +69,21 @@ function requestPermissions(background) {
68
69
  return _nativeInterface.default.requestPermissions([background]);
69
70
  }
70
71
 
72
+ /**
73
+ * A method to request the required permissions to collect locations.
74
+ * @returns A callback that will be called on successful authorization by the app. A callback that will be called when the app denies permission.
75
+ * The plugin will return an object with either one of the messages - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
76
+ */
77
+ function requestBLEPermissions() {
78
+ if (_reactNative.Platform.OS === 'android') {
79
+ return _nativeInterface.default.requestBLEPermissions();
80
+ } else {
81
+ return new Promise(resolve => {
82
+ resolve('GRANTED');
83
+ });
84
+ }
85
+ }
86
+
71
87
  /**
72
88
  * A method to check if the app has granted required permissions to track location.
73
89
  * @returns A callback that will be called with the following status - GRANTED_BACKGROUND, GRANTED_FOREGROUND, DENIED
@@ -76,6 +92,20 @@ function getPermissionsStatus() {
76
92
  return _nativeInterface.default.getPermissionsStatus();
77
93
  }
78
94
 
95
+ /**
96
+ * A method to check if the app has granted required permissions to track location.
97
+ * @returns A callback that will be called with the following status - BACKGROUND_LOCATION_DENIED, GRANTED, DENIED
98
+ */
99
+ function getBLEPermissionsStatus() {
100
+ if (_reactNative.Platform.OS == 'android') {
101
+ return _nativeInterface.default.getBLEPermissionsStatus();
102
+ } else {
103
+ return new Promise(resolve => {
104
+ resolve('GRANTED');
105
+ });
106
+ }
107
+ }
108
+
79
109
  /**
80
110
  * Method will
81
111
  invoke callback and pass a location object as a parameter. Method will return a watchId . This id can be used to remove a callback.
@@ -107,11 +137,14 @@ function clearLocationWatch(watchID) {
107
137
  const saved = subscriptionsLocation[watchID];
108
138
  if (saved) {
109
139
  const arg0 = saved[0];
110
- eventEmitter.removeListener('geolocationDidChange', arg0);
140
+ arg0.remove();
141
+ //eventEmitter.removeListener('geolocationDidChange', arg0);
111
142
  const arg1 = saved[1];
112
143
  if (arg1) {
113
- eventEmitter.removeListener('geolocationError', arg1);
144
+ arg1.remove();
145
+ //eventEmitter.removeListener('geolocationError', arg1);
114
146
  }
147
+
115
148
  subscriptionsLocation[watchID] = undefined;
116
149
  }
117
150
  return _nativeInterface.default.clearLocationWatch(watchID);
@@ -149,11 +182,14 @@ function clearRegionsWatch(watchID) {
149
182
  const saved = subscriptionsRegion[watchID];
150
183
  if (saved) {
151
184
  const arg0 = saved[0];
152
- eventEmitter.removeListener('woosmapgeofenceRegionDidChange', arg0);
185
+ arg0.remove();
186
+ //eventEmitter.removeListener('woosmapgeofenceRegionDidChange', arg0);
153
187
  const arg1 = saved[1];
154
188
  if (arg1) {
155
- eventEmitter.removeListener('woosmapgeofenceRegionError', arg1);
189
+ arg1.remove();
190
+ //eventEmitter.removeListener('woosmapgeofenceRegionError', arg1);
156
191
  }
192
+
157
193
  subscriptionsRegion[watchID] = undefined;
158
194
  }
159
195
  return _nativeInterface.default.clearRegionsWatch(watchID);
@@ -295,7 +331,7 @@ function removePois() {
295
331
  return _nativeInterface.default.removeAllPois();
296
332
  }
297
333
  /**
298
- * if preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method.
334
+ * if preset tracking profiles don’t fit with your use cases, you can build your own profile and uses the startCustomTracking() method.
299
335
  * There are two way to host the json file:
300
336
  * - included in the client application (local)
301
337
  * - hosted externally in a file folder in your information system (external)
@@ -306,12 +342,64 @@ function removePois() {
306
342
  function startCustomTracking(sourceType, source) {
307
343
  return _nativeInterface.default.startCustomTracking(sourceType, source);
308
344
  }
345
+
346
+ /**
347
+ * Retrieve Beacon info for venue
348
+ * @param venueID - Optional venue id
349
+ * @param ref - Optional beacon id return by region event
350
+ * @returns promise with A callback that will be called on success or error.
351
+ */
352
+ function getIndoorBeacons(venueID, ref) {
353
+ if (venueID == null) {
354
+ return _nativeInterface.default.getAllIndoorBeacons().then(result => {
355
+ var formatted = [];
356
+ result.forEach(item => {
357
+ if (ref !== undefined) {
358
+ if (item.identifier === ref) {
359
+ formatted.push(_IndoorBeacon.default.jsonToObj(item));
360
+ }
361
+ } else {
362
+ formatted.push(_IndoorBeacon.default.jsonToObj(item));
363
+ }
364
+ });
365
+ return Promise.resolve(formatted);
366
+ }).catch(e => {
367
+ return Promise.reject(e);
368
+ });
369
+ } else {
370
+ return _nativeInterface.default.getIndoorBeacons(venueID).then(result => {
371
+ var formatted = [];
372
+ result.forEach(item => {
373
+ if (ref !== undefined) {
374
+ if (item.identifier === ref) {
375
+ formatted.push(_IndoorBeacon.default.jsonToObj(item));
376
+ }
377
+ } else {
378
+ formatted.push(_IndoorBeacon.default.jsonToObj(item));
379
+ }
380
+ });
381
+ return Promise.resolve(formatted);
382
+ }).catch(e => {
383
+ return Promise.reject(e);
384
+ });
385
+ }
386
+ }
387
+
388
+ /**
389
+ * Remove saved POI info
390
+ * @returns promise with A callback that will be called on success or error.
391
+ */
392
+ function removeIndoorBeacons() {
393
+ return _nativeInterface.default.removeIndoorBeacons();
394
+ }
309
395
  const WoosmapGeofencing = {
310
396
  initialize,
311
397
  setWoosmapApiKey,
312
398
  startTracking,
313
399
  requestPermissions,
400
+ requestBLEPermissions,
314
401
  getPermissionsStatus,
402
+ getBLEPermissionsStatus,
315
403
  stopTracking,
316
404
  watchLocation,
317
405
  clearLocationWatch,
@@ -326,8 +414,9 @@ const WoosmapGeofencing = {
326
414
  removeLocations,
327
415
  getPois,
328
416
  removePois,
329
- startCustomTracking
417
+ startCustomTracking,
418
+ getIndoorBeacons,
419
+ removeIndoorBeacons
330
420
  };
331
- var _default = WoosmapGeofencing;
332
- exports.default = _default;
421
+ var _default = exports.default = WoosmapGeofencing;
333
422
  //# sourceMappingURL=index.js.map