03 – A basic Cordova app

Situm SDK can be used to build Wayfinding and Tracking applications, and dozens of use cases within those realms. However, there is a common pattern or skeleton that most Situm based applications will follow. In this Section, we provide an Android step-by-step guide to build your first Situm app based on this pattern.

Pre-requisites: Configuring Cordova #

First, you need to configure Cordova by following this tutorial. Then, make sure you comply with the requirements for Android, iOS and Cocoapods.

Installing the plugin #

We assume that you have already created a Cordova based app with your favourite framework. Then, you may integrate the plugin in your project in different ways.

Please note that we are using Cocoapods in order to manage iOS dependencies, which means you might need to run pod repo update when trying to compile your app after updating our plugin.

Alternative 1: With Cordova CLI from npm or Github #

You may install the plugin using Cordova CLI

#From npm
cordova plugin add situm-cordova-plugin-official

#From Github
cordova plugin add https://github.com/situmtech/situm-cordova-plugin.git

Alternative 2: Automatic installation using config.xml #

You may also define the plugin in your config.xml

<plugin name="situm-cordova-plugin-official" source="npm">
</plugin>

Using the plugin #

There are many things you can do with the Situm SDK Cordova Plugin. In this guide, we will show you how to do the basic stuff. For more info, take a look at our Cordova sample app and at the Plugin Method Reference.

Initializing the plugin #

Situm Cordova Plugin initializes automatically. When the “device ready” event is fired, the Situm Cordova Plugin will be autowired in the variable cordova.plugins.Situm.

Setting the credentials #

Then, you can setup your credentials. If you choose APIKEY based authentication, you may retrieve your APIKEY from your Profile.

#APIKEY based authentication
cordova.plugins.setApiKey("SITUM_EMAIL", "SITUM_API_KEY")

#User-Password based authentication
cordova.plugins.setUserPass("SITUM_EMAIL", "SITUM_PASS")

Starting positioning #

Then, you may start positioning by using the cordova.plugins.startPositioning method. You may pass a locationOptions object in order to modify the default positioning parameters.

cordova.plugins.Situm.startPositioning(locationOptions, (res: any) => {
   //Receives position as a result ...
   let position = res 
}, (err: any) => {
   // ... or it may also produce an error if positioning can not be started
   console.log('Error when starting positioning.', err);
});

Running the application #

Assuming you use ionic (you may use other frameworks as well):

#Android
ionic cordova run android

#iOS
ionic cordova run ios

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