One of the more common challenges with the Situm SDK is using the correct configuration. For instance, you may want to use the GPS while positioning indoor if your building has good signal inside. Knowing what is the best configuration normally takes time and various iterations. Before the version 2.69.0 you had to recompile your app changing the configuration programmatically. If you already have users they have to update it and this process takes time. The Remote Configuration feature has changed this. You can use it to make changes instantly and for all of your users.
Changing the configuration #
You can change the Situm SDK Configuration using the Remote Configuration panel available on the “My organization” menu, as it is shown in image below.
Right now this panel only has positioning configuration but we are working to add more. When you are done with the changes you just have to save them and, if you have the SDK configured to use the Remote Configuration, the next time you start the positioning the changes will be applied.
Configuring the Android SDK #
To use this functionality you need to be at least in version 2.69.0. First, you need to set the usage of the Remote Configuration to true, like this:
//Initialize Situm SDK SitumSdk.init(this); //After initialising the SDK, it should be indicated to use remote config SitumSdk.configuration().setUseRemoteConfig(true);
This instruction only needs to be performed once, not every time you request location updates. This instruction is normally placed after init the SDK.
After that, when you want to start the positioning just use an empty LocationRequest.
SitumSdk.locationManager().requestLocationUpdates(new LocationRequest.Builder().build(), locationListener);
And that’s all. Now when you start the positioning the Situm SDK will check if the configuration has been updated and, if that’s the case, the new one will be used.
In the case that you don’t have connection when the SDK is downloading the configuration an error will be thrown. This is the same behaviour as when the download of other necessary information (like the buildings or the model of the building) fails.
Override the Remote Configuration #
You can override specific parameters of the configuration if you want. We normally recommend to just use the Remote Configuration but there may be some cases when you may want to override them. Imagine that you have more than one building in your account, you could use the Global Mode but the logic of the application requires the user to select between them, so in this case one option is to wait until the user selects the building and use the Building Mode.
LocationRequest.Builder locationRequestBuilder = new LocationRequest.Builder(); // Empty location request builder locationRequestBuilder.setBuildingIdentifier("1234"); // Local changes overriding remote configuration values SitumSdk.locationManager.requestLocationUpdates(locationRequestBuilder.build(), locationListener); // Start location with all remote configuration parameters but building identifier (specified programmatically)
When there is more than one configuration, the local always have priority over the Remote Configuration. Keep in mind that this is done for each individual parameter. In the previous example only the building identifier will use the Local Configuration, the other parameters are the ones in the Remote Configuration.
As you can see using the Remote Config feature is not mandatory and you can always override it programmatically; but please keep in mind that when you change parameters programmatically you loose some of the benefits of the feature, the most important one being able to deploy changes in configuration remote and instantly to all your customers base.
Get the Remote Configuration #
You can use the Situm SDK CommunicationManager to get the Remote Configuration by calling the method fetchRemoteConfig. This method will asynchronously get a RemoteConfig object which encapsulates all the objects that can be configured remotely using the dashboard. At this moment that is the case of only a LocationRequest, but is expected to grow in line with subsequent remote settings.
Configuring the iOS SDK #
To use this functionality you need to be at least in version 2.52.0. First, you need to set the usage of the Remote Configuration to true, like this:
SITServices.setUseRemoteConfig(true);
This instruction only needs to be performed once, not every time you request location updates. You can place it on the same file of other Situm configuration like credentials (for example, AppDelegate.swift).
After that, when you want to start the positioning just use an empty LocationRequest.
SITLocationManager.sharedInstance().requestLocationUpdates(nil)
And that’s all. Now when you start the positioning the Situm SDK will check if the configuration has been updated and, if that’s the case, the new one will be used.
In the case that you don’t have connection when the SDK is downloading the configuration an error will be thrown. This is the same behavior as when the download of other necessary information (like the buildings or the model of the building) fails.
Override the Remote Configuration #
Starting from version 2.52.3 os Situm SDK for iOS you can override specific parameters of the configuration if you want. We normally recommend to just use the Remote Configuration but there may be some cases when you may want to override them. Imagine that you have more than one building in your account, you could use the Global Mode but the logic of the application requires the user to select between them, so in this case one option is to wait until the user selects the building and use the Building Mode.
var locationRequest = LocationRequest() // Empty location request locationRequest.buildingId = "1234" // Local changes overriding remote configuration values SITLocationManager.sharedInstance().requestLocationUpdates(request) // Start location with all remote configuration parameters but building identifier (specified programmatically)
When there is more than one configuration, the local always have priority over the Remote Configuration. Keep in mind that this is done for each individual parameter. In the previous example only the building identifier will use the Local Configuration, the other parameters are the ones in the Remote Configuration.
As you can see using the Remote Config feature is not mandatory and you can always override it programmatically; but please keep in mind that when you change parameters programmatically you lose some of the benefits of the feature, the most important one being able to deploy changes in configuration remote and instantly to all your customers base.
Get the Remote Configuration #
You can use the Situm SDK CommunicationManager to get the Remote Configuration by calling the method fetchRemoteConfig. This method will asynchronously get a RemoteConfig object which encapsulates all the objects that can be configured remotely using the dashboard. At this moment that is the case of only a LocationRequest, but is expected to grow in line with subsequent remote settings.
Configuring the React Native plugin #
To use this functionality you need to be at least using the version 0.0.13 of the plugin. First, you need to set the usage of the Remote Configuration to true, like this:
SitumPlugin.setConfiguration({useRemoteConfig: true});
This instruction only needs to be performed once, not every time you request location updates. You can place it on the same file of the other Situm configuration like credentials. After that, you just need to start positioning as shown in this example.