@woosmap/react-native-plugin-geofencing 0.1.6 → 0.1.9

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 (100) hide show
  1. package/README.md +219 -19
  2. package/android/build.gradle +7 -0
  3. package/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +324 -31
  4. package/android/src/main/java/com/reactnativeplugingeofencing/WoosRegionReadyListener.java +1 -7
  5. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +17 -0
  6. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapTask.java +299 -0
  7. package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +118 -2
  8. package/ios/DataLocation.swift +4 -0
  9. package/ios/DataPOI.swift +11 -0
  10. package/ios/DataRegion.swift +33 -3
  11. package/ios/PluginGeofencing.m +43 -0
  12. package/ios/PluginGeofencing.swift +377 -22
  13. package/ios/WoosmapGeofenceMessage.swift +12 -0
  14. package/ios/WoosmapGeofenceService.swift +203 -30
  15. package/lib/commonjs/index.js +171 -68
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/{Airship.js → internal/Airship.js} +0 -0
  18. package/lib/commonjs/internal/Airship.js.map +1 -0
  19. package/lib/commonjs/{Location.js → internal/Location.js} +0 -0
  20. package/lib/commonjs/{Location.js.map → internal/Location.js.map} +1 -1
  21. package/lib/commonjs/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
  22. package/lib/commonjs/internal/MarketingCloud.js.map +1 -0
  23. package/lib/{module → commonjs/internal}/Poi.js +10 -1
  24. package/lib/commonjs/internal/Poi.js.map +1 -0
  25. package/lib/commonjs/{Region.js → internal/Region.js} +0 -0
  26. package/lib/commonjs/internal/Region.js.map +1 -0
  27. package/lib/commonjs/{Visit.js → internal/Visit.js} +0 -0
  28. package/lib/commonjs/internal/Visit.js.map +1 -0
  29. package/lib/commonjs/{Zoi.js → internal/Zoi.js} +0 -0
  30. package/lib/commonjs/internal/Zoi.js.map +1 -0
  31. package/lib/commonjs/internal/nativeInterface.js +18 -0
  32. package/lib/commonjs/internal/nativeInterface.js.map +1 -0
  33. package/lib/commonjs/internal/types.js +2 -0
  34. package/lib/commonjs/internal/types.js.map +1 -0
  35. package/lib/module/index.js +155 -53
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/{Airship.js → internal/Airship.js} +0 -0
  38. package/lib/module/internal/Airship.js.map +1 -0
  39. package/lib/module/{Location.js → internal/Location.js} +0 -0
  40. package/lib/module/internal/Location.js.map +1 -0
  41. package/lib/module/{MarketingCloud.js → internal/MarketingCloud.js} +0 -0
  42. package/lib/module/internal/MarketingCloud.js.map +1 -0
  43. package/lib/{commonjs → module/internal}/Poi.js +2 -3
  44. package/lib/module/internal/Poi.js.map +1 -0
  45. package/lib/module/{Region.js → internal/Region.js} +0 -0
  46. package/lib/module/internal/Region.js.map +1 -0
  47. package/lib/module/{Visit.js → internal/Visit.js} +0 -0
  48. package/lib/module/internal/Visit.js.map +1 -0
  49. package/lib/module/{Zoi.js → internal/Zoi.js} +0 -0
  50. package/lib/module/internal/Zoi.js.map +1 -0
  51. package/lib/module/internal/nativeInterface.js +9 -0
  52. package/lib/module/internal/nativeInterface.js.map +1 -0
  53. package/lib/module/internal/types.js +2 -0
  54. package/lib/module/internal/types.js.map +1 -0
  55. package/lib/typescript/index.d.ts +63 -4
  56. package/lib/typescript/{Airship.d.ts → internal/Airship.d.ts} +0 -0
  57. package/lib/typescript/{Location.d.ts → internal/Location.d.ts} +0 -0
  58. package/lib/typescript/{MarketingCloud.d.ts → internal/MarketingCloud.d.ts} +0 -0
  59. package/lib/typescript/{Poi.d.ts → internal/Poi.d.ts} +4 -2
  60. package/lib/typescript/{Region.d.ts → internal/Region.d.ts} +0 -0
  61. package/lib/typescript/{Visit.d.ts → internal/Visit.d.ts} +0 -0
  62. package/lib/typescript/{Zoi.d.ts → internal/Zoi.d.ts} +0 -0
  63. package/lib/typescript/internal/nativeInterface.d.ts +2 -0
  64. package/lib/typescript/internal/types.d.ts +18 -0
  65. package/package.json +1 -1
  66. package/src/index.tsx +173 -53
  67. package/src/{Airship.tsx → internal/Airship.tsx} +0 -0
  68. package/src/{Location.tsx → internal/Location.tsx} +0 -0
  69. package/src/{MarketingCloud.tsx → internal/MarketingCloud.tsx} +0 -0
  70. package/src/{Poi.tsx → internal/Poi.tsx} +4 -3
  71. package/src/{Region.tsx → internal/Region.tsx} +0 -0
  72. package/src/{Visit.tsx → internal/Visit.tsx} +0 -0
  73. package/src/{Zoi.tsx → internal/Zoi.tsx} +0 -0
  74. package/src/internal/nativeInterface.tsx +8 -0
  75. package/src/internal/types.tsx +20 -0
  76. package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  77. package/android/.gradle/7.1.1/dependencies-accessors/gc.properties +0 -0
  78. package/android/.gradle/7.1.1/executionHistory/executionHistory.lock +0 -0
  79. package/android/.gradle/7.1.1/fileChanges/last-build.bin +0 -0
  80. package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
  81. package/android/.gradle/7.1.1/gc.properties +0 -0
  82. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  83. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  84. package/android/.gradle/checksums/checksums.lock +0 -0
  85. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  86. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  87. package/android/.gradle/vcs-1/gc.properties +0 -0
  88. package/lib/commonjs/Airship.js.map +0 -1
  89. package/lib/commonjs/MarketingCloud.js.map +0 -1
  90. package/lib/commonjs/Poi.js.map +0 -1
  91. package/lib/commonjs/Region.js.map +0 -1
  92. package/lib/commonjs/Visit.js.map +0 -1
  93. package/lib/commonjs/Zoi.js.map +0 -1
  94. package/lib/module/Airship.js.map +0 -1
  95. package/lib/module/Location.js.map +0 -1
  96. package/lib/module/MarketingCloud.js.map +0 -1
  97. package/lib/module/Poi.js.map +0 -1
  98. package/lib/module/Region.js.map +0 -1
  99. package/lib/module/Visit.js.map +0 -1
  100. package/lib/module/Zoi.js.map +0 -1
