situm-cordova-plugin-official v1.20.34
Situm Cordova Plugin
Situm Cordova Plugin is a set of utilities that allow any developer to build Cordova location based apps using Situm's indoor positioning system. Among many other capabilities, apps developed with Situm Cordova Plugin will be able to:
- Obtain information related to buildings where Situm's positioning system is already configured: floorplans, points of interest, geotriggered events, etc.
- Retrieve the location of the smartphone inside these buildings (position, orientation, and floor where the smartphone is).
- Compute a route from a point A (e.g. where the smartphone is) to a point B (e.g. any point of interest within the building).
- Trigger notifications when the user enters a certain area.
Table of contents
- Getting started
- Versioning
- Submitting contributions
- License
- Documentation
- Development
- More information
- Support information
Getting started
- Set up your Situm account following these steps.
- Configure this plugin in your project.
- API Reference will help you use a particular class or method.
Versioning
Please refer to CHANGELOG.md for a list of notables changes for each version of the plugin.
You can also see the tags on this repository.
Submitting contributions
You will need to sign a Contributor License Agreement (CLA) before making a submission. Learn more here.
License
Situm-Cordova-Plugin is licensed under MIT License. See LICENSE.txt file for further details.
Documentation
- General documentation. You can find in our documentation site all the information you need to configure this plugin in your project and get it up and running in no time.
- API reference. Check out the plugin reference and learn how to use a particular class or method.
- Examples. In this repo you can find a sample app implementing this plugin. Take a look at how the examples are implemented, so you can figure out how to adapt it to your project.
- Cordova Wayfinding plugin. If you are looking for a wayfinding solution using Cordova, check out this repo.
Methods
NOTE: This plugin is currently under development. There may be method not implemented yet. Also there may be some API changes as development progresses.
- setApiKey
Log in into your Situm Account. This key is generated in Situm Dashboard. Return true if apiKey was set successfully, otherwise false
cordova.plugins.Situm.setApiKey("SITUM_EMAIL", "SITUM_API_KEY");
- setUserPass
Provides user's email and password. Return true if apiKey was set successfully, otherwise false
cordova.plugins.Situm.setUserPass("SITUM_EMAIL", "SITUM_USER_PASS");
- setRemoteConfig
Set the remote configuration state which allows to use the configuration (location request) stored on the web to find the location of the user.
cordova.plugins.Situm.setUseRemoteConfig(true);
- setCacheMaxAge
Sets the maximum age of a cached response in seconds.
cordova.plugins.Situm.setCacheMaxAge(1*60*60) // 1 hour
- startPositioning
Starts the positioning system. In the success callback it can return:
locationOptions = {
buildingIdentifier = "BUILDING_ID"
};
cordova.plugins.Situm.startPositioning(locationOptions, (res: any) => {
if (res && res.statusName) {
// Returns location status
}
if (res && res.position) {
// Return location object
}
}, (err: any) => {
//Return error as an string.If this happens the positioning is stopped
});
- stopPositioning
Stop the positioning system on current active listener.
cordova.plugins.Situm.stopPositioning()
- fetchBuildings
Download all the buildings for the current user.Returns an array of buildings
cordova.plugins.Situm.fetchBuildings((res: any) => {
// Return an array of buildings
}, (err: any) => {
// returns error string
});
- fetchBuildingInfo
Download the information (floors, pois, ...) of a building
cordova.plugins.Situm.fetchBuildingInfo(building,(res: any) => {
// Return the buildingInfo
}, (err: any) => {
// returns error string
});
- fetchFloorsFromBuilding
Download all the floors of a building.
cordova.plugins.Situm.fetchFloorsFromBuilding(building,(res: any) => {
// Return an array of floors
}, (err: any) => {
// returns error string
});
- fetchIndoorPOIsFromBuilding
Download the indoor POIs of a building.
cordova.plugins.Situm.fetchIndoorPOIsFromBuilding(building,(res: any) => {
// Return an array of indoor POIs
}, (err: any) => {
// returns error string
});
- fetchOutdoorPOIsFromBuilding
Download the outdoor POIs of a building.
cordova.plugins.Situm.fetchOutdoorPOIsFromBuilding(building,(res: any) => {
// Return an array of outdoor POIs
}, (err: any) => {
// returns error string
});
- fetchEventsFromBuilding
Download the events of a building.
cordova.plugins.Situm.fetchEventsFromBuilding(building,(res: any) => {
// Return an array of events
}, (err: any) => {
// returns error string
});
- fetchPoiCategories
Get all POI Categories, download and cache their icons asynchronously.
cordova.plugins.Situm.fetchPoiCategories((res: any) => {
// Return an array of POI categories
}, (err: any) => {
// returns error string
});
- fetchMapFromFloor
Download the map image of a floor.
cordova.plugins.Situm.fetchMapFromFloor(floor, (res: any) => {
// Return an image as an string encoded in Base64
}, (err: any) => {
// returns error string
});
- fetchPoiCategoryIconNormal
Get the normal category icon for a POICategory.
cordova.plugins.Situm.fetchPoiCategoryIconNormal(category, (res: any) => {
// Return an image as an string encoded in Base64
}, (err: any) => {
// returns error string
});
- fetchPoiCategoryIconSelected
Get the selected category icon for a POICategory.
cordova.plugins.Situm.fetchPoiCategoryIconSelected(category, (res: any) => {
// Return an image as an string encoded in Base64
}, (err: any) => {
// returns error string
});
- fetchGeofencesFromBuilding
Get all geofences from the building.
cordova.plugins.Situm.fetchGeofencesFromBuilding(building, (res: any) => {
// Return an array of geofences
}, (err: any) => {
// returns error string
});
- invalidateCache
Invalidate all the resources in the cache.
cordova.plugins.Situm.invalidateCache();
- requestDirections
Calculates a route between two points. This route is the one that will be used when you call requestNavigationUpdates. If this method is called multiple times the last Route will be used. You can change the options to generate the Route with DirectionOptions Returns a Route
directionRequest = [
building, // Building in which you're positioning
from, // Point where you want to start the route. You can pass a Point or a Location
to, // Point where you want to finish the route
{} // Options to generate the route
]
cordova.plugins.Situm.requestDirections(
directionsRequest, (route: any) => {
//Return a Route
}, (err: any) => {
// returns error string
});
- requestNavigationUpdates
Necessary step to request progress. Alone this method does not provide progress object. You must feed navigation API with location, as indicated on updateNavigationWithLocation section. When you start feeding locations you can receive NavigationProgress or other of the results described below
// Navigation request with example values
navigationRequest = [
distanceToGoalThreshold = 10,
distanceToFloorChangeThreshold = 5
]
cordova.plugins.Situm.requestNavigationUpdates(
navigationRequest,
(navigation: any) => {
/**
* This callback can return four different things:
* 1. A message notifying about the success starting the navigation
* 2. A json with the NavigationProgress. The Json will also have a field "type" with the value "progress" so you can know when this happens.
* 3. A json with the field "type" and the value "destinationReached". This happens when the navigation finish because you reached the end.
* 4. A json with the field "type" and the value "userOutsideRoute". This happens when the user deviate from the route. You can notify them so they return to the correct path.
*/
},
(error: any) => {
//returns error string
});
- updateNavigationWithLocation
Usually, position variable should be one of the locations provided by the system on the startPositioning function.
cordova.plugins.Situm.updateNavigationWithLocation(currentLocation)
- removeNavigationUpdates
When you are no longer interested on Navigation Updates you should call this method to remove internal allocated resources.
cordova.plugins.Situm.removeNavigationUpdates();
- requestRealTimeUpdates
Emits the real time location of devices
const request = {
building: building, //Building in which you want to be notified
pollTime: 3000, // time in milliseconds
}
cordova.plugins.Situm.SitumPlugin.requestRealTimeUpdates(
request,
(locations: any) => {
// returns the locations of the other devices in real time
},
(error: any) => {
// returns error string
}
);
- removeRealTimeUpdates
When you are no longer interested on realtime location Updates you should call this method to remove internal allocated resources.
cordova.plugins.Situm.removeRealTimeUpdates();
- onEnterGeofences
Get notified about users entering geofences. Take into account:
- This method must be called before the positioning is started.
- Positioning geofences (with
trainer_metadata
custom field configured in the dashboard) won't be notified. - This callback works only with indoor locations. Any outdoor location will produce a call to onExitedGeofences with the last positioned geofences as argument.
- This callback will return an array of geofences
cordova.plugins.Situm.onEnterGeofences((geofences: any) => {
// Returns an array of geofences
// e.g. [{"polygonPoints": [], "customFields": {}, "updatedAt": "Thu Jan 01 01:00:00 +0100 1970", "buildingIdentifier": "1234", "floorIdentifier": "123456", "code": "", "createdAt": "Thu Jan 01 01:00:00 +0100 1970", "infoHtml": "", "name": "My Geofence", "identifier": "12345678-aaaa-bbbb-cccc-12345678abcd"}]
});
- onExitGeofences
Get notified about exiting geofences. Take into account the considerations described at onEnterGeofences.
- This callback will return an array of geofences
cordova.plugins.Situm.onExitGeofences((geofences: any) => {
// Returns an array of geofences
// e.g. [{"polygonPoints": [], "customFields": {}, "updatedAt": "Thu Jan 01 01:00:00 +0100 1970", "buildingIdentifier": "1234", "floorIdentifier": "123456", "code": "", "createdAt": "Thu Jan 01 01:00:00 +0100 1970", "infoHtml": "", "name": "My Geofence", "identifier": "12345678-aaaa-bbbb-cccc-12345678abcd"}]
});
Development
Run javascript tests
1. Install mocha and expect.js:
```javascript
npm install mocha --save
npm install expect.js --save
```
2. In js tests folder run:
mocha test
Dependencies
Note for Android platform
Situm SDK for Android now compiles and targets sdkVersion 31 (Android 12). To work properly on Android 12 devices and above, the host app must:
- Target android api 31 or above. In your project
config.xml
file, add<preference name="android-targetSdkVersion" value="31" />
to the Android platform configuration. - Request the runtime permissions
ACCESS_COARSE_LOCATION
,BLUETOOTH_SCAN
andBLUETOOTH_CONNECT
(plusACCESS_FINE_LOCATION
if you are using Global Mode). Remember to also add them to the Android platform section of yourconfig.xml
file:<config-file parent="/manifest" target="AndroidManifest.xml"> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- In Global mode --> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> </config-file>
- Add
android:exported="true"
to all the intent-filtered components of yourAndroidManifest.xml
file. You can add the following configuration to yourconfig.xml
to automate this process:<edit-config file="app/src/main/AndroidManifest.xml" target="/manifest/application/activity[@android:name='MainActivity']" mode="merge"> <activity android:exported="true"/> </edit-config>
- Make sure the
widget
root element of yourconfig.xml
file declares the Android namespace:<widget id="..." version="..." ... xmlns:android="http://schemas.android.com/apk/res/android">
- If you find problems, also make sure the Gradle JDK points to version 11 in your project configuration (recommended Android Studio embedded JDK).
Capacitor compatibility
This plugin is compatible with Capacitor 3.0.
Issue: In iOS, there is a known issue with capacitor-cli 3.2.5 and static cordova plugins https://github.com/ionic-team/capacitor/issues/5142. To solve it use a different version of capacitor cli.
If the problem persists, add this plugin to the staticPlugins
section of your capacitor.config.json
file:
{
"cordova": {
"staticPlugins": [
"situm-cordova-plugin-official"
]
}
}
More information
More info is available at our Developers Page.
Support information
For any question or bug report, please send an email to support@situm.es
7 months ago
7 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
9 months ago
12 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago