@situm/cordova 3.3.14 → 3.4.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.
@@ -755,159 +755,140 @@ static JSONObject buildingInfoToJsonObject(BuildingInfo buildingInfo) throws JSO
755
755
  return locationBuilder.build();
756
756
  }
757
757
 
758
- JSONObject jsonoBuilding = args.getJSONObject(0);
759
- String sBuildingId;
760
- if (jsonoBuilding.get(SitumMapper.BUILDING_IDENTIFIER) instanceof String) {
761
- sBuildingId = jsonoBuilding.getString(SitumMapper.BUILDING_IDENTIFIER);
762
- } else {
763
- sBuildingId = String.format(Locale.getDefault(), "%d", jsonoBuilding.getInt(SitumMapper.BUILDING_IDENTIFIER));
758
+ JSONObject request = args.getJSONObject(0);
759
+ if (request.has(SitumMapper.BUILDING_IDENTIFIER)) {
760
+ String buildingIdentifier = String.valueOf(request.get(SitumMapper.BUILDING_IDENTIFIER));
761
+ locationBuilder.buildingIdentifier(buildingIdentifier);
762
+ Log.i(TAG, "buildingIdentifier: " + buildingIdentifier);
764
763
  }
765
764
 
766
- if (args.length() > 1) {
767
- JSONObject request = args.getJSONObject(1);
768
- if (request.has(SitumMapper.BUILDING_IDENTIFIER)) {
769
- String buildingIdentifier;
770
- if (request.get(SitumMapper.BUILDING_IDENTIFIER) instanceof String) {
771
- buildingIdentifier = request.getString(SitumMapper.BUILDING_IDENTIFIER);
772
- } else {
773
- buildingIdentifier = String.format(Locale.getDefault(), "%d", jsonoBuilding.getInt(SitumMapper.BUILDING_IDENTIFIER));
774
- }
775
-
776
- locationBuilder.buildingIdentifier(buildingIdentifier);
777
- Log.i(TAG, "buildingIdentifier: " + buildingIdentifier);
778
- }
779
-
780
- if (request.has(SitumMapper.INTERVAL)) {
781
- Integer interval = request.getInt(SitumMapper.INTERVAL);
782
- if (interval != null) {
783
- locationBuilder.interval(interval);
784
- Log.i(TAG, "interval: " + interval);
785
- }
786
- }
765
+ if (request.has(SitumMapper.INTERVAL)) {
766
+ Integer interval = request.getInt(SitumMapper.INTERVAL);
767
+ if (interval != null) {
768
+ locationBuilder.interval(interval);
769
+ Log.i(TAG, "interval: " + interval);
770
+ }
771
+ }
787
772
 
788
- if (request.has(SitumMapper.INDOOR_PROVIDER)) {
789
- String indoorProvider = request.getString(SitumMapper.INDOOR_PROVIDER);
790
- if (indoorProvider != null && !indoorProvider.isEmpty()) {
791
- if (indoorProvider.equals(LocationRequest.IndoorProvider.SUPPORT.name())) {
792
- locationBuilder.indoorProvider(LocationRequest.IndoorProvider.SUPPORT);
793
- } else {
794
- locationBuilder.indoorProvider(LocationRequest.IndoorProvider.INPHONE);
795
- }
796
- Log.i(TAG, "indoorProvider: " + indoorProvider);
797
- }
773
+ if (request.has(SitumMapper.INDOOR_PROVIDER)) {
774
+ String indoorProvider = request.getString(SitumMapper.INDOOR_PROVIDER);
775
+ if (indoorProvider != null && !indoorProvider.isEmpty()) {
776
+ if (indoorProvider.equals(LocationRequest.IndoorProvider.SUPPORT.name())) {
777
+ locationBuilder.indoorProvider(LocationRequest.IndoorProvider.SUPPORT);
778
+ } else {
779
+ locationBuilder.indoorProvider(LocationRequest.IndoorProvider.INPHONE);
798
780
  }
781
+ Log.i(TAG, "indoorProvider: " + indoorProvider);
782
+ }
783
+ }
799
784
 
800
- if (request.has(SitumMapper.USE_BLE)) {
801
- Boolean useBle = request.getBoolean(SitumMapper.USE_BLE);
802
- locationBuilder.useBle(useBle);
803
- Log.i(TAG, "useBle: " + useBle);
804
- }
785
+ if (request.has(SitumMapper.USE_BLE)) {
786
+ Boolean useBle = request.getBoolean(SitumMapper.USE_BLE);
787
+ locationBuilder.useBle(useBle);
788
+ Log.i(TAG, "useBle: " + useBle);
789
+ }
805
790
 
806
- if (request.has(SitumMapper.USE_WIFI)) {
807
- Boolean useWifi = request.getBoolean(SitumMapper.USE_WIFI);
808
- locationBuilder.useWifi(useWifi);
809
- Log.i(TAG, "useWifi: " + useWifi);
810
- }
791
+ if (request.has(SitumMapper.USE_WIFI)) {
792
+ Boolean useWifi = request.getBoolean(SitumMapper.USE_WIFI);
793
+ locationBuilder.useWifi(useWifi);
794
+ Log.i(TAG, "useWifi: " + useWifi);
795
+ }
811
796
 
812
- if (request.has(SitumMapper.USE_GPS)) {
813
- Boolean useGps = request.getBoolean(SitumMapper.USE_GPS);
814
- locationBuilder.useGps(useGps);
815
- Log.i(TAG, "useGps: " + useGps);
816
- }
797
+ if (request.has(SitumMapper.USE_GPS)) {
798
+ Boolean useGps = request.getBoolean(SitumMapper.USE_GPS);
799
+ locationBuilder.useGps(useGps);
800
+ Log.i(TAG, "useGps: " + useGps);
801
+ }
817
802
 
818
- if (request.has(SitumMapper.USE_BAROMETER)) {
819
- Boolean useBarometer = request.getBoolean(SitumMapper.USE_BAROMETER);
820
- locationBuilder.useBarometer(useBarometer);
821
- Log.i(TAG, "useBarometer: " + useBarometer);
822
- }
803
+ if (request.has(SitumMapper.USE_BAROMETER)) {
804
+ Boolean useBarometer = request.getBoolean(SitumMapper.USE_BAROMETER);
805
+ locationBuilder.useBarometer(useBarometer);
806
+ Log.i(TAG, "useBarometer: " + useBarometer);
807
+ }
823
808
 
824
- if (request.has(SitumMapper.AUTO_ENABLE_BLE)) {
825
- Boolean autoEnableBleDuringPositioning = request.getBoolean(SitumMapper.AUTO_ENABLE_BLE);
826
- locationBuilder.autoEnableBleDuringPositioning(autoEnableBleDuringPositioning);
827
- Log.i(TAG, "autoEnableBleDuringPositioning: " + autoEnableBleDuringPositioning);
828
- }
809
+ if (request.has(SitumMapper.AUTO_ENABLE_BLE)) {
810
+ Boolean autoEnableBleDuringPositioning = request.getBoolean(SitumMapper.AUTO_ENABLE_BLE);
811
+ locationBuilder.autoEnableBleDuringPositioning(autoEnableBleDuringPositioning);
812
+ Log.i(TAG, "autoEnableBleDuringPositioning: " + autoEnableBleDuringPositioning);
813
+ }
829
814
 
830
- if (request.has(SitumMapper.MOTION_MODE)) {
831
- String motionMode = request.getString(SitumMapper.MOTION_MODE);
832
- if (motionMode != null) {
833
- if (motionMode.equals(LocationRequest.MotionMode.BY_FOOT.name())) {
834
- locationBuilder.motionMode(LocationRequest.MotionMode.BY_FOOT);
835
- } else if (motionMode.equals(LocationRequest.MotionMode.BY_CAR.name())) {
836
- locationBuilder.motionMode(LocationRequest.MotionMode.BY_CAR);
837
- }
838
- Log.i(TAG, "motionMode: " + motionMode);
839
- }
815
+ if (request.has(SitumMapper.MOTION_MODE)) {
816
+ String motionMode = request.getString(SitumMapper.MOTION_MODE);
817
+ if (motionMode != null) {
818
+ if (motionMode.equals(LocationRequest.MotionMode.BY_FOOT.name())) {
819
+ locationBuilder.motionMode(LocationRequest.MotionMode.BY_FOOT);
820
+ } else if (motionMode.equals(LocationRequest.MotionMode.BY_CAR.name())) {
821
+ locationBuilder.motionMode(LocationRequest.MotionMode.BY_CAR);
840
822
  }
823
+ Log.i(TAG, "motionMode: " + motionMode);
824
+ }
825
+ }
841
826
 
842
- if (request.has(SitumMapper.USE_FOREGROUND_SERVICE)) {
843
- Boolean useForegroundService = request.getBoolean(SitumMapper.USE_FOREGROUND_SERVICE);
844
- locationBuilder.useForegroundService(useForegroundService);
845
- Log.i(TAG, "useForegroundService: " + useForegroundService);
846
- }
827
+ if (request.has(SitumMapper.USE_FOREGROUND_SERVICE)) {
828
+ Boolean useForegroundService = request.getBoolean(SitumMapper.USE_FOREGROUND_SERVICE);
829
+ locationBuilder.useForegroundService(useForegroundService);
830
+ Log.i(TAG, "useForegroundService: " + useForegroundService);
831
+ }
847
832
 
848
- if (request.has(SitumMapper.USE_DEAD_RECKONING)) {
849
- Boolean useDeadReckoning = request.getBoolean(SitumMapper.USE_DEAD_RECKONING);
850
- locationBuilder.useDeadReckoning(useDeadReckoning);
851
- Log.i(TAG, "useDeadReckoning: " + useDeadReckoning);
852
- }
833
+ if (request.has(SitumMapper.USE_DEAD_RECKONING)) {
834
+ Boolean useDeadReckoning = request.getBoolean(SitumMapper.USE_DEAD_RECKONING);
835
+ locationBuilder.useDeadReckoning(useDeadReckoning);
836
+ Log.i(TAG, "useDeadReckoning: " + useDeadReckoning);
837
+ }
853
838
 
854
- if (request.has(SitumMapper.OUTDOOR_LOCATION_OPTIONS)) {
855
- JSONObject outdoorLocationOptions = request.getJSONObject(SitumMapper.OUTDOOR_LOCATION_OPTIONS);
856
- if (outdoorLocationOptions != null) {
857
- locationBuilder.outdoorLocationOptions(buildOutdoorLocationOptions(outdoorLocationOptions));
858
- }
859
- }
839
+ if (request.has(SitumMapper.OUTDOOR_LOCATION_OPTIONS)) {
840
+ JSONObject outdoorLocationOptions = request.getJSONObject(SitumMapper.OUTDOOR_LOCATION_OPTIONS);
841
+ if (outdoorLocationOptions != null) {
842
+ locationBuilder.outdoorLocationOptions(buildOutdoorLocationOptions(outdoorLocationOptions));
843
+ }
844
+ }
860
845
 
861
- if (request.has(SitumMapper.BEACON_FILTERS)) {
862
- JSONArray beaconFilters = request.getJSONArray(SitumMapper.BEACON_FILTERS);
863
- List<BeaconFilter> filtersList = new ArrayList<BeaconFilter>();
864
- for (int i = 0; i < beaconFilters.length(); i++) {
865
- JSONObject beaconFilter = beaconFilters.getJSONObject(i);
866
- if (beaconFilter.has(SitumMapper.UUID)) {
867
- String uuid = beaconFilter.getString(SitumMapper.UUID);
868
- if (uuid != null && !uuid.isEmpty()) {
869
- BeaconFilter.Builder builder = new BeaconFilter.Builder().uuid(uuid);
870
- filtersList.add(builder.build());
871
- Log.i(TAG, "beaconFilter: " + uuid);
872
- }
873
- }
874
- }
875
-
876
- locationBuilder.addBeaconFilters(filtersList);
846
+ if (request.has(SitumMapper.BEACON_FILTERS)) {
847
+ JSONArray beaconFilters = request.getJSONArray(SitumMapper.BEACON_FILTERS);
848
+ List<BeaconFilter> filtersList = new ArrayList<BeaconFilter>();
849
+ for (int i = 0; i < beaconFilters.length(); i++) {
850
+ JSONObject beaconFilter = beaconFilters.getJSONObject(i);
851
+ if (beaconFilter.has(SitumMapper.UUID)) {
852
+ String uuid = beaconFilter.getString(SitumMapper.UUID);
853
+ if (uuid != null && !uuid.isEmpty()) {
854
+ BeaconFilter.Builder builder = new BeaconFilter.Builder().uuid(uuid);
855
+ filtersList.add(builder.build());
856
+ Log.i(TAG, "beaconFilter: " + uuid);
857
+ }
877
858
  }
859
+ }
860
+ locationBuilder.addBeaconFilters(filtersList);
861
+ }
878
862
 
879
- if (request.has(SitumMapper.SMALLEST_DISPLACEMENT)) {
880
- Float smallestDisplacement = new Float(request.getDouble(SitumMapper.SMALLEST_DISPLACEMENT));
881
- if (smallestDisplacement != null && smallestDisplacement > 0) {
882
- locationBuilder.smallestDisplacement(smallestDisplacement);
883
- Log.i(TAG, "smallestDisplacement: " + smallestDisplacement);
884
- }
885
- }
863
+ if (request.has(SitumMapper.SMALLEST_DISPLACEMENT)) {
864
+ Float smallestDisplacement = new Float(request.getDouble(SitumMapper.SMALLEST_DISPLACEMENT));
865
+ if (smallestDisplacement != null && smallestDisplacement > 0) {
866
+ locationBuilder.smallestDisplacement(smallestDisplacement);
867
+ Log.i(TAG, "smallestDisplacement: " + smallestDisplacement);
868
+ }
869
+ }
886
870
 
887
- if (request.has(SitumMapper.REALTIME_UPDATE_INTERVAL) &&
888
- request.get(SitumMapper.REALTIME_UPDATE_INTERVAL) instanceof String) {
889
- String realtimeUpdateInterval = request.getString(SitumMapper.REALTIME_UPDATE_INTERVAL);
890
- if (realtimeUpdateInterval != null) {
891
- if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.REALTIME.name())) {
892
- locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.REALTIME);
893
- } else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.FAST.name())) {
894
- locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.FAST);
895
- } else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.NORMAL.name())) {
896
- locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.NORMAL);
897
- } else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.SLOW.name())) {
898
- locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.SLOW);
899
- } else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.BATTERY_SAVER.name())) {
900
- locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.BATTERY_SAVER);
901
- }
902
- Log.i(TAG, "realtimeUpdateInterval: " + realtimeUpdateInterval);
903
- }
871
+ if (request.has(SitumMapper.REALTIME_UPDATE_INTERVAL) &&
872
+ request.get(SitumMapper.REALTIME_UPDATE_INTERVAL) instanceof String) {
873
+ String realtimeUpdateInterval = request.getString(SitumMapper.REALTIME_UPDATE_INTERVAL);
874
+ if (realtimeUpdateInterval != null) {
875
+ if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.REALTIME.name())) {
876
+ locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.REALTIME);
877
+ } else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.FAST.name())) {
878
+ locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.FAST);
879
+ } else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.NORMAL.name())) {
880
+ locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.NORMAL);
881
+ } else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.SLOW.name())) {
882
+ locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.SLOW);
883
+ } else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.BATTERY_SAVER.name())) {
884
+ locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.BATTERY_SAVER);
904
885
  }
