@woosmap/react-native-plugin-geofencing 0.2.3 → 0.2.4-beta.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.
@@ -107,6 +107,10 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
107
107
  this.woosmap.createWoosmapNotifChannel();
108
108
  }
109
109
  this.woosmap.onResume();
110
+ //Add region listener
111
+ regionReadyListener = new WoosRegionReadyListener(getReactApplicationContext());
112
+ woosmap.setRegionLogReadyListener(regionReadyListener);
113
+ woosmap.setRegionReadyListener(regionReadyListener);
110
114
  if (!trackingProfile.isEmpty()) {
111
115
  woosmap.startTracking(trackingProfile);
112
116
  }
@@ -449,10 +453,8 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
449
453
  public void watchRegions(String watchID, Promise promise) {
450
454
  try {
451
455
  if (isWoosmapInitialized()) {
452
- if (regionReadyListener == null) {
453
- regionReadyListener = new WoosRegionReadyListener(reactContext);
454
- woosmap.setRegionLogReadyListener(regionReadyListener);
455
- woosmap.setRegionReadyListener(regionReadyListener);
456
+ if (!regionReadyListener.getIsRegionWatchEnabled()) {
457
+ regionReadyListener.setIsRegionWatchEnabled(true);
456
458
  promise.resolve(watchID);
457
459
  } else {
458
460
  promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.regionWatchAlreadyStarted);
@@ -474,10 +476,8 @@ public class PluginGeofencingModule extends ReactContextBaseJavaModule implement
474
476
  @ReactMethod
475
477
  public void clearRegionsWatch(String watchID, Promise promise) {
476
478
  try {
477
- if (regionReadyListener != null) {
478
- woosmap.setRegionLogReadyListener(null);
479
- woosmap.setRegionReadyListener(null);
480
- regionReadyListener = null;
479
+ if (regionReadyListener.getIsRegionWatchEnabled()) {
480
+ regionReadyListener.setIsRegionWatchEnabled(false);
481
481
  promise.resolve(watchID);
482
482
  } else {
483
483
  promise.reject(WoosmapMessageAndKey.errorCode, WoosmapMessageAndKey.regionWatchNotStarted);
@@ -20,9 +20,18 @@ public class WoosRegionReadyListener implements Woosmap.RegionReadyListener,Woos
20
20
 
21
21
  private ReactNativeHost reactNativeHost;
22
22
  private Context context;
23
+ private boolean isRegionWatchEnabled = false;
23
24
  public WoosRegionReadyListener(Context context){
24
25
  this.context=context;
25
26
  }
27
+
28
+ public boolean getIsRegionWatchEnabled(){
29
+ return isRegionWatchEnabled;
30
+ }
31
+
32
+ public void setIsRegionWatchEnabled(boolean value){
33
+ isRegionWatchEnabled = value;
34
+ }
26
35
  private void sendEvent(final String eventName, final Object data) {
27
36
  final ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
28
37
  ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
@@ -33,15 +42,17 @@ public class WoosRegionReadyListener implements Woosmap.RegionReadyListener,Woos
33
42
  @Override
34
43
  public void RegionLogReadyCallback(RegionLog regionLog) {
35
44
  try {
36
- ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
37
45
  if (WoosmapUtil.getEnableAishipConnector(context)){
38
46
  //Do the airship push here.
39
47
  AirshipPushHelper airshipPushHelper = new AirshipPushHelper(context);
40
48
  HashMap<String, Object> data = airshipPushHelper.getAirshipData(regionLog);
41
49
  airshipPushHelper.pushDataToCloud(data);
42
50
  }
43
- reactNativeHost = reactApplication.getReactNativeHost();
44
- sendEvent(WoosmapMessageAndKey.regionSuccessCallbackName, WoosmapUtil.getRegionWritableMap(regionLog));
51
+ if (isRegionWatchEnabled){
52
+ ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
53
+ reactNativeHost = reactApplication.getReactNativeHost();
54
+ sendEvent(WoosmapMessageAndKey.regionSuccessCallbackName, WoosmapUtil.getRegionWritableMap(regionLog));
55
+ }
45
56
  }catch (Exception ex){
46
57
  sendEvent(WoosmapMessageAndKey.regionErrorCallbackName, ex.getMessage());
47
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woosmap/react-native-plugin-geofencing",
3
- "version": "0.2.3",
3
+ "version": "0.2.4-beta.0",
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",
@@ -141,4 +141,4 @@
141
141
  "dependencies": {
142
142
  "react-native-uuid": "^2.0.1"
143
143
  }
144
- }
144
+ }
package/CHANGELOG.md DELETED
@@ -1,8 +0,0 @@
1
- ### Latest
2
- * Added a new field named `eventName` in the region callback
3
-
4
- ### 0.1.9
5
- * #56 region create event triggers other than region log event removed in android. by @dippatra in https://github.com/Woosmap/geofencing-react-native-plugin/pull/58
6
-
7
- ### 0.1.8
8
- * #53 POI identifier (idStore) is not returned in the Region object issue by @dippatra in https://github.com/Woosmap/geofencing-react-native-plugin/pull/54