@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
package/ios/PluginGeofencing.m
CHANGED
|
@@ -59,4 +59,47 @@ RCT_EXTERN_METHOD(setPoiRadius:(NSString *)radius
|
|
|
59
59
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
60
60
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
61
61
|
|
|
62
|
+
RCT_EXTERN_METHOD(addRegion:(NSDictionary *)regioninfo
|
|
63
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
64
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
65
|
+
|
|
66
|
+
RCT_EXTERN_METHOD(getAllRegions:(RCTPromiseResolveBlock)resolve
|
|
67
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
68
|
+
|
|
69
|
+
RCT_EXTERN_METHOD(getRegions:(NSString *)regionid
|
|
70
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
71
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
72
|
+
|
|
73
|
+
RCT_EXTERN_METHOD(removeAllRegions:(RCTPromiseResolveBlock)resolve
|
|
74
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
75
|
+
|
|
76
|
+
RCT_EXTERN_METHOD(removeRegion:(NSString *)regionid
|
|
77
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
78
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
79
|
+
|
|
80
|
+
RCT_EXTERN_METHOD(getAllLocations:(RCTPromiseResolveBlock)resolve
|
|
81
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
82
|
+
|
|
83
|
+
RCT_EXTERN_METHOD(getLocation:(NSString *)locationid
|
|
84
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
85
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
86
|
+
|
|
87
|
+
RCT_EXTERN_METHOD(removeAllLocations:(RCTPromiseResolveBlock)resolve
|
|
88
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
89
|
+
|
|
90
|
+
RCT_EXTERN_METHOD(getAllPois:(RCTPromiseResolveBlock)resolve
|
|
91
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
92
|
+
|
|
93
|
+
RCT_EXTERN_METHOD(getPoi:(NSString *)poiid
|
|
94
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
95
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
96
|
+
|
|
97
|
+
RCT_EXTERN_METHOD(removeAllPois:(RCTPromiseResolveBlock)resolve
|
|
98
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
99
|
+
|
|
100
|
+
RCT_EXTERN_METHOD(startCustomTracking:(NSString *)mode
|
|
101
|
+
source:(NSString *)source
|
|
102
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
103
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
104
|
+
|
|
62
105
|
@end
|
|
@@ -41,7 +41,7 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
41
41
|
|
|
42
42
|
override func supportedEvents() -> [String]! {
|
|
43
43
|
return ["geolocationDidChange",
|
|
44
|
-
"
|
|
44
|
+
"geolocationError",
|
|
45
45
|
"woosmapgeofenceRegionDidChange",
|
|
46
46
|
"woosmapgeofenceRegionError"]
|
|
47
47
|
}
|
|
@@ -108,6 +108,7 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
108
108
|
WoosmapGeofenceService.setup(woosmapKey: privateKeyWoosmapAPI, configurationProfile: "")
|
|
109
109
|
}
|
|
110
110
|
if(isCallUnsuccessfull == false){
|
|
111
|
+
sleep(1);// Take a some time as plugin initialize on main thread
|
|
111
112
|
resolve(WoosmapGeofenceMessage.initialize)
|
|
112
113
|
}
|
|
113
114
|
}
|
|
@@ -238,29 +239,31 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
238
239
|
} else if status == .authorizedAlways {
|
|
239
240
|
resolve(WoosmapGeofenceMessage.samePermission)
|
|
240
241
|
} else {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
alertInfo
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
alert.addAction(UIAlertAction(title: WoosmapGeofenceMessage.cancel, style: UIAlertAction.Style.default, handler: nil))
|
|
250
|
-
alert.addAction(UIAlertAction(title: WoosmapGeofenceMessage.setting, style: UIAlertAction.Style.default, handler: { _ in
|
|
251
|
-
if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
|
|
252
|
-
UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil)
|
|
242
|
+
resolve(WoosmapGeofenceMessage.showingPermissionBox)
|
|
243
|
+
DispatchQueue.main.async {
|
|
244
|
+
let appname: String = Bundle.main.infoDictionary?[kCFBundleNameKey as String] as? String ?? ""
|
|
245
|
+
var alertInfo: String = ""
|
|
246
|
+
if status == .denied {
|
|
247
|
+
alertInfo = String(format: WoosmapGeofenceMessage.deniedPermission, appname)
|
|
248
|
+
} else {
|
|
249
|
+
alertInfo = String(format: WoosmapGeofenceMessage.replacePermission, appname)
|
|
253
250
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
251
|
+
let alert = UIAlertController(title: "", message: alertInfo, preferredStyle: UIAlertController.Style.alert)
|
|
252
|
+
alert.addAction(UIAlertAction(title: WoosmapGeofenceMessage.cancel, style: UIAlertAction.Style.default, handler: nil))
|
|
253
|
+
alert.addAction(UIAlertAction(title: WoosmapGeofenceMessage.setting, style: UIAlertAction.Style.default, handler: { _ in
|
|
254
|
+
if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
|
|
255
|
+
UIApplication.shared.open(settingsUrl, options: [:], completionHandler: nil)
|
|
256
|
+
}
|
|
257
|
+
}))
|
|
258
|
+
var rootViewController = UIApplication.shared.keyWindow?.rootViewController
|
|
259
|
+
if let navigationController = rootViewController as? UINavigationController {
|
|
260
|
+
rootViewController = navigationController.viewControllers.first
|
|
261
|
+
}
|
|
262
|
+
if let tabBarController = rootViewController as? UITabBarController {
|
|
263
|
+
rootViewController = tabBarController.selectedViewController
|
|
264
|
+
}
|
|
265
|
+
rootViewController?.present(alert, animated: true, completion: nil)
|
|
261
266
|
}
|
|
262
|
-
rootViewController?.present(alert, animated: true, completion: nil)
|
|
263
|
-
resolve(WoosmapGeofenceMessage.showingPermissionBox)
|
|
264
267
|
}
|
|
265
268
|
} else {
|
|
266
269
|
if status == .notDetermined {
|
|
@@ -419,6 +422,86 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
419
422
|
resolve("00000-00000-0000")
|
|
420
423
|
}
|
|
421
424
|
|
|
425
|
+
|
|
426
|
+
/// Add a region that you want to monitor. Method will accept an object with the following attributes:
|
|
427
|
+
/// regionId - Id of the region
|
|
428
|
+
/// lat - Latitude
|
|
429
|
+
/// lng - Longitude
|
|
430
|
+
/// radius - Radius in meters
|
|
431
|
+
/// type - circle/isochrone
|
|
432
|
+
/// - Parameters:
|
|
433
|
+
/// - regioninfo: regioninfo description
|
|
434
|
+
/// - resolve: return Reference watchid on successfully call
|
|
435
|
+
/// - reject: return error info
|
|
436
|
+
@objc(addRegion:withResolver:withRejecter:)
|
|
437
|
+
func addRegion(regioninfo:NSDictionary, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
438
|
+
if WoosmapGeofenceService.shared != nil {
|
|
439
|
+
if let regioninfo = regioninfo as? [String: Any] {
|
|
440
|
+
var regionid = UUID().uuidString
|
|
441
|
+
var radius = 100
|
|
442
|
+
var lat: Double = 0
|
|
443
|
+
var lng: Double = 0
|
|
444
|
+
var regiontype:String = ""
|
|
445
|
+
if let inputregionId = regioninfo["regionId"] as? String {
|
|
446
|
+
regionid = inputregionId
|
|
447
|
+
}
|
|
448
|
+
if let inputCoordinate = regioninfo["lat"] as? String {
|
|
449
|
+
lat = Double(inputCoordinate) ?? 0
|
|
450
|
+
} else if let inputCoordinate = regioninfo["lat"] as? Double {
|
|
451
|
+
lat = inputCoordinate
|
|
452
|
+
}
|
|
453
|
+
if let inputCoordinate = regioninfo["lng"] as? String {
|
|
454
|
+
lng = Double(inputCoordinate) ?? 0
|
|
455
|
+
} else if let inputCoordinate = regioninfo["lng"] as? Double {
|
|
456
|
+
lng = inputCoordinate
|
|
457
|
+
}
|
|
458
|
+
if let inputradius = regioninfo["radius"] as? String {
|
|
459
|
+
radius = Int(inputradius) ?? 0
|
|
460
|
+
} else if let inputradius = regioninfo["radius"] as? Int {
|
|
461
|
+
radius = inputradius
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if let inputtype = regioninfo["type"] as? String {
|
|
465
|
+
regiontype = inputtype
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if lat == 0 || lng == 0 {
|
|
469
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
470
|
+
WoosmapGeofenceMessage.invalidLocation,
|
|
471
|
+
showWoomapError(WoosmapGeofenceMessage.invalidLocation))
|
|
472
|
+
} else if !(regiontype == "circle" || regiontype == "isochrone") {
|
|
473
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
474
|
+
WoosmapGeofenceMessage.invalidRegionType,
|
|
475
|
+
showWoomapError(WoosmapGeofenceMessage.invalidRegionType))
|
|
476
|
+
} else {
|
|
477
|
+
let coordinate: CLLocationCoordinate2D = CLLocationCoordinate2D.init(latitude: lat, longitude: lng)
|
|
478
|
+
|
|
479
|
+
let (regionIsCreated, identifier) = WoosmapGeofenceService.shared!.addRegion(identifier: regionid, center: coordinate, radius: radius, type: regiontype)
|
|
480
|
+
var result: [AnyHashable: Any] = [:]
|
|
481
|
+
result["regionid"] = identifier
|
|
482
|
+
result["iscreated"] = regionIsCreated
|
|
483
|
+
if(regionIsCreated) {
|
|
484
|
+
resolve(result["regionid"])
|
|
485
|
+
}
|
|
486
|
+
else{
|
|
487
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
488
|
+
WoosmapGeofenceMessage.regionInfoDuplicateID,
|
|
489
|
+
showWoomapError(WoosmapGeofenceMessage.regionInfoDuplicateID))
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
494
|
+
WoosmapGeofenceMessage.regionInfoEmptyOrNull,
|
|
495
|
+
showWoomapError(WoosmapGeofenceMessage.regionInfoEmptyOrNull))
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
} else {
|
|
499
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
500
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
501
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
422
505
|
/// Added SFMC Credentials to SDK
|
|
423
506
|
/// - Parameters:
|
|
424
507
|
/// - credentials: SFMC Credentials object
|
|
@@ -487,6 +570,278 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
487
570
|
}
|
|
488
571
|
}
|
|
489
572
|
|
|
573
|
+
/// Fetch All region
|
|
574
|
+
/// - Parameters:
|
|
575
|
+
/// - resolve: return list of Array with region info
|
|
576
|
+
/// - reject: return error info
|
|
577
|
+
@objc(getAllRegions:withRejecter:)
|
|
578
|
+
func getAllRegions(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
579
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
580
|
+
let capturedRegions = objWoos.getRegions()
|
|
581
|
+
var result: [[AnyHashable: Any]] = []
|
|
582
|
+
|
|
583
|
+
for item in capturedRegions {
|
|
584
|
+
result.append(formatRegionData(woosdata: item))
|
|
585
|
+
}
|
|
586
|
+
resolve(result);
|
|
587
|
+
} else {
|
|
588
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
589
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
590
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/// Fetch region
|
|
595
|
+
/// - Parameters:
|
|
596
|
+
/// - regionid: regionid to fetch
|
|
597
|
+
/// - resolve: return region info
|
|
598
|
+
/// - reject: error info
|
|
599
|
+
@objc(getRegions:withResolver:withRejecter:)
|
|
600
|
+
func getRegions(regionid:String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
601
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
602
|
+
if(regionid != ""){
|
|
603
|
+
if let capturedRegions = objWoos.getRegions(id:regionid){
|
|
604
|
+
resolve(formatRegionData(woosdata: capturedRegions));
|
|
605
|
+
}
|
|
606
|
+
else{
|
|
607
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
608
|
+
WoosmapGeofenceMessage.notfound_regionid,
|
|
609
|
+
showWoomapError(WoosmapGeofenceMessage.notfound_regionid))
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
else{
|
|
613
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
614
|
+
WoosmapGeofenceMessage.required_regionid,
|
|
615
|
+
showWoomapError(WoosmapGeofenceMessage.required_regionid))
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
} else {
|
|
619
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
620
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
621
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/// Clear All regions from DB
|
|
626
|
+
/// - Parameters:
|
|
627
|
+
/// - resolve: return regionDeleted
|
|
628
|
+
/// - reject: error info
|
|
629
|
+
@objc(removeAllRegions:withRejecter:)
|
|
630
|
+
func removeAllRegions(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
631
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
632
|
+
objWoos.deleteAllRegion()
|
|
633
|
+
resolve(WoosmapGeofenceMessage.regionDeleted);
|
|
634
|
+
} else {
|
|
635
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
636
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
637
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/// Remove region with ID
|
|
642
|
+
/// - Parameters:
|
|
643
|
+
/// - regionid: region id
|
|
644
|
+
/// - resolve: return regionDeleted
|
|
645
|
+
/// - reject: error info
|
|
646
|
+
@objc(removeRegion:withResolver:withRejecter:)
|
|
647
|
+
func removeRegion(regionid:String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
648
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
649
|
+
if(regionid != ""){
|
|
650
|
+
do{
|
|
651
|
+
try objWoos.deleteRegions(id: regionid)
|
|
652
|
+
resolve(WoosmapGeofenceMessage.regionDeleted);
|
|
653
|
+
}
|
|
654
|
+
catch let error as WoosGeofenceError {
|
|
655
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
656
|
+
error.localizedDescription,
|
|
657
|
+
showWoomapError(error.localizedDescription))
|
|
658
|
+
} catch {
|
|
659
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
660
|
+
error.localizedDescription,
|
|
661
|
+
showWoomapError(error.localizedDescription))
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
else{
|
|
665
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
666
|
+
WoosmapGeofenceMessage.required_regionid,
|
|
667
|
+
showWoomapError(WoosmapGeofenceMessage.required_regionid))
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
} else {
|
|
671
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
672
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
673
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/// Fetch all locations
|
|
678
|
+
/// - Parameters:
|
|
679
|
+
/// - resolve: List of Array with location info
|
|
680
|
+
/// - reject: error info
|
|
681
|
+
@objc(getAllLocations:withRejecter:)
|
|
682
|
+
func getAllLocations(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
683
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
684
|
+
let capturedLocations = objWoos.getLocations()
|
|
685
|
+
var result: [[AnyHashable: Any]] = []
|
|
686
|
+
|
|
687
|
+
for item in capturedLocations {
|
|
688
|
+
result.append(formatLocationData(woosdata: item))
|
|
689
|
+
}
|
|
690
|
+
resolve(result);
|
|
691
|
+
} else {
|
|
692
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
693
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
694
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/// Fetch Location info for given id
|
|
699
|
+
/// - Parameters:
|
|
700
|
+
/// - locationid: id of location
|
|
701
|
+
/// - resolve: Location info
|
|
702
|
+
/// - reject: Error Info
|
|
703
|
+
@objc(getLocation:withResolver:withRejecter:)
|
|
704
|
+
func getLocation(locationid:String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
705
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
706
|
+
if(locationid != ""){
|
|
707
|
+
if let capturedPOIs = objWoos.getLocations(id:locationid){
|
|
708
|
+
resolve(formatLocationData(woosdata: capturedPOIs));
|
|
709
|
+
}
|
|
710
|
+
else{
|
|
711
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
712
|
+
WoosmapGeofenceMessage.notfound_locationid,
|
|
713
|
+
showWoomapError(WoosmapGeofenceMessage.notfound_locationid))
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
else{
|
|
717
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
718
|
+
WoosmapGeofenceMessage.required_regionid,
|
|
719
|
+
showWoomapError(WoosmapGeofenceMessage.required_regionid))
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
} else {
|
|
723
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
724
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
725
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/// Get All Pois
|
|
730
|
+
/// - Parameters:
|
|
731
|
+
/// - resolve: List of Array of POI info
|
|
732
|
+
/// - reject: Error info
|
|
733
|
+
@objc(getAllPois:withRejecter:)
|
|
734
|
+
func getAllPois(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
735
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
736
|
+
let capturedRegions = objWoos.getPOIs()
|
|
737
|
+
var result: [[AnyHashable: Any]] = []
|
|
738
|
+
for item in capturedRegions {
|
|
739
|
+
result.append(formatPOIData(woosdata: item))
|
|
740
|
+
}
|
|
741
|
+
resolve(result);
|
|
742
|
+
} else {
|
|
743
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
744
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
745
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/// Get POI info by ID
|
|
750
|
+
/// - Parameters:
|
|
751
|
+
/// - poiid: id of POI
|
|
752
|
+
/// - resolve: POI info
|
|
753
|
+
/// - reject: Error Info
|
|
754
|
+
@objc(getPoi:withResolver:withRejecter:)
|
|
755
|
+
func getPoi(poiid:String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
756
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
757
|
+
if(poiid != ""){
|
|
758
|
+
if let capturedRegions = objWoos.getPOIs(id:poiid){
|
|
759
|
+
resolve(formatPOIData(woosdata: capturedRegions));
|
|
760
|
+
}
|
|
761
|
+
else{
|
|
762
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
763
|
+
WoosmapGeofenceMessage.notfound_poiid,
|
|
764
|
+
showWoomapError(WoosmapGeofenceMessage.notfound_poiid))
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
else{
|
|
768
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
769
|
+
WoosmapGeofenceMessage.required_poiid,
|
|
770
|
+
showWoomapError(WoosmapGeofenceMessage.required_poiid))
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
} else {
|
|
774
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
775
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
776
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/// Clear all Location from DB
|
|
781
|
+
/// - Parameters:
|
|
782
|
+
/// - resolve: Deleted
|
|
783
|
+
/// - reject: Error Info
|
|
784
|
+
@objc(removeAllLocations:withRejecter:)
|
|
785
|
+
func removeAllLocations(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
786
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
787
|
+
objWoos.deleteAllLocations()
|
|
788
|
+
resolve(WoosmapGeofenceMessage.locationDeleted);
|
|
789
|
+
} else {
|
|
790
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
791
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
792
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/// Clear all POIs from DB
|
|
797
|
+
/// - Parameters:
|
|
798
|
+
/// - resolve: Deleted
|
|
799
|
+
/// - reject: Error Info
|
|
800
|
+
@objc(removeAllPois:withRejecter:)
|
|
801
|
+
func removeAllPois(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
802
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
803
|
+
objWoos.deletePOI()
|
|
804
|
+
resolve(WoosmapGeofenceMessage.poiDeleted);
|
|
805
|
+
} else {
|
|
806
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
807
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
808
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// MARK: Custom Tracking
|
|
813
|
+
|
|
814
|
+
/// Start User defined tracking
|
|
815
|
+
/// - Parameters:
|
|
816
|
+
/// - mode: local/external
|
|
817
|
+
/// - source: URL or from local resource
|
|
818
|
+
/// - resolve: Success
|
|
819
|
+
/// - reject: Error Info
|
|
820
|
+
@objc(startCustomTracking:source:withResolver:withRejecter:)
|
|
821
|
+
func startCustomTracking(mode:String,
|
|
822
|
+
source:String,
|
|
823
|
+
resolve:@escaping RCTPromiseResolveBlock,
|
|
824
|
+
reject:@escaping RCTPromiseRejectBlock) {
|
|
825
|
+
if let objWoos = WoosmapGeofenceService.shared {
|
|
826
|
+
objWoos.startCustomTracking(mode: mode, source: source, completion: { Value, Error in
|
|
827
|
+
if let functionError = Error{
|
|
828
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
829
|
+
functionError.localizedDescription,
|
|
830
|
+
self.showWoomapError(functionError.localizedDescription))
|
|
831
|
+
}
|
|
832
|
+
else{
|
|
833
|
+
if(Value){
|
|
834
|
+
resolve(WoosmapGeofenceMessage.initialize);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
} else {
|
|
839
|
+
reject(WoosmapGeofenceMessage.plugin_errorDomain,
|
|
840
|
+
WoosmapGeofenceMessage.woosemapNotInitialized,
|
|
841
|
+
showWoomapError(WoosmapGeofenceMessage.woosemapNotInitialized))
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
490
845
|
|
|
491
846
|
// MARK: Events
|
|
492
847
|
@objc func newLocationAdded(_ notification: Notification) {
|
|
@@ -613,10 +968,9 @@ class PluginGeofencing: RCTEventEmitter {
|
|
|
613
968
|
|
|
614
969
|
private func formatDistanceData(woosdata: DistanceResponseResult) -> [AnyHashable: Any] {
|
|
615
970
|
var result: [AnyHashable: Any] = [:]
|
|
616
|
-
result["locationid"] = woosdata.locationId
|
|
617
|
-
|
|
618
|
-
result["
|
|
619
|
-
result["duration"] = "" //woosdata.duration.text
|
|
971
|
+
result["locationid"] = ""//woosdata.locationId
|
|
972
|
+
result["distance"] = String(woosdata.distance)
|
|
973
|
+
result["duration"] = String(woosdata.duration)
|
|
620
974
|
return result
|
|
621
975
|
}
|
|
622
976
|
|
|
@@ -11,7 +11,9 @@ internal struct WoosmapGeofenceMessage {
|
|
|
11
11
|
static let woosemapNotInitialized = "Woosmap not initialized"
|
|
12
12
|
static let watchIDEmptyOrNull = "Watch id cannot be empty or null"
|
|
13
13
|
static let regionInfoEmptyOrNull = "regionInfo cannot be empty or null"
|
|
14
|
+
static let regionInfoDuplicateID = "regionid should be unique"
|
|
14
15
|
static let invalidLocation = "Invalid location"
|
|
16
|
+
static let invalidRegionType = "Provide valid region type (circle/isochrone)"
|
|
15
17
|
static let searchpoiRequestInfoEmptyOrNull = "search poi Request cannot be empty or null"
|
|
16
18
|
static let showingPermissionBox = "Showing permission box"
|
|
17
19
|
static let cancel = "Cancel"
|
|
@@ -26,6 +28,7 @@ internal struct WoosmapGeofenceMessage {
|
|
|
26
28
|
static let zoiDeleted = "Deleted"
|
|
27
29
|
static let locationDeleted = "Deleted"
|
|
28
30
|
static let regionDeleted = "Deleted"
|
|
31
|
+
static let poiDeleted = "Deleted"
|
|
29
32
|
static let invalidProfile = "Invalid profile"
|
|
30
33
|
static let invalidPOIRadius = "POI Radius should be an integer or a string"
|
|
31
34
|
static let invalidSFMCCredentials = "Credentials cannot be empty"
|
|
@@ -34,7 +37,16 @@ internal struct WoosmapGeofenceMessage {
|
|
|
34
37
|
static let required_client_id = "Required key missing: client_id"
|
|
35
38
|
static let required_client_secret = "Required key missing: client_secret"
|
|
36
39
|
static let required_contactKey = "Required key missing: contactKey"
|
|
40
|
+
static let required_regionid = "Region id cannot be empty or null"
|
|
41
|
+
static let required_poiid = "POI id cannot be empty or null"
|
|
42
|
+
static let required_locationid = "Location id cannot be empty or null"
|
|
43
|
+
static let notfound_regionid = "Unable to fetch region info"
|
|
44
|
+
static let regionid_notexist = "Region id invalid"
|
|
45
|
+
static let notfound_locationid = "Unable to fetch location info"
|
|
46
|
+
static let notfound_poiid = "Unable to fetch POI info"
|
|
37
47
|
static let plugin_errorcode = 10001
|
|
38
48
|
static let plugin_errorDomain = "WoosmapGeofencePlugin"
|
|
39
49
|
static let plugin_parsingFailed = "Something wrong while processing data. Please check input parameters"
|
|
50
|
+
static let invalid_profilesourcetype = "Provide valid source type type (local/external)"
|
|
51
|
+
static let invalid_profilefile = "Invalid profile file"
|
|
40
52
|
}
|