@woosmap/react-native-plugin-geofencing 0.1.4 → 0.1.5

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 CHANGED
@@ -46,8 +46,6 @@ if you are using **M1 Mac** Update pod post installation like
46
46
  end
47
47
  ```
48
48
 
49
- For Android
50
- - ToDo: Please update for Android
51
49
 
52
50
  ### Supported Platforms ###
53
51
  ---
@@ -94,9 +92,10 @@ WoosmapGeofencing.getPermissionsStatus()
94
92
  ```
95
93
 
96
94
  Parameter status will be a string, one of:
97
- * `GRANTED_BACKGROUND` : User has granted location access even when app is not running in the foreground
98
- * `GRANTED_FOREGROUND` : Location access is granted only while user is using the app
99
- * `DENIED`: Location access is denied
95
+ * `GRANTED_BACKGROUND` : User has granted location access even when app is not running in the foreground.
96
+ * `GRANTED_FOREGROUND` : Location access is granted only while user is using the app.
97
+ * `DENIED`: Location access is denied.
98
+ * `UNKNOWN`: Without providing or denying any permission then it will return unknown.
100
99
 
101
100
  **_Please note_**: Plugin will not work as expected if location access is denied.
102
101
 
@@ -10,9 +10,9 @@ public class WoosmapMessageAndKey {
10
10
  protected static String permissionNotGrantedMessage="Required permissions not granted";
11
11
  protected static String permissionValueNotProvided="Permission value not provided";
12
12
  protected static String unknownMessage="UNKNOWN";
13
- protected static String deniedPermissionMessage="PERMISSION_STATUS_DENIED";
14
- protected static String foregroundPermissionGrantedMessage="PERMISSION_STATUS_GRANTED_FOREGROUND";
15
- protected static String backgroundPermissionGrantedMessage="PERMISSION_STATUS_GRANTED_BACKGROUND";
13
+ protected static String deniedPermissionMessage="DENIED";
14
+ protected static String foregroundPermissionGrantedMessage="GRANTED_FOREGROUND";
15
+ protected static String backgroundPermissionGrantedMessage="GRANTED_BACKGROUND";
16
16
  protected static String woosmapKeyNotProvide="Woosmap API Key not provided";
17
17
  protected static String woosmapNotInitialized="Woosmap not initialized";
18
18
  protected static String trackingProfileNotProvided="Tracking profile is missing";
@@ -7,29 +7,22 @@
7
7
  import Foundation
8
8
  import CoreLocation
9
9
  import WoosmapGeofencing
10
+ import SwiftUI
10
11
 
11
12
  public class DataDistance: DistanceAPIDelegate {
12
- public func distanceAPIResponse(distance: [Distance]) {
13
-
14
- }
15
13
 
16
14
  public init() {}
17
15
 
18
- public func distanceAPIResponseData(distanceAPIData: DistanceAPIData, locationId: String) {
19
- if distanceAPIData.status == "OK" {
20
- if distanceAPIData.rows?.first?.elements?.first?.status == "OK" {
21
- let distance = distanceAPIData.rows?.first?.elements?.first?.distance
22
- let duration = distanceAPIData.rows?.first?.elements?.first?.duration
23
- if distance != nil && duration != nil {
24
- // TODO: Implementation missing
25
- //let result: DistanceResponseResult = DistanceResponseResult.init(locationId: locationId, distance: distance!, duration: duration!)
26
- //NotificationCenter.default.post(name: .distanceCalculated, object: self, userInfo: ["Distance": result])
27
- }
28
- }
29
- } else {
30
- let result: DistanceResponseError = DistanceResponseError.init(locationId: locationId, error: distanceAPIData.status ?? "-")
31
- NotificationCenter.default.post(name: .distanceCalculated, object: self, userInfo: ["Distance": result])
32
- }
16
+ public func distanceAPIResponse(distance: [Distance]) {
17
+
18
+ distance.forEach({ distanceElement in
19
+ let distance = distanceElement.distance
20
+ let duration = distanceElement.duration
21
+ let result: DistanceResponseResult = DistanceResponseResult.init(distance: distance, duration: duration)
22
+ NotificationCenter.default.post(name: .distanceCalculated, object: self, userInfo: ["Distance": result])
23
+ // print(distance?.value ?? 0)
24
+ // print(duration?.text ?? 0)
25
+ })
33
26
  }
34
27
 
35
28
  public func distanceAPIError(error: String) {
@@ -42,11 +35,9 @@ extension Notification.Name {
42
35
  }
43
36
 
44
37
  class DistanceResponseResult {
45
- var locationId: String = ""
46
- var distance: Distance
47
- var duration: Distance
48
- required init(locationId: String, distance: Distance, duration: Distance) {
49
- self.locationId = locationId
38
+ var distance: Int
39
+ var duration: Int
40
+ required init(distance: Int, duration: Int) {
50
41
  self.distance = distance
51
42
  self.duration = duration
52
43
  }
@@ -15,6 +15,18 @@ public class DataLocation: LocationServiceDelegate {
15
15
 
16
16
  public func tracingLocation(location: Location) {
17
17
  NotificationCenter.default.post(name: .newLocationSaved, object: self, userInfo: ["Location": location])
18
+
19
+ // let content = UNMutableNotificationContent()
20
+ // content.title = "Location update"
21
+ // content.body = "Location = " + "Lat = " + String(format: "%f", location.latitude) + " Lng = " + String(format: "%f", location.longitude)
22
+ // // Create the request
23
+ // let uuidString = UUID().uuidString
24
+ // let request = UNNotificationRequest(identifier: uuidString,
25
+ // content: content, trigger: nil)
26
+ //
27
+ // // Schedule the request with the system.
28
+ // let notificationCenter = UNUserNotificationCenter.current()
29
+ // notificationCenter.add(request)
18
30
  }
19
31
 
20
32
  public func tracingLocationDidFailWithError(error: Error) {
@@ -20,12 +20,10 @@ public class DataRegion: RegionsServiceDelegate {
20
20
 
21
21
  public func didEnterPOIRegion(POIregion: Region) {
22
22
  NotificationCenter.default.post(name: .didEventPOIRegion, object: self, userInfo: ["Region": POIregion])
23
- sendNotification(POIregion: POIregion, didEnter: true)
24
23
  }
25
24
 
26
25
  public func didExitPOIRegion(POIregion: Region) {
27
26
  NotificationCenter.default.post(name: .didEventPOIRegion, object: self, userInfo: ["Region": POIregion])
28
- sendNotification(POIregion: POIregion, didEnter: false)
29
27
  }
30
28
 
31
29
  public func workZOIEnter(classifiedRegion: Region) {
@@ -44,31 +42,6 @@ public class DataRegion: RegionsServiceDelegate {
44
42
  Regions.deleteAll()
45
43
  }
46
44
 
47
- public func sendNotification(POIregion: Region, didEnter: Bool) {
48
- let content = UNMutableNotificationContent()
49
- if didEnter {
50
- content.title = "Region enter"
51
- } else {
52
- content.title = "Region exit"
53
- }
54
- content.body = "Region = " + POIregion.identifier
55
- content.body += "Lat = " + String(format: "%f", POIregion.latitude) + " Lng = " + String(format: "%f", POIregion.longitude)
56
- content.body += "\n FromPositionDetection = " + String(POIregion.fromPositionDetection)
57
- // Create the request
58
- let uuidString = UUID().uuidString
59
- let request = UNNotificationRequest(identifier: uuidString,
60
- content: content, trigger: nil)
61
-
62
- let center = UNUserNotificationCenter.current()
63
- center.getNotificationSettings { settings in
64
- if settings.authorizationStatus == .authorized {
65
- // Schedule the request with the system.
66
- let notificationCenter = UNUserNotificationCenter.current()
67
- notificationCenter.add(request)
68
- }
69
- }
70
-
71
- }
72
45
  }
73
46
 
74
47
  extension Notification.Name {
@@ -22,42 +22,42 @@ public class MarketingCloudEvents: MarketingCloudEventsDelegate {
22
22
 
23
23
  public func regionEnterEvent(regionEvent: [String: Any], eventName: String) {
24
24
  // here you can modify your event name and add your data in the dictonnary
25
- print("MarketingCloudEvents regionEnterEvent")
25
+ //print("MarketingCloudEvents regionEnterEvent")
26
26
  let result: MarketingData = MarketingData.init(eventname: eventName, properties: regionEvent)
27
27
  NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
28
28
  }
29
29
 
30
30
  public func regionExitEvent(regionEvent: [String: Any], eventName: String) {
31
31
  // here you can modify your event name and add your data in the dictonnary
32
- print("MarketingCloudEvents regionExitEvent")
32
+ //print("MarketingCloudEvents regionExitEvent")
33
33
  let result: MarketingData = MarketingData.init(eventname: eventName, properties: regionEvent)
34
34
  NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
35
35
  }
36
36
 
37
37
  public func visitEvent(visitEvent: [String: Any], eventName: String) {
38
38
  // here you can modify your event name and add your data in the dictonnary
39
- print("MarketingCloudEvents visitEvent")
39
+ //print("MarketingCloudEvents visitEvent")
40
40
  let result: MarketingData = MarketingData.init(eventname: eventName, properties: visitEvent)
41
41
  NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
42
42
  }
43
43
 
44
44
  public func poiEvent(POIEvent: [String: Any], eventName: String) {
45
45
  // here you can modify your event name and add your data in the dictonnary
46
- print("MarketingCloudEvents poiEvent")
46
+ //print("MarketingCloudEvents poiEvent")
47
47
  let result: MarketingData = MarketingData.init(eventname: eventName, properties: POIEvent)
48
48
  NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
49
49
  }
50
50
 
51
51
  public func ZOIclassifiedEnter(regionEvent: [String: Any], eventName: String) {
52
52
  // here you can modify your event name and add your data in the dictonnary
53
- print("MarketingCloudEvents ZOIclassifiedEnter")
53
+ //print("MarketingCloudEvents ZOIclassifiedEnter")
54
54
  let result: MarketingData = MarketingData.init(eventname: eventName, properties: regionEvent)
55
55
  NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
56
56
  }
57
57
 
58
58
  public func ZOIclassifiedExit(regionEvent: [String: Any], eventName: String) {
59
59
  // here you can modify your event name and add your data in the dictonnary
60
- print("MarketingCloudEvents ZOIclassifiedExit")
60
+ //print("MarketingCloudEvents ZOIclassifiedExit")
61
61
  let result: MarketingData = MarketingData.init(eventname: eventName, properties: regionEvent)
62
62
  NotificationCenter.default.post(name: .marketingEvent, object: self, userInfo: ["Marketing": result])
63
63
  }
@@ -613,10 +613,9 @@ class PluginGeofencing: RCTEventEmitter {
613
613
 
614
614
  private func formatDistanceData(woosdata: DistanceResponseResult) -> [AnyHashable: Any] {
615
615
  var result: [AnyHashable: Any] = [:]
616
- result["locationid"] = woosdata.locationId
617
- //TODO: format it
618
- result["distance"] = "" //woosdata.distance.text
619
- result["duration"] = "" //woosdata.duration.text
616
+ result["locationid"] = ""//woosdata.locationId
617
+ result["distance"] = String(woosdata.distance)
618
+ result["duration"] = String(woosdata.duration)
620
619
  return result
621
620
  }
622
621
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/react-native-plugin-geofencing",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "This react-native plugin extends the functionality offered by the Woosmap Geofencing Mobile SDKs. Find more about the Woosmap Geofencing SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",