02 – Initialization & common configurations

Before you perform any other operation with Situm SDK, you should initialize it and perform some common configurations. The entry point of Situm SDK is the SitumSdk class. This class allows you to do it.

Importing Situm SDK #

In order to learn how to import Situm SDK in your project, we recommend you to follow one the Quickstart guides: Android, iOS, Cordova, React Native.

SDK Initialization #

After the import step, you may initialize Situm SDK. This does not start positioning nor retrieves any resource from Situm Platform: it just allocates the required resources for the SDK to run.

The following snippet shows you how to do it in Android and React Native (we recommend to do this as soon as possible on your application’s lifecycle). In iOS & Cordova the SDK initializes itself after the import, so you don’t need to take further actions.

//MainActivity.java

import es.situm.sdk.SitumSdk;
...

public class MainActivity extends AppCompatActivity{
  
   @Override
    public void onCreate() {
        super.onCreate();
        ...
        
        SitumSdk.init(this);
    }
}
//App.js
import SitumPlugin from 'react-native-situm-plugin';
...

const App = () => {

  //Initialize Situm SDK
  SitumPlugin.initSitumSDK();

  ...
}
 
export default App;

Traversal configurations #

Credentials

You may provide you account credentials programmatically, as in the following example. We recommend to use the APIKEY way (see docs of the function for Android, iOS, Cordova and React Native).

//You may use your user email and API_KEY
SitumSdk.configuration().setApiKey("USER_EMAIL", "API_KEY");

//... or your user email and password (not recommended)
SitumSdk.configuration().setUserPass("USER_EMAIL", "PASSWORD");
//You may use your user email and API_KEY
SITServices.provideAPIKey("SET YOUR APIKEY HERE", forEmail: "SET YOUR EMAIL HERE")

//... or your user email and password (not recommended)
SITServices.provideUser("SET YOUR USER EMAIL HERE", password: "SET YOUR PASSWORD HERE")
#APIKEY based authentication
cordova.plugins.setApiKey("SITUM_EMAIL", "SITUM_API_KEY")

#User-Password based authentication
cordova.plugins.setUserPass("SITUM_EMAIL", "SITUM_PASS")
//You may use your user email and API_KEY
SitumPlugin.setApiKey("SITUM_EMAIL","SITUM_API_KEY")

//... or your user email and password
SitumPlugin.setUserPass("SITUM_EMAIL","SITUM_USER_PASSWORD")

Cache Max Age

As explained in this article, Situm SDK stores in the local cache of the smartphone the information it downloads from Situm Platform. Therefore, this information will be available in future requests without making network requests.  

You may configure how long this information will be stored in the smartphone’s cache (reference for Android, iOS, Cordova, ReactNative). The following snippet shows an example for Android and React Native, iOS and Cordova are similar (see reference above).

//Information will be cached for 1 day at most
SitumSdk.configuration().setCacheMaxAge(1, TimeUnit.DAYS);

//Information will be cached for 1 second at most
SitumSdk.configuration().setCacheMaxAge(1, TimeUnit.SECONDS);
//Information will be cached for 1 hour (3600 seconds) at most
SitumPlugin.setCacheMaxAge(1*60*60)

Caching this information may have a different effect depending on the Cache Strategy that you configure. See this article for details.

Connecting to your own Situm Platform instance (Native Android/iOS only)

In case you are running Situm Platform in your own premises or private cloud, you may want to configure the URL to which Situm SDK connects by using the SitumSdk.Configuration.setDashboardURL method (Android) or SITServices.setDashboardURL (iOS).

//Situm SDK will connect to https://your-own-server.com
SitumSdk.configuration().setDashboardURL("https://your-own-server.com");
//Situm SDK will connect to https://your-own-server.com
SITServices.setDashboardURL("https://your-own-server.com")

