1.20.34 • Published 6 months ago

situm-cordova-plugin-official v1.20.34

Weekly downloads
8
License
MIT
Repository
github
Last release
6 months ago

Situm Cordova Plugin

License: MIT npm npm

npm.io

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

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 and BLUETOOTH_CONNECT (plus ACCESS_FINE_LOCATION if you are using Global Mode). Remember to also add them to the Android platform section of your config.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 your AndroidManifest.xml file. You can add the following configuration to your config.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 your config.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

1.20.27

7 months ago

1.20.28

7 months ago

1.20.29

6 months ago

1.20.21

7 months ago

1.20.22

7 months ago

1.20.23

7 months ago

1.20.24

7 months ago

1.20.25

7 months ago

1.20.26

7 months ago

1.20.30

6 months ago

1.20.31

6 months ago

1.20.32

6 months ago

1.20.33

6 months ago

1.20.34

6 months ago

3.0.0

6 months ago

1.20.19

7 months ago

1.20.20

7 months ago

1.20.16

8 months ago

1.20.17

8 months ago

1.20.18

8 months ago

1.20.10

10 months ago

1.20.11

10 months ago

1.20.12

10 months ago

1.20.13

10 months ago

1.20.14

9 months ago

1.20.15

9 months ago

1.20.5

12 months ago

1.20.6

11 months ago

1.20.9

11 months ago

1.20.7

11 months ago

1.20.8

11 months ago

1.19.0

1 year ago

1.20.1

1 year ago

1.20.2

1 year ago

1.20.0

1 year ago

1.20.3

1 year ago

1.20.4

1 year ago

1.18.2

1 year ago

1.18.1

2 years ago

1.18.0

2 years ago

1.17.4

2 years ago

1.17.2

2 years ago

1.17.1

2 years ago

1.17.0

2 years ago

1.16.3

3 years ago

1.16.2

3 years ago

1.16.1

4 years ago

1.16.0

4 years ago

1.15.10

5 years ago

1.15.10-support

5 years ago

1.15.9

5 years ago

1.15.9-support

5 years ago

1.15.8

5 years ago

1.15.8-support

5 years ago

1.15.7

5 years ago

1.15.7-support

5 years ago

1.15.6-support

5 years ago

1.15.5

5 years ago

1.15.5-support

5 years ago

1.15.4

5 years ago

1.15.4-support

5 years ago

1.15.3

5 years ago

1.15.3-support

5 years ago

1.15.2

5 years ago

1.15.2-support

5 years ago

1.15.1

5 years ago

1.15.1-support

5 years ago

1.15.0

5 years ago

1.14.5

5 years ago

1.14.5-support

5 years ago

1.14.4

5 years ago

1.14.4-support

5 years ago

1.14.3

5 years ago

1.14.3-support

5 years ago

1.14.2

5 years ago

1.14.1

5 years ago

1.14.0

5 years ago

1.13.0

5 years ago

1.13.0-support

5 years ago

1.12.2

5 years ago

1.12.2-support

5 years ago

1.12.1

5 years ago

1.12.0

5 years ago

1.11.8

5 years ago

1.11.8-support

5 years ago

1.11.7

5 years ago

1.11.7-support

5 years ago

1.11.6

5 years ago

1.11.5

5 years ago

1.11.5-support

5 years ago

1.11.4

5 years ago

1.11.3

5 years ago

1.11.2

5 years ago

1.11.1

5 years ago

1.11.1-support

5 years ago

1.11.0

5 years ago

1.10.9

5 years ago

1.10.9-support

5 years ago

1.10.8

5 years ago

1.10.7

5 years ago

1.10.5

5 years ago

1.10.4

5 years ago

1.10.3

5 years ago

1.10.2

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

1.9.6

5 years ago

1.9.5

5 years ago

1.9.4

5 years ago

1.9.3

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.9

5 years ago

1.8.8

6 years ago

1.8.6

6 years ago

1.8.5

6 years ago

1.8.4

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.6

6 years ago

1.7.5

6 years ago

1.7.4

6 years ago

1.7.3

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.10

6 years ago

1.5.8

6 years ago

1.5.7

6 years ago

1.5.6

6 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.17

6 years ago

1.3.16

6 years ago

1.3.15

6 years ago

1.3.14

6 years ago

1.3.13

6 years ago

1.3.12

6 years ago

1.3.11

6 years ago

1.3.10

6 years ago

1.3.9

6 years ago

1.3.8

6 years ago

1.3.7

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago