Skip to content

Latest commit

 

History

History
166 lines (112 loc) · 6 KB

README.md

File metadata and controls

166 lines (112 loc) · 6 KB

Situm Capacitor & Cordova Example

A sample Capacitor application to start learning the power of @situm/cordova.

License: MIT npm npm

What's in here

This folder contains the source code of a Capacitor + Ionic example application using the Situm Cordova Plugin. You can also integrate this plugin on a Cordova project! Learn how to do it in this section.

sdk_preview wyf_preview

How to run the app

Step 1: Install the dependencies

  1. The first step is to download this repo:
git clone https://github.com/situmtech/cordova.git
  1. Then install the plugin dependencies alongside the example app as follows:
cd cordova/example
npm install

Tip

You might want to try out this configuration if you are facing some issues to build our sample app:

  • node >= 18.13.X
  • @ionic/cli 7.1.5
  • gradle 8.4
  • java 17.0.6

Note

Make sure you are using @ionic/cli and not the deprecated ionic npm package. Otherwise you won't be able to build the app and you will receive the following error:

- [ERROR] Invalid project type: angular-standalone (project config: ./ionic.config.json).

Step 2: Set up your Situm credentials

This example provides you with a template on src/constants.ts.example to set all your credentials used on the sdk tab just in one file. So rename this file to constants.ts and set up your credentials before running the app:

export const API_USER = 'YOUR_SITUM_API_USER';
export const API_KEY = 'YOUR_SITUM_API_KEY';
export const BUILDING_IDENTIFIER = 'YOUR_BUILDING_IDENTIFIER';
export const VIEWER_DOMAIN = 'https://map-viewer.situm.com';

Note

The credentials will also be set in the src/app/wyf/wyf.page.html automatically in this example app. Make sure you set your credentials inside this file in your integration.

Step 3: Run the app

From the example/ folder, execute the following command to run the app on your device:

# For Android devices
ionic cap run android
# For iOS devices
ionic cap run ios

Note

iOS only

You might need to update the pods of this app by executing inside example/ios/App:

$ pod install --repo-update

Also check out the project code signing before you run the example.

You can also run the app from your IDE:

  • On Android: open example/android/ with Android Studio.
  • On iOS: open example/ios/App/App.xcworkspace with XCode.

Using @situm/cordova on a Cordova app

To integrate our plugin in a Cordova project, follow this 3 steps:

  1. Configure your Content-Security-Policy <meta> tag in your www/index.html to be able to display our MapView on Android:
<meta
  http-equiv="Content-Security-Policy"
  content="default-src 'self' data: https://ssl.gstatic.com https://map-viewer.situm.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;"
/>
  1. Configure your config.xml file to be able to display our MapView on iOS by adding the following <allow-navigation> tag:
<widget>
  ...
  <allow-navigation href="https://map-viewer.situm.com/*" />
</widget>
  1. All ready to use our plugin in a Cordova app!
cordova plugin add @situm/cordova
# For Android
cordova run android
# For iOS
cordova run iOS

Documentation

More information on how to use the official @situm/cordova plugin and the set of APIs, the functions, parameters and results each function accepts and provides can be found in our SDK API Reference and Wayfinding API Reference.

Examples

In case you want to learn how to use our plugin, you may want to take a look at our code samples of the basics functionalities:

  1. Basic SDK and Wayfinding functionality: showcases how to initialize the Situm SDK (refer to the cordova sdk quickstart guide for more information) and how to use some basic features like positioning and obtaining the information of a given building.

Versioning

We use SemVer for versioning.

Please refer to CHANGELOG.md for a list of notables changes for each version of the library.

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

This project is licensed under the MIT - see the LICENSE file for details.

More information

More info is available at our Developers Page.

Support information

For any question or bug report, please send an email to [email protected]