@woosmap/react-native-plugin-geofencing 0.1.3 → 0.1.4
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/android/src/main/java/com/reactnativeplugingeofencing/PluginGeofencingModule.java +104 -18
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosLocationReadyListener.java +3 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosRegionReadyListener.java +3 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapMessageAndKey.java +1 -0
- package/android/src/main/java/com/reactnativeplugingeofencing/WoosmapUtil.java +3 -0
- package/package.json +1 -1
|
@@ -30,6 +30,9 @@ import java.util.ArrayList;
|
|
|
30
30
|
import java.util.HashMap;
|
|
31
31
|
import java.util.Iterator;
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* This is a React native plugin exposing Woosmap Geofencing SDK methods.
|
|
35
|
+
*/
|
|
33
36
|
@ReactModule(name = PluginGeofencingModule.NAME)
|
|
34
37
|
public class PluginGeofencingModule extends ReactContextBaseJavaModule implements PermissionListener, LifecycleEventListener {
|
|
35
38
|
public static final String NAME = "PluginGeofencing";
|
|
@@ -47,6 +50,10 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
47
50
|
this.reactContext.addLifecycleEventListener(this);
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
/***
|
|
54
|
+
* Return plugin name.
|
|
55
|
+
* @return woosmap native plugin name.which is constant for android and ios.
|
|
56
|
+
*/
|
|
50
57
|
@Override
|
|
51
58
|
@NonNull
|
|
52
59
|
public String getName() {
|
|
@@ -62,6 +69,12 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
|
|
72
|
+
/***
|
|
73
|
+
* Initializes Woosmap object with given parameters.
|
|
74
|
+
* @param map ReadableMap may contain privateKeyWoosmapAPI with Woosmap API key,
|
|
75
|
+
* trackingProfile with tracking profile info.
|
|
76
|
+
* @param promise React native callback context.
|
|
77
|
+
*/
|
|
65
78
|
@ReactMethod
|
|
66
79
|
public void initialize(ReadableMap map, Promise promise) {
|
|
67
80
|
String trackingProfile = "";
|
|
@@ -106,6 +119,10 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
106
119
|
|
|
107
120
|
}
|
|
108
121
|
|
|
122
|
+
/***
|
|
123
|
+
* Checks if Woosmap object is instantiated.
|
|
124
|
+
* @return true if woosmap sdk is initialized else false.
|
|
125
|
+
*/
|
|
109
126
|
private boolean isWoosmapInitialized() {
|
|
110
127
|
if (woosmap == null) {
|
|
111
128
|
return false;
|
|
@@ -113,6 +130,10 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
113
130
|
return true;
|
|
114
131
|
}
|
|
115
132
|
|
|
133
|
+
/***
|
|
134
|
+
* Requests permissions. If the background permission is required then ACCESS_BACKGROUND_LOCATION is requested for devices above Android 9.
|
|
135
|
+
* @param data Readable Array containing a boolean parameter to check if the background permission is required.
|
|
136
|
+
*/
|
|
116
137
|
@ReactMethod
|
|
117
138
|
private void requestPermissions(ReadableArray data, Promise promise) {
|
|
118
139
|
try {
|
|
@@ -146,6 +167,10 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
146
167
|
return true;
|
|
147
168
|
}
|
|
148
169
|
|
|
170
|
+
/***
|
|
171
|
+
* Provide status of foreground and background location permission.
|
|
172
|
+
* @param promise React native callback context.
|
|
173
|
+
*/
|
|
149
174
|
private void providePermissionStatus(final Promise promise) {
|
|
150
175
|
try {
|
|
151
176
|
if (promise == null) {
|
|
@@ -179,11 +204,23 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
179
204
|
}
|
|
180
205
|
}
|
|
181
206
|
|
|
207
|
+
/***
|
|
208
|
+
* Checks if the required location permissions are granted or not.
|
|
209
|
+
* Returns PERMISSION_STATUS_DENIED is no permissions are granted.
|
|
210
|
+
* Returns PERMISSION_STATUS_GRANTED_FOREGROUND if foreground location permission is granted.
|
|
211
|
+
* Returns PERMISSION_STATUS_GRANTED_BACKGROUND if background location permission is granted.
|
|
212
|
+
* Returns UNKNOWN is plugin is unable to determine.
|
|
213
|
+
*/
|
|
182
214
|
@ReactMethod
|
|
183
215
|
public void getPermissionsStatus(final Promise promise) {
|
|
184
216
|
providePermissionStatus(promise);
|
|
185
217
|
}
|
|
186
218
|
|
|
219
|
+
/***
|
|
220
|
+
* Check if the user has given location permission.
|
|
221
|
+
* @param isBackground Pass true if the background permission needs to be checked.
|
|
222
|
+
* @return boolean
|
|
223
|
+
*/
|
|
187
224
|
private boolean hasPermission(boolean isBackground) {
|
|
188
225
|
try {
|
|
189
226
|
Activity activity = getCurrentActivity();
|
|
@@ -225,6 +262,11 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
225
262
|
}
|
|
226
263
|
}
|
|
227
264
|
|
|
265
|
+
/***
|
|
266
|
+
* Sets the Woosmap private API key for calling Woosmap APIs.
|
|
267
|
+
* @param data accepts Woosmap API key in a Readable array.
|
|
268
|
+
* @param promise React native callback context.
|
|
269
|
+
*/
|
|
228
270
|
@ReactMethod
|
|
229
271
|
public void setWoosmapApiKey(ReadableArray data, Promise promise) {
|
|
230
272
|
try {
|
|
@@ -248,6 +290,11 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
248
290
|
}
|
|
249
291
|
}
|
|
250
292
|
|
|
293
|
+
/***
|
|
294
|
+
* Starts Woosmap Geofencing tracking.
|
|
295
|
+
* @param data Accepts tracking profile. Value can be either liveTracking, passiveTracking or stopsTracking.
|
|
296
|
+
* @param promise React native callback context.
|
|
297
|
+
*/
|
|
251
298
|
@ReactMethod
|
|
252
299
|
public void startTracking(ReadableArray data, Promise promise) {
|
|
253
300
|
try {
|
|
@@ -273,6 +320,10 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
273
320
|
}
|
|
274
321
|
}
|
|
275
322
|
|
|
323
|
+
/***
|
|
324
|
+
* Stops tracking
|
|
325
|
+
* @param promise React native callback context.
|
|
326
|
+
*/
|
|
276
327
|
@ReactMethod
|
|
277
328
|
public void stopTracking(Promise promise) {
|
|
278
329
|
try {
|
|
@@ -288,6 +339,11 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
288
339
|
}
|
|
289
340
|
}
|
|
290
341
|
|
|
342
|
+
/***
|
|
343
|
+
* Add watch to woosmap location data.
|
|
344
|
+
* @param watchID Unique String value for location listener.
|
|
345
|
+
* @param promise React native callback context.
|
|
346
|
+
*/
|
|
291
347
|
@ReactMethod
|
|
292
348
|
public void watchLocation(String watchID, Promise promise) {
|
|
293
349
|
try {
|
|
@@ -307,6 +363,11 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
307
363
|
}
|
|
308
364
|
}
|
|
309
365
|
|
|
366
|
+
/***
|
|
367
|
+
* Clear woosmap location watch.
|
|
368
|
+
* @param watchID Unique String value for location listener.
|
|
369
|
+
* @param promise React native callback context.
|
|
370
|
+
*/
|
|
310
371
|
@ReactMethod
|
|
311
372
|
public void clearLocationWatch(String watchID, Promise promise) {
|
|
312
373
|
try {
|
|
@@ -322,6 +383,11 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
322
383
|
}
|
|
323
384
|
}
|
|
324
385
|
|
|
386
|
+
/***
|
|
387
|
+
* Sets Sales Force Marketing Cloud credentials.
|
|
388
|
+
* @param map accepts Sales Force Marketing Cloud credentials key in a ReadableMap.
|
|
389
|
+
* @param promise React native callback context.
|
|
390
|
+
*/
|
|
325
391
|
@ReactMethod
|
|
326
392
|
private void setSFMCCredentials(ReadableMap map, Promise promise) {
|
|
327
393
|
try {
|
|
@@ -365,6 +431,11 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
365
431
|
}
|
|
366
432
|
}
|
|
367
433
|
|
|
434
|
+
/***
|
|
435
|
+
* Add watch to woosmap region data.
|
|
436
|
+
* @param watchID Unique String value for region listener.
|
|
437
|
+
* @param promise React native callback context.
|
|
438
|
+
*/
|
|
368
439
|
@ReactMethod
|
|
369
440
|
public void watchRegions(String watchID, Promise promise) {
|
|
370
441
|
try {
|
|
@@ -385,6 +456,12 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
385
456
|
}
|
|
386
457
|
}
|
|
387
458
|
|
|
459
|
+
/***
|
|
460
|
+
* Clear woosmap region watch.
|
|
461
|
+
* @param watchID Unique String value for region listener.Which is getting
|
|
462
|
+
* @param promise React native callback context.
|
|
463
|
+
*/
|
|
464
|
+
|
|
388
465
|
@ReactMethod
|
|
389
466
|
public void clearRegionsWatch(String watchID, Promise promise) {
|
|
390
467
|
try {
|
|
@@ -401,35 +478,39 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
401
478
|
}
|
|
402
479
|
}
|
|
403
480
|
|
|
481
|
+
/***
|
|
482
|
+
* Set radius of POI
|
|
483
|
+
* @param radius A string containing POI radius value in number,string,double format.
|
|
484
|
+
* @param promise React native callback context.
|
|
485
|
+
*/
|
|
404
486
|
@ReactMethod
|
|
405
|
-
public void setPoiRadius(String radius,Promise promise){
|
|
406
|
-
try{
|
|
407
|
-
if (isWoosmapInitialized()){
|
|
408
|
-
if (radius.isEmpty()){
|
|
487
|
+
public void setPoiRadius(String radius, Promise promise) {
|
|
488
|
+
try {
|
|
489
|
+
if (isWoosmapInitialized()) {
|
|
490
|
+
if (radius.isEmpty()) {
|
|
409
491
|
throw new Exception(WoosmapMessageAndKey.radiusEmptyMessage);
|
|
410
492
|
}
|
|
411
|
-
if(onlyContainsNumbers(radius)){
|
|
412
|
-
WoosmapSettings.poiRadius=Integer.parseInt(radius);
|
|
493
|
+
if (onlyContainsNumbers(radius)) {
|
|
494
|
+
WoosmapSettings.poiRadius = Integer.parseInt(radius);
|
|
413
495
|
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
414
|
-
}else if(onlyContainsDouble(radius)){
|
|
415
|
-
double d=Double.parseDouble(radius);
|
|
416
|
-
WoosmapSettings.poiRadius=(int) Math.round(d);
|
|
496
|
+
} else if (onlyContainsDouble(radius)) {
|
|
497
|
+
double d = Double.parseDouble(radius);
|
|
498
|
+
WoosmapSettings.poiRadius = (int) Math.round(d);
|
|
417
499
|
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
418
|
-
}else {
|
|
419
|
-
WoosmapSettings.poiRadiusNameFromResponse=radius;
|
|
500
|
+
} else {
|
|
501
|
+
WoosmapSettings.poiRadiusNameFromResponse = radius;
|
|
420
502
|
promise.resolve(WoosmapMessageAndKey.successMessage);
|
|
421
503
|
}
|
|
422
|
-
}else {
|
|
504
|
+
} else {
|
|
423
505
|
promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.woosmapNotInitialized);
|
|
424
506
|
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
promise.reject(WoosmapMessageAndKey.errorCode,ex.getMessage());
|
|
507
|
+
} catch (Exception ex) {
|
|
508
|
+
promise.reject(WoosmapMessageAndKey.errorCode, ex.getMessage());
|
|
428
509
|
}
|
|
429
510
|
}
|
|
430
511
|
|
|
431
|
-
|
|
432
|
-
*
|
|
512
|
+
/***
|
|
513
|
+
* Its check string is integer or not.
|
|
433
514
|
* @param text string for checking if it contains only number or not.
|
|
434
515
|
* @return true boolean value if string is only number else false.
|
|
435
516
|
*/
|
|
@@ -442,6 +523,11 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
442
523
|
}
|
|
443
524
|
}
|
|
444
525
|
|
|
526
|
+
/***
|
|
527
|
+
* Its check string is double or not.
|
|
528
|
+
* @param text String for checking if it contain double or not.
|
|
529
|
+
* @return true boolean value if string is double else false.
|
|
530
|
+
*/
|
|
445
531
|
private boolean onlyContainsDouble(String text) {
|
|
446
532
|
try {
|
|
447
533
|
Double.parseDouble(text);
|
|
@@ -450,6 +536,6 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
|
|
|
450
536
|
return false;
|
|
451
537
|
}
|
|
452
538
|
}
|
|
453
|
-
|
|
539
|
+
|
|
454
540
|
|
|
455
541
|
}
|
package/android/src/main/java/com/reactnativeplugingeofencing/WoosLocationReadyListener.java
CHANGED
|
@@ -10,6 +10,9 @@ import com.facebook.react.bridge.ReactContext;
|
|
|
10
10
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
11
11
|
import com.webgeoservices.woosmapgeofencing.Woosmap;
|
|
12
12
|
|
|
13
|
+
/***
|
|
14
|
+
* Implements Woosmap Location Ready callbacks
|
|
15
|
+
*/
|
|
13
16
|
public class WoosLocationReadyListener implements Woosmap.LocationReadyListener {
|
|
14
17
|
private ReactNativeHost reactNativeHost;
|
|
15
18
|
private Context context;
|
|
@@ -11,6 +11,9 @@ import com.webgeoservices.woosmapgeofencing.Woosmap;
|
|
|
11
11
|
import com.webgeoservices.woosmapgeofencing.database.Region;
|
|
12
12
|
import com.webgeoservices.woosmapgeofencing.database.RegionLog;
|
|
13
13
|
|
|
14
|
+
/***
|
|
15
|
+
* Implements Woosmap Region callbacks
|
|
16
|
+
*/
|
|
14
17
|
public class WoosRegionReadyListener implements Woosmap.RegionReadyListener,Woosmap.RegionLogReadyListener {
|
|
15
18
|
|
|
16
19
|
private ReactNativeHost reactNativeHost;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@woosmap/react-native-plugin-geofencing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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",
|