905
- } else {
906
- locationBuilder.buildingIdentifier(sBuildingId);
886
+ Log.i(TAG, "realtimeUpdateInterval: " + realtimeUpdateInterval);
887
+ }
907
888
  }
908
889
 
909
890
  return locationBuilder.build();
910
- }
891
+ }
911
892
 
912
893
  static OutdoorLocationOptions buildOutdoorLocationOptions(JSONObject outdoorLocationOptions) throws JSONException{
913
894
  OutdoorLocationOptions.Builder optionsBuilder = new OutdoorLocationOptions.Builder();
@@ -471,18 +471,6 @@ public class SitumMapperTest {
471
471
  }
472
472
  }
473
473
 
474
- @Test
475
- public void indicationJSONObjectTest() {
476
- try {
477
- Indication indication = indicationCreator.createIndication();
478
- JSONObject indicationJSONObject = SitumMapper.indicationToJsonObject(indication);
479
- JSONObject indication1 = indicationCreator.getIndication1();
480
- testIndication(indicationJSONObject, indication1);
481
- } catch (JSONException e) {
482
- System.err.println(e.getMessage());
483
- }
484
- }
485
-
486
474
  @Test
487
475
  public void locationTest1() {
488
476
  try {
@@ -837,34 +825,6 @@ public class SitumMapperTest {
837
825
  }
838
826
  }
839
827
 
840
- @Test
841
- public void routeStepJSONObjectTest(){
842
- try{
843
- RouteStep routeStepWithCoordinate = routeStepCreator.createRouteStepWithCoordinate();
844
- JSONObject routeStepWithCoordinateJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithCoordinate);
845
- JSONObject routeStep1 = routeStepCreator.getRouteStep1();
846
- testRouteStep(routeStepWithCoordinateJSONObject, routeStep1);
847
- RouteStep routeStepWithCoordinateAndBuildingId = routeStepCreator.createRouteStepWithCoordinateAndBuildingId();
848
- JSONObject routeStepWithCoordinateAndBuildingIdJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithCoordinateAndBuildingId);
849
- JSONObject routeStep2 = routeStepCreator.getRouteStep2();
850
- testRouteStep(routeStepWithCoordinateAndBuildingIdJSONObject, routeStep2);
851
- RouteStep routeStepWithCoordinateBuildingIdAndFloor = routeStepCreator.createRouteStepWithCoordinateBuildingIdAndFloor();
852
- JSONObject routeStepWithCoordinateBuildingIdAndFloorJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithCoordinateBuildingIdAndFloor);
853
- JSONObject routeStep3 = routeStepCreator.getRouteStep3();
854
- testRouteStep(routeStepWithCoordinateBuildingIdAndFloorJSONObject, routeStep3);
855
- RouteStep routeStepWithBuildingWithAngleFromDegree = routeStepCreator.createRouteStepWithBuildingWithAngleFromDegree();
856
- JSONObject routeStepWithBuildingWithAngleFromDegreeJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithBuildingWithAngleFromDegree);
857
- JSONObject routeStep4 = routeStepCreator.getRouteStep4();
858
- testRouteStep(routeStepWithBuildingWithAngleFromDegreeJSONObject, routeStep4);
859
- RouteStep routeStepWithBuildingWithAngleFromRadians = routeStepCreator.createRouteStepWithBuildingWithAngleFromRadians();
860
- JSONObject routeStepWithBuildingWithAngleFromRadiansJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithBuildingWithAngleFromRadians);
861
- JSONObject routeStep5 = routeStepCreator.getRouteStep5();
862
- testRouteStep(routeStepWithBuildingWithAngleFromRadiansJSONObject, routeStep5);
863
- }catch(JSONException e){
864
- System.err.println(e.getMessage());
865
- }
866
- }
867
-
868
828
  @Test