@@ -0,0 +1,299 @@
1
+ package com.reactnativeplugingeofencing;
2
+
3
+ import android.content.Context;
4
+ import android.os.Build;
5
+
6
+
7
+ import androidx.annotation.RequiresApi;
8
+
9
+
10
+ import com.facebook.react.bridge.Arguments;
11
+ import com.facebook.react.bridge.Promise;
12
+ import com.facebook.react.bridge.WritableArray;
13
+ import com.facebook.react.bridge.WritableNativeArray;
14
+ import com.google.android.gms.maps.model.LatLng;
15
+ import com.webgeoservices.woosmapgeofencing.Woosmap;
16
+ import com.webgeoservices.woosmapgeofencing.database.MovingPosition;
17
+ import com.webgeoservices.woosmapgeofencing.database.POI;
18
+ import com.webgeoservices.woosmapgeofencing.database.Region;
19
+ import com.webgeoservices.woosmapgeofencing.database.WoosmapDb;
20
+
21
+ import org.json.JSONObject;
22
+
23
+ import java.util.concurrent.CompletableFuture;
24
+ import java.util.concurrent.CompletionException;
25
+ import java.util.function.Supplier;
26
+
27
+ public class WoosmapTask {
28
+ private static WoosmapTask _instance = null;
29
+ private final Context context;
30
+
31
+ public static WoosmapTask getInstance(Context context) {
32
+ if (_instance == null) {
33
+ _instance = new WoosmapTask(context);
34
+ }
35
+ return _instance;
36
+ }
37
+
38
+ private WoosmapTask(Context context) {
39
+ this.context = context;
40
+ }
41
+
42
+ @RequiresApi(api = Build.VERSION_CODES.N)
43
+ public void addRegion(final Region region, final Promise promise) {
44
+ CompletableFuture.supplyAsync(() -> {
45
+ try {
46
+ if ((!region.type.isEmpty()) && (!region.type.equalsIgnoreCase(WoosmapMessageAndKey.isochroneTypeKey) && !region.type.equalsIgnoreCase(WoosmapMessageAndKey.circleTypeKey))) {
47
+ throw new Exception(WoosmapMessageAndKey.validRegionTypeMessage);
48
+ }
49
+ if (region.idStore.isEmpty() && region.type.isEmpty()) {
50
+ Woosmap.getInstance().addGeofence(region.identifier, new LatLng(region.lat, region.lng), (float) region.radius);
51
+ } else if (!region.idStore.isEmpty() && region.type.isEmpty()) {
52
+ Woosmap.getInstance().addGeofence(region.identifier, new LatLng(region.lat, region.lng), (float) region.radius, region.idStore);
53
+ } else if (!region.type.isEmpty() && region.idStore.isEmpty()) {
54
+ Woosmap.getInstance().addGeofence(region.identifier, new LatLng(region.lat, region.lng), (float) region.radius, region.type);
55
+ } else {
56
+ Woosmap.getInstance().addGeofence(region.identifier, new LatLng(region.lat, region.lng), (float) region.radius, region.idStore, region.type);
57
+ }
58
+
59
+ } catch (Exception ex) {
60
+ throw new CompletionException(ex);
61
+ }
62
+ return region.identifier;
63
+ }).whenComplete((data, throwable) -> {
64
+ if (throwable != null) {
65
+ promise.reject(WoosmapMessageAndKey.errorCode, throwable.getMessage());
66
+ } else {
67
+ promise.resolve(data);
68
+ }
69
+ });
70
+ }
71
+
72
+ @RequiresApi(api = Build.VERSION_CODES.N)
73
+ public void enqueGetRegionsRequest(String regionID,Promise promise) {
74
+ CompletableFuture.supplyAsync(() -> {
75
+ try {
76
+ Region region;
77
+ region = WoosmapDb.getInstance(context).getRegionsDAO().getRegionFromId(regionID);
78
+ if(region!=null){
79
+ return WoosmapUtil.getRegionWritableMap(region);
80
+ }
81
+ } catch (Exception ex) {
82
+ throw new CompletionException(ex);
83
+ }
84
+ return null;
85
+ }).whenComplete((data, throwable) -> {
86
+ if (throwable == null) {
87
+ if(data==null){
88
+ promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.invalidRegionid);
89
+ }else {
90
+ promise.resolve(data);
91
+ }
92
+ } else {
93
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
94
+ }
95
+ });
96
+ }
97
+
98
+ @RequiresApi(api = Build.VERSION_CODES.N)
99
+ public void enqueGetRegionsRequest(Promise promise) {
100
+ CompletableFuture.supplyAsync(() -> {
101
+ try {
102
+ Region[] regions;
103
+ WritableArray array= Arguments.createArray();
104
+ regions = WoosmapDb.getInstance(context).getRegionsDAO().getAllRegions();
105
+ for (Region region : regions) {
106
+ array.pushMap(WoosmapUtil.getRegionWritableMap(region));
107
+ }
108
+ return array;
109
+ } catch (Exception ex) {
110
+ throw new CompletionException(ex);
111
+ }
112
+ }).whenComplete((data, throwable) -> {
113
+ if (throwable == null) {
114
+ promise.resolve(data);
115
+ } else {
116
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
117
+ }
118
+ });
119
+ }
120
+ @RequiresApi(api = Build.VERSION_CODES.N)
121
+ public void removeRegion(String regionId, final Promise promise){
122
+ CompletableFuture.supplyAsync((Supplier<Void>) () -> {
123
+ try{
124
+ if (!regionId.isEmpty()){
125
+ Woosmap.getInstance().removeGeofence(regionId);
126
+ WoosmapDb.getInstance(context).getRegionsDAO().deleteRegionFromId(regionId);
127
+ }
128
+ else{
129
+ Woosmap.getInstance().removeGeofence();
130
+ WoosmapDb.getInstance(context).getRegionsDAO().deleteAllRegions();
131
+ }
132
+ }
133
+ catch (Exception ex){
134
+ throw new CompletionException(ex);
135
+ }
136
+ return null;
137
+ }).whenComplete((unused, throwable) -> {
138
+ if (throwable==null){
139
+ promise.resolve(WoosmapMessageAndKey.deleteMessage);
140
+ }
141
+ else{
142
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
143
+ }
144
+ });
145
+ }
146
+
147
+ @RequiresApi(api = Build.VERSION_CODES.N)
148
+ public void removeAllPois(final Promise promise){
149
+ CompletableFuture.supplyAsync((Supplier<Void>) () -> {
150
+ try{
151
+ WoosmapDb.getInstance(context).getPOIsDAO().deleteAllPOIs();
152
+ }
153
+ catch (Exception ex){
154
+ throw new CompletionException(ex);
155
+ }
156
+ return null;
157
+ }).whenComplete((unused, throwable) -> {
158
+ if (throwable==null){
159
+ promise.resolve(WoosmapMessageAndKey.deleteMessage);
160
+ }
161
+ else{
162
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
163
+ }
164
+ });
165
+ }
166
+
167
+ @RequiresApi(api = Build.VERSION_CODES.N)
168
+ public void enqueGetAllPoiRequest(Promise promise) {
169
+ CompletableFuture.supplyAsync(() -> {
170
+ try {
171
+ POI[] pois;
172
+ WritableArray array= Arguments.createArray();
173
+ pois = WoosmapDb.getInstance(context).getPOIsDAO().getAllPOIs();
174
+ for (POI poi : pois) {
175
+ array.pushMap(WoosmapUtil.getPOIWritableMap(poi));
176
+ }
177
+ return array;
178
+ } catch (Exception ex) {
179
+ throw new CompletionException(ex);
180
+ }
181
+ }).whenComplete((data, throwable) -> {
182
+ if (throwable == null) {
183
+ promise.resolve(data);
184
+ } else {
185
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
186
+ }
187
+ });
188
+ }
189
+ @RequiresApi(api = Build.VERSION_CODES.N)
190
+ public void enqueGetPOIRequest(String locationID,Promise promise) {
191
+ CompletableFuture.supplyAsync(() -> {
192
+ try {
193
+ POI poi;
194
+ poi = WoosmapDb.getInstance(context).getPOIsDAO().getPOIbyStoreId(locationID);
195
+ if(poi!=null){
196
+ return WoosmapUtil.getPOIWritableMap(poi);
197
+ }else {
198
+ if(WoosmapUtil.onlyContainsNumbers(locationID)){
199
+ poi = WoosmapDb.getInstance(context).getPOIsDAO().getPOIbyLocationID(Integer.parseInt(locationID));
200
+ if(poi!=null){
201
+ return WoosmapUtil.getPOIWritableMap(poi);
202
+ }
203
+ }
204
+ }
205
+ } catch (Exception ex) {
206
+ throw new CompletionException(ex);
207
+ }
208
+ return null;
209
+ }).whenComplete((data, throwable) -> {
210
+ if (throwable == null) {
211
+ if(data==null){
212
+ promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.invalidLocationid);
213
+ }else {
214
+ promise.resolve(data);
215
+ }
216
+ } else {
217
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
218
+ }
219
+ });
220
+ }
221
+ @RequiresApi(api = Build.VERSION_CODES.N)
222
+ protected void enqueueGetLocationRequest(String locationID,Promise promise) {
223
+ CompletableFuture.supplyAsync(() -> {
224
+ try {
225
+ MovingPosition requiredLocation=null;
226
+ MovingPosition[]movingPosition;
227
+ movingPosition = WoosmapDb.getInstance(context).getMovingPositionsDao().getMovingPositions(-1);
228
+ for (MovingPosition location : movingPosition) {
229
+ if(location.id==Integer.parseInt(locationID)){
230
+ requiredLocation=location;
231
+ break;
232
+ }
233
+ }
234
+ if(requiredLocation!=null){
235
+ return WoosmapUtil.getMovingPositionObject(requiredLocation);
236
+ }
237
+
238
+ } catch (Exception ex) {
239
+ throw new CompletionException(ex);
240
+ }
241
+ return null;
242
+ }).whenComplete((data, throwable) -> {
243
+ if (throwable == null) {
244
+ if(data==null){
245
+ promise.reject(WoosmapMessageAndKey.errorCode,WoosmapMessageAndKey.invalidLocationID);
246
+ }else {
247
+ promise.resolve(data);
248
+ }
249
+ } else {
250
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
251
+ }
252
+ });
253
+ }
254
+
255
+ @RequiresApi(api = Build.VERSION_CODES.N)
256
+ protected void enqueueGetLocationRequest(Promise promise) {
257
+ CompletableFuture.supplyAsync(() -> {
258
+ try {
259
+ MovingPosition[]movingPosition;
260
+ WritableArray array= Arguments.createArray();
261
+ movingPosition = WoosmapDb.getInstance(context).getMovingPositionsDao().getMovingPositions(-1);
262
+ for (MovingPosition location : movingPosition) {
263
+ array.pushMap(WoosmapUtil.getMovingPositionObject(location));
264
+ }
265
+ return array;
266
+ } catch (Exception ex) {
267
+ throw new CompletionException(ex);
268
+ }
269
+ }).whenComplete((data, throwable) -> {
270
+ if (throwable == null) {
271
+ promise.resolve(data);
272
+ } else {
273
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
274
+ }
275
+ });
276
+ }
277
+ @RequiresApi(api = Build.VERSION_CODES.N)
278
+ protected void removeAllLocation(final Promise promise){
279
+ CompletableFuture.supplyAsync((Supplier<Void>) () -> {
280
+ try{
281
+ WoosmapDb.getInstance(context).getMovingPositionsDao().deleteAllMovingPositions();
282
+ }
283
+ catch (Exception ex){
284
+ throw new CompletionException(ex);
285
+ }
286
+ return null;
287
+ }).whenComplete((unused, throwable) -> {
288
+ if (throwable==null){
289
+ promise.resolve(WoosmapMessageAndKey.deleteMessage);
290
+ }
291
+ else{
292
+ promise.reject(WoosmapMessageAndKey.errorCode,throwable.getMessage());
293
+ }
294
+ });
295
+ }
296
+
297
+
298
+
299
+ }
@@ -3,10 +3,14 @@ package com.reactnativeplugingeofencing;
3
3
  import android.location.Location;
4
4
  import android.util.Log;
5
5
 
6
+ import androidx.annotation.Nullable;
7
+
6
8
  import com.facebook.react.bridge.WritableArray;
7
9
  import com.facebook.react.bridge.WritableMap;
8
10
  import com.facebook.react.bridge.WritableNativeArray;
9
11
  import com.facebook.react.bridge.WritableNativeMap;
12
+ import com.webgeoservices.woosmapgeofencing.database.MovingPosition;
13
+ import com.webgeoservices.woosmapgeofencing.database.POI;
10
14
  import com.webgeoservices.woosmapgeofencing.database.Region;
11
15
  import com.webgeoservices.woosmapgeofencing.database.RegionLog;
12
16
 
@@ -42,7 +46,11 @@ public class WoosmapUtil {
42
46
  map.putDouble("latitude", regionLog.lat);
43
47
  map.putDouble("date", regionLog.dateTime);
44
48
  map.putBoolean("didenter", regionLog.didEnter);
45
- map.putString("identifier", regionLog.identifier);
49
+ if(!regionLog.idStore.isEmpty()){
50
+ map.putString("identifier", regionLog.idStore);
51
+ }else {
52
+ map.putString("identifier", regionLog.identifier);
53
+ }
46
54
  map.putDouble("radius", regionLog.radius);
47
55
  map.putBoolean("frompositiondetection", regionLog.isCurrentPositionInside);
48
56
  return map;
@@ -60,7 +68,11 @@ public class WoosmapUtil {
60
68
  map.putDouble("latitude", region.lat);
61
69
  map.putDouble("date", region.dateTime);
62
70
  map.putBoolean("didenter", region.didEnter);
63
- map.putString("identifier", region.identifier);
71
+ if(!region.idStore.isEmpty()){
72
+ map.putString("identifier", region.idStore);
73
+ }else {
74
+ map.putString("identifier", region.identifier);
75
+ }
64
76
  map.putDouble("radius", region.radius);
65
77
  map.putBoolean("frompositiondetection", region.isCurrentPositionInside);
66
78
  return map;
@@ -71,4 +83,108 @@ public class WoosmapUtil {
71
83
  return null;
72
84
  }
73
85
 
86
+ @Nullable
87
+ protected static WritableMap getPOIWritableMap(POI poi){
88
+ WritableMap map=new WritableNativeMap();
89
+ try{
90
+ map.putDouble("date", poi.dateTime);
91
+ map.putDouble("distance", poi.distance);
92
+ map.putString("locationid", String.valueOf(poi.locationId));
93
+ map.putDouble("latitude", poi.lat);
94
+ map.putDouble("longitude", poi.lng);
95
+ map.putString("city", poi.city);
96
+ map.putString("idstore", poi.idStore);
97
+ map.putString("name", poi.name);
98
+ map.putString("duration", poi.duration);
99
+ map.putString("zipcode", poi.zipCode);
100
+ //map.putString("jsondata", poi.data);
101
+ try {
102
+ JSONObject obj = new JSONObject(poi.data);
103
+ map.putMap("jsondata", convertJsonToMap(obj));
104
+ } catch (Throwable t) {
105
+ Log.e("Geofence Plugin", "Could not parse malformed JSON: \"" + poi.data + "\"");
106
+ }
107
+
108
+ return map;
109
+ }
110
+ catch (Exception ex){
111
+ Log.e(TAG,ex.toString());
112
+ }
113
+ return null;
114
+ }
115
+
116
+ public static WritableArray convertJsonToArray(JSONArray jsonArray) throws JSONException {
117
+ WritableArray array = new WritableNativeArray();
118
+
119
+ for (int i = 0; i < jsonArray.length(); i++) {
120
+ Object value = jsonArray.get(i);
121
+ if (value instanceof JSONObject) {
122
+ array.pushMap(convertJsonToMap((JSONObject) value));
123
+ } else if (value instanceof JSONArray) {
124
+ array.pushArray(convertJsonToArray((JSONArray) value));
125
+ } else if (value instanceof Boolean) {
126
+ array.pushBoolean((Boolean) value);
127
+ } else if (value instanceof Integer) {
128
+ array.pushInt((Integer) value);
129
+ } else if (value instanceof Double) {
130
+ array.pushDouble((Double) value);
131
+ } else if (value instanceof String) {
132
+ array.pushString((String) value);
133
+ } else {
134
+ array.pushString(String.valueOf(value));
135
+ }
136
+ }
137
+ return array;
138
+ }
139
+
140
+ private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
141
+ WritableMap map = new WritableNativeMap();
142
+
143
+ Iterator<String> iterator = jsonObject.keys();
144
+ while (iterator.hasNext()) {
145
+ String key = iterator.next();
146
+ Object value = jsonObject.get(key);
147
+ if (value instanceof JSONObject) {
148
+ map.putMap(key, convertJsonToMap((JSONObject) value));
149
+ } else if (value instanceof JSONArray) {
150
+ map.putArray(key, convertJsonToArray((JSONArray) value));
151
+ } else if (value instanceof Boolean) {
152
+ map.putBoolean(key, (Boolean) value);
153
+ } else if (value instanceof Integer) {
154
+ map.putInt(key, (Integer) value);
155
+ } else if (value instanceof Double) {
156
+ map.putDouble(key, (Double) value);
157
+ } else if (value instanceof String) {
158
+ map.putString(key, (String) value);
159
+ } else {
160
+ map.putString(key, String.valueOf(value));
161
+ }
162
+ }
163
+ return map;
164
+ }
165
+ protected static WritableMap getMovingPositionObject(MovingPosition location){
166
+ try{
167
+ WritableMap map=new WritableNativeMap();
168
+ map.putDouble("latitude", location.lat);
169
+ map.putDouble("longitude", location.lng);
170
+ map.putString("locationid", String.valueOf(location.id));
171
+ map.putString("locationdescription", "description");
172
+ map.putDouble("date", location.dateTime);
173
+ return map;
174
+ }
175
+ catch (Exception ex){
176
+ Log.e(TAG,ex.toString());
177
+ }
178
+ return null;
179
+ }
180
+ protected static boolean onlyContainsNumbers(String text) {
181
+ try {
182
+ Long.parseLong(text);
183
+ return true;
184
+ } catch (NumberFormatException ex) {
185
+ return false;
186
+ }
187
+ }
188
+
189
+
74
190
  }
