This guide refers to the previous version of the WYF module, which is no longer maintained. We strongly recommend visiting the updated guide which will guide you on how to integrate the new visual component, MapView.
To stay up to date, checkout the iOS SDK Changelog.
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.