869
829
  public void pointTest1() {
870
830
  try{
@@ -11,7 +11,6 @@ allprojects {
11
11
  }
12
12
 
13
13
  dependencies {
14
- implementation 'com.google.android.gms:play-services-maps:16.0.0'
15
14
  implementation 'com.google.android.gms:play-services-location:16.0.0'
16
15
  implementation('es.situm:situm-sdk:3.11.2@aar') {
17
16
  transitive = true
@@ -234,9 +234,7 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
234
234
  return jo;
235
235
  }
236
236
 
237
-
238
237
  - (SITLocationRequest *) jsonObjectToLocationRequest: (NSArray *) json {
239
- NSDictionary *buildingJO;
240
238
  NSNumber *useDeadReckoning = nil;
241
239
  NSNumber *useGps = nil;
242
240
  NSString *buildingId;
@@ -245,11 +243,10 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
245
243
  NSNumber *smallestDisplacement = nil;
246
244
  NSNumber *useBarometer = nil;
247
245
  SITRealtimeUpdateInterval realtimeInterval = 0;
248
-
246
+
249
247
  // Check use of remote configuration
250
248
  if ([json isKindOfClass:[NSDictionary class]]) {
251
249
  NSDictionary *params = (NSDictionary *)json;
252
-
253
250
  if ([params allKeys].count == 0) {
254
251
  return nil;
255
252
  }
@@ -258,38 +255,17 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
258
255
  return nil;
259
256
  }
260
257
  }
261
-
262
- //The following if-else is necessary in order to mantain compatibility
263
- //with the startPositioning[building] method.
264
- //If params is an array, then it contains both a building and a locationRequest
265
- //If params is a dictionary, then it should only contain a building
266
-
267
- if ([json isKindOfClass:[NSArray class]]) {
268
- buildingJO = (NSDictionary*)[json objectAtIndex:0];
269
- if (json.count > 1) {
270
- NSDictionary *requestJO = (NSDictionary*)[json objectAtIndex:1];
271
- buildingId = [NSString stringWithFormat:@"%@", requestJO[@"buildingIdentifier"]];
272
- useDeadReckoning = [requestJO objectForKey: @"useDeadReckoning"];
273
- useGps = [requestJO objectForKey: @"useGps"];
274
- realtimeUpdateInterval = requestJO[@"realtimeUpdateInterval"];
275
- interval = requestJO[@"interval"];
276
- smallestDisplacement = requestJO[@"smallestDisplacement"];
277
- useBarometer = [requestJO objectForKey: @"useBarometer"];
278
- }
279
- } else {
280
- buildingJO = (NSDictionary*)json[0];
281
- }
282
-
283
- if (buildingId == nil) {
284
- buildingId = [buildingJO valueForKey:@"identifier"];
285
- }
286
-
287
- if (buildingId == nil) {
288
- buildingId = [NSString stringWithFormat:@"%@", [buildingJO valueForKey:@"buildingIdentifier"]];
289
- }
290
-
258
+
259
+ NSDictionary *requestJO = (NSDictionary*)[json objectAtIndex:0];
260
+ buildingId = [NSString stringWithFormat:@"%@", requestJO[@"buildingIdentifier"]];
261
+ useDeadReckoning = [requestJO objectForKey: @"useDeadReckoning"];
262
+ useGps = [requestJO objectForKey: @"useGps"];
263
+ realtimeUpdateInterval = requestJO[@"realtimeUpdateInterval"];
264
+ interval = requestJO[@"interval"];
265
+ smallestDisplacement = requestJO[@"smallestDisplacement"];
266
+ useBarometer = [requestJO objectForKey: @"useBarometer"];
267
+
291
268
  if (realtimeUpdateInterval != nil && [realtimeUpdateInterval isKindOfClass: [NSString class]]) {
292
-
293
269
  if ([realtimeUpdateInterval isEqualToString:@"REALTIME"]) {
294
270
  realtimeInterval = kSITUpdateIntervalRealtime;
295
271
  } else if ([realtimeUpdateInterval isEqualToString:@"FAST"]) {
@@ -302,18 +278,19 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
302
278
  realtimeInterval = kSITUpdateIntervalBatterySaver;
303
279
  }
304
280
  }
305
-
281
+
306
282
  SITLocationRequest *locationRequest = [[SITLocationRequest alloc] initWithBuildingId:buildingId];
283
+
307
284
  if (useDeadReckoning != nil) {
308
285
  [locationRequest setUseDeadReckoning:[useDeadReckoning boolValue]];
309
-
310
286
  }
287
+
311
288
  if(useGps != nil) {
312
289
  [locationRequest setUseGps:[useGps boolValue]];
313
290
  }
314
-
291
+
315
292
  if(interval != nil) {
316
- [locationRequest setInterval:[interval intValue]];
293
+ [locationRequest setInterval:[interval intValue]];
317
294
  }
318
295
 
319
296
  if (smallestDisplacement != nil) {
@@ -321,11 +298,11 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
321
298
  }
322
299
 
323
300
  if(useBarometer != nil) {
324
- [locationRequest setUseBarometer: [useBarometer boolValue]];
301
+ [locationRequest setUseBarometer: [useBarometer boolValue]];
325
302
  }
326
303
 
327
304
  if (realtimeInterval != 0) {
328
- [locationRequest setUpdateInterval:realtimeInterval];
305
+ [locationRequest setRealtimeUpdateInterval:realtimeInterval];
329
306
  }
330
307
  return locationRequest;
331
308
  }
@@ -462,9 +462,10 @@ static NSString *DEFAULT_SITUM_LOG = @"SitumSDK >>: ";
462
462
  }
463
463
 
464
464
  - (void)stopPositioning:(CDVInvokedUrlCommand *)command {
465
- locationCallbackId = command.callbackId;
466
465
  [[SITLocationManager sharedInstance] removeUpdates];
467
466
  [[SITLocationManager sharedInstance] removeDelegate:self];
467
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
468
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
468
469
  }
469
470
 
470
471
  - (void)onEnterGeofences:(CDVInvokedUrlCommand *)command {
@@ -581,7 +582,7 @@ static NSString *DEFAULT_SITUM_LOG = @"SitumSDK >>: ";
581
582
 
582
583
  CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Navigation updated"];
583
584
  pluginResult.keepCallback = [NSNumber numberWithBool:true];
584
- [self.commandDelegate sendPluginResult:pluginResult callbackId:locationCallbackId];
585
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
585
586
  }
586
587
 
587
588
  - (void) removeNavigationUpdates:(CDVInvokedUrlCommand *)command {
@@ -592,7 +593,7 @@ static NSString *DEFAULT_SITUM_LOG = @"SitumSDK >>: ";
592
593
  NSMutableDictionary *obj = [[NSMutableDictionary alloc] init];
593
594
  [[SITCommunicationManager sharedManager] clearCache];
594
595
  CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:obj.copy];
595
- [self.commandDelegate sendPluginResult:pluginResult callbackId:locationCallbackId];
596
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
596
597
  }