Sometimes, in development environments you may want to use self-signed certificates. These certificates will not have a valid Authority, therefore Situm SDK will not work. You may bypass this issue by calling the method SitumSdk.configuration().allowInvalidSSLCertificate (Android) or SITServices.setAllowsInvalidSSLCertificate (iOS) right after you initialize the Situm SDK.

//Situm SDK will trust the SSL certificate of the server (even if its Authority is not valid)
SitumSdk.init(this);
SitumSdk.configuration().allowInvalidSSLCertificate(true);
//Situm SDK will trust the SSL certificate of the server (even if its Authority is not valid)
SITServices.setAllowsInvalidSSLCertificate(true)

Please take into account that, by using this option, you may be exposing your app and network to unnecessary security risks. Use it at your own risk.

Situm SDK Managers #

Managers are utility classes that will allow you to access to all the functionalities and resources.   

ManagerDescriptionRelevant classes / methods Relevant docs
Location ManagerHandles all configurations & functionalities related to Indoor & Outdoor Positioning.Android: SitumSdk.LocationManager

iOS: SITLocationManager

Cordova: startPositioning, stopPositioning

ReactNative: startPositioning, stopPositioning
Positioning

Remote configuration

Battery efficiency

Background execution
Communication ManagerHandles all configurations & functionalities related to communications & cartographyAndroid: SitumSdk.CommunicationManager

iOS: SITCommunicationManager

Cordova: fetchBuildingInfo,
fetchBuildings, fetchFloorsFromBuilding, fetchGeofencesFromBuilding, fetchIndoorPOIsFromBuilding, fetchMapFromFloor, fetchOutdoorPOIsFromBuilding, fetchPoiCategories, fetchPoiCategoryIconNormal, fetchPoiCategoryIconSelected

ReactNative:
fetchBuildings
fetchFloorsFromBuilding
fetchIndoorPOIsFromBuilding
fetchOutdoorPOIsFromBuilding
fetchPoiCategories
fetchMapFromFloor
fetchPoiCategoryIconNormal
fetchPoiCategoryIconSelected
Cartography

Working offline with cached data
Directions Managerhandles all configurations & functionalities related to computing the shortest route from a point A to a point B.  Android: SitumSdk.DirectionsManager

iOS: SITCommunicationManager

Cordova: reguestDirections

ReactNative: requestDirections
Navigation Managerhandles all configurations & functionalities related to computing turn by turn directions & indications while the user moves along a route (previously computed using the DirectionsManager).  Android: SitumSdk.NavigationManager

iOS: SITNavigationManager

Cordova: requestNavigationUpdates, removeNavigationUpdates, updateNavigationWithLocation

ReactNative: requestNavigationUpdates, removeNavigationUpdates, updateNavigationWithLocation
Realtime ManagerHandles all configurations & functionalities related to retrieving the real-time geolocation of other users from Situm Platform.  Android: SitumSdk.RealTimeManager

iOS: SITRealTimeManager

Cordova: requestRealtimeUpdates, removeRealtimeUpdates

ReactNative: requestRealTimeUpdates, removeRealTimeUpdates

Subscribe to our newsletter

BASIC INFORMATION ON DATA PROTECTION

Data controller: SITUM TECHNOLOGIES, S.L.
Contact: Data controller: situm@situm.es
Responsible for protection: dpo@situm.es
Purpose and legal basis: To manage the sending of SITUM newsletters only with consent.
Legitimation: Express consent of the interested party.
Recipients: The data will not be passed on to third parties with the exception of legal obligations.
Retention period: As long as the interested party remains subscribed to the newsletter (a link to unsubscribe will be available in each newsletter sent by Situm).
Rights: The interested party may at any time revoke their consent, as well as exercise their rights of opposition, access, conservation, rectification, limitation, deletion of data and not be subject to a decision based only on automated data processing, by writing to SITUM at the addresses indicated.
Additional Information: You can consult additional and detailed information on Data Protection in our privacy policy.

Please, download your copy here

Thank you for downloading our whitepaper. Please do not hesitate to contact us if you would like to know more about how our solutions can help your business. Download whitepaper


Close window