02 – iOS quickstart guide

In this tutorial, we will guide you step by step to set up your first iOS application using Situm Wayfinding Module.

Configure the WYF module in your iOS project #

We assume that you have created your project and configured Cocoapods in it.

First, you must import Situm WYF by adding it to your Podfile:

target 'YOUR_TARGET_NAME' do
  source 'https://github.com/CocoaPods/Specs.git'
  platform :ios, '9.0'
  use_frameworks!

  ...

  #Add Situm WYF to your project
  pod 'SitumWayfinding'
end

Then, on a terminal, go to your project´s root directory and run:

pod install

And that’s it! From now on you can import our module in your code with:

import SitumWayfinding
@import SitumWayfinding;

Set your Situm and Google Maps #

There are two ways to set the credentials, programmatically or in the Info.plist file. You should choose the first if you want to inject the Situm WYF view into your app’s UI programmatically and the second if you just want to declare one of your views as a “SitumView”.

Situm WYF uses Google Maps as a base layer, on top of which everything else is drawn: floorplans, routes, user’s location… More concretely, it uses the Dynamic Maps service, which has a generous free tier. In order to use Google Maps, you you should create an API Key for your project. 

Option 1: Set your credentials in your code #

The recommended way is to create an object “Credentials” with your Situm user and APIKEY. You will also need to provide your Google Maps APIKEY:

let credentials: Credentials = Credentials(user: "YOUR_DASHBOARD_USER", password: "YOUR_DASHBOARD_APIKEY", googleMapsApiKey: "YOUR_GOOGLE_MAPS_APIKEY")

You can also use your Situm user and password (less recommended):

let credentials: Credentials = Credentials(user: "YOUR_DASHBOARD_USER", apiKey: "YOUR_DASHBOARD_APIKEY", googleMapsApiKey: "YOUR_GOOGLE_MAPS_APIKEY")

This object we just created will be used later to authenticate for Situm and GoogleMaps services.

Option 2: Set your credentials in Info.plist file #

Open your Info.plist file as source code and add your credentials like this:

<key>es.situm.sdk.API_USER</key>
<string>YOUR_DASHBOARD_USER</string>
<key>es.situm.sdk.API_KEY</key>
<string>YOUR_DASHBOARD_APIKEY</string>
<key>com.google.android.geo.API_KEY</key>
<string>YOUR_GOOGLE_MAPS_APIKEY</string>

Please note that this option only allows authentication using APIKEY.

Load our SitumMapView #

The last step you need to follow is loading our “SitumView” into your app. This can be done in two ways: programmatically or through your Storyboard.

Option 1: Programmatically (recommended) #

Using SitumWYF programmatically is very easy and provides the greatest flexibility. To do so, you just need to declare a SitumMapsLibrary object and specify: the containing superview, its controller and the settings that you want to apply.

import UIKit
import SitumWayfinding

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //Define the credentials
        let credentials: Credentials = Credentials(user: "USER@EMAIL.COM", apiKey: "SITUM-APIKEY", googleMapsApiKey: "GOOGLEMAPS-APIKEY")
        
        //Configure the SitumMapsLibrary settings (more settings here: https://situm.com/docs/static-ui-settings/)
        let librarySettings = LibrarySettings.Builder().setCredentials(credentials: credentials).setBuildingId(buildingId: "11908").setUseRemoteConfig(useRemoteConfig: true).build();
        
        //Start SitumMapsLibrary
        let library: SitumMapsLibrary = SitumMapsLibrary(containedBy: self.view, controlledBy: self, withSettings: librarySettings)
        do{
            try library.load()
        }
        catch{
            print("Error loading SitumWayfinding view")
        }
        
    }
}

Option 2: Declare SitumView in your storyboard #

The second option allows you to declare any view in your storyboard as a SitumView. Just select the one you want, open the identity inspector and type “SitumView” as custom class and “SitumWayfinding” as the custom module. Please remember that this option will only work if you include your credentials in your plist file

Enjoy your new app! #

Congratulations! You’ve just created your first positioning app in just a few steps. With SitumWayfinding you and your users will be able to position inside a building, ask for routes to a selected point, receive navigation instructions, and much more.

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