@@ -36,6 +36,10 @@ public class DataLocation: LocationServiceDelegate {
36
36
  public func readLocations() -> [Location] {
37
37
  return Locations.getAll()
38
38
  }
39
+
40
+ public func readLocations(id:String) -> Location? {
41
+ return Locations.getLocationByLocationID(locationId: id)
42
+ }
39
43
 
40
44
  public func eraseLocations() {
41
45
  Locations.deleteAll()
package/ios/DataPOI.swift CHANGED
@@ -22,6 +22,17 @@ public class DataPOI: SearchAPIDelegate {
22
22
  public func readPOI() -> [POI] {
23
23
  return POIs.getAll()
24
24
  }
25
+
26
+ public func readPOI(id: String) ->POI? {
27
+ if let poiinfo = POIs.getPOIbyIdStore(idstore: id){
28
+ return poiinfo
29
+ }
30
+ return POIs.getPOIbyLocationID(locationId: id);
31
+ }
32
+
33
+ public func readPOIByStore(id: String) ->POI? {
34
+ return POIs.getPOIbyIdStore(idstore: id);
35
+ }
25
36
 
26
37
  func getPOIbyLocationID(locationId: String) -> POI? {
27
38
  return POIs.getPOIbyLocationID(locationId: locationId)
@@ -33,15 +33,45 @@ public class DataRegion: RegionsServiceDelegate {
33
33
  public func homeZOIEnter(classifiedRegion: Region) {
34
34
  NotificationCenter.default.post(name: .didEventPOIRegion, object: self, userInfo: ["Region": classifiedRegion])
35
35
  }
36
-
36
+
37
+ /// Read POI Regions
38
+ /// - Returns: Region info
37
39
  public func readRegions() -> [Region] {
38
40
  return Regions.getAll()
39
41
  }
40
-
42
+
43
+ /// Read POI Regions
44
+ /// - Parameter id: Identifier
45
+ /// - Returns: Region info
46
+ public func readRegions(id:String) -> Region? {
47
+ return Regions.getRegionFromId(id: id)
48
+ }
49
+
50
+ /// Read Isochrone Regions
51
+ /// - Returns: Region info
52
+ public func readIsochroneRegions() -> [RegionIsochrone] {
53
+ return RegionIsochrones.getAll()
54
+ }
55
+
56
+ /// Read Isochrone Regions
57
+ /// - Parameter id: Identifier
58
+ /// - Returns: Region info
59
+ public func readIsochroneRegions(id:String) -> RegionIsochrone? {
60
+ return RegionIsochrones.getRegionFromId(id: id)
61
+ }
62
+
63
+ /// Erase All Regions
41
64
  public func eraseRegions() {
42
65
  Regions.deleteAll()
66
+ RegionIsochrones.deleteAll()
43
67
  }
44
-
68
+
69
+ /// Erase Regions by ID
70
+ /// - Parameter id: Identifier
71
+ public func eraseRegions(id:String) {
72
+ RegionIsochrones.removeRegionIsochrone(id: id)
73
+ }
74
+
45
75
  }
46
76
 
47
77
  extension Notification.Name {
@@ -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