597
598
 
598
599
  // Realtime
@@ -553,7 +553,7 @@ module.exports = SitumConversionArea
553
553
 
554
554
  /**
555
555
  * @name
556
- * LocationOptions
556
+ * LocationRequest
557
557
  * @description
558
558
  * A data object that contains parameters for the location service, LocationManager.
559
559
  * @property {number} buildingIdentifier - Identifier of the building on which the positioning will be started
@@ -567,13 +567,12 @@ module.exports = SitumConversionArea
567
567
  * @property {boolean} useForegroundService - Defines whether or not to activate the {@link http://developers.situm.es/pages/android/using_situm_sdk_background.html foreground service}
568
568
  * @property {boolean} useDeadReckoning - Defines whether ot not to use dead reckoning to get fast position updates using only the inertial sensors, between the server position updates.
569
569
  * @property {OutdoorLocationOptions} outdoorLocationOptions - Outdoor location options. Only used in an indoor/outdoor request
570
- * @property {BeaconFilter[]} beaconFilters - Beacon filters to be handled during scan time, otherwise only Situm beacons will be scanned. Can be invoked multiple times to add as much beacon filters as you want @deprecated The SitumSDK now does it automatically
570
+ * @property {BeaconFilter[]} beaconFilters - Beacon filters to be handled during scan time, otherwise only Situm beacons will be scanned. Can be invoked multiple times to add as much beacon filters as you want.
571
571
  * @property {number} smallestDisplacement - Default smallest displacement to nofiy location updates
572
572
  * @property {string} realtimeUpdateInterval - Default interval to send locations to the Realtime. Possible values are REALTIME, FAST, NORMAL, SLOW and BATTERY_SAVER
573
573
  * @property {boolean} autoEnableBleDuringPositioning - Set if the BLE should be re-enabled during positioning if the ble is used. Android only
574
574
  */
575
-
576
- var LocationOptions = {
575
+ var LocationRequest = {
577
576
  buildingIdentifier,
578
577
  interval,
579
578
  indoorProvider,
@@ -587,27 +586,22 @@ var LocationOptions = {
587
586
  outdoorLocationOptions,
588
587
  beaconFilters,
589
588
  smallestDisplacement,
590
- realtimeUpdateInterval
591
- }
589
+ realtimeUpdateInterval,
590
+ autoEnableBleDuringPositioning,
591
+ };
592
592
 
593
- module.exports = LocationOptions
593
+ module.exports = LocationRequest;
594
594
 
595
595
  /**
596
596
  * @name
597
- * LocationRequest
597
+ * LocationOptions
598
598
  * @description
599
599
  * A data object that contains parameters for the location service, LocationManager.
600
- * @type {array}
601
- * @property {Building} building 0 - Building on which the positioning will be started
602
- * @property {LocationOptions} locationOptions 1 - Location options.
600
+ * @deprecated Use {@link LocationRequest} instead.
603
601
  */
602
+ var LocationOptions = LocationRequest;
604
603
 
605
- var LocationRequest = {
606
- building,
607
- locationOptions
608
- }
609
-
610
- module.exports = LocationRequest
604
+ module.exports = LocationOptions
611
605
 
612
606
  /**
613
607
  * @name
@@ -0,0 +1,36 @@
1
+ module.exports = {
2
+ /**
3
+ * Takes the different input types from requestLocationUpdates (and startPositioning) and standarizes the response.
4
+ * This function aims to maintain compatibility with older versions of this plugin.
5
+ * @param {any} input
6
+ * @returns A single item array containing the LocationRequest, ready to be sent to native platforms.
7
+ */
8
+ standarizeRequest: function(input) {
9
+ let response;
10
+ if (!input) {
11
+ // If it is null or undefined, pass an empty location request.
12
+ response = {};
13
+ } else if (Array.isArray(input) && input.length > 0) {
14
+ // If it is an array:
15
+ if (input.every(item => typeof item === 'object')){
16
+ // It may contain objects (legacy API: Building + LocationOptions).
17
+ // Then merge all of them into a single object.
18
+ response = Object.assign({}, ...input);
19
+ } else if (typeof input[0] === 'string' || typeof input[0] === 'number') {
20
+ // It may contain a building identifier + a set of LocationOptions.
21
+ // Assign the building identifier and merge.
22
+ input[0] = {buildingIdentifier: input[0]};
23
+ response = Object.assign({}, ...input);
24
+ }
25
+ } else if (typeof input === 'string' || typeof input === 'number') {
26
+ // The input itself may be a single building identifier.
27
+ response = {buildingIdentifier: input};
28
+ } else {
29
+ // If the input is an object (or any other case), return the object itself. Delegate the
30
+ // error checks to the platform's mapper.
31
+ response = input;
32
+ }
33
+ // Cordova platforms wait for a JSONArray:
34
+ return [response];
35
+ }
36
+ }