In this tutorial, we will guide you step by step to set up your first application using Situm Wayfinding Module.
Configure the WYF module in your iOS project #
First of all, you must configure Wayfinding Module in your iOS project. Here we will walk you through the proccess.
Add a Podfile to your project’s root directory with the content:
target 'YOUR_TARGET_NAME' do source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' use_frameworks! pod 'SitumWayfinding' end
Then open a Terminal, go to your project´s root directory and run:
And that’s it! From now on you can import our module in your Swift code with:
Set your credentials #
There are two ways to set the credentials, programmatically or in the Info.plist file. You should choose the first if you wanna inject the wayfinding view into your app’s UI programmatically and the second if you just want to declare one of your view as a “SitumView”.
Option 1: Set your credentials in your code #
You just need to create an object “Credentials” with your user and your password:
let credentials: Credentials = Credentials(user: "YOUR_DASHBOARD_USER", apiKey: "YOUR_DASHBOARD_APIKEY", googleMapsApiKey: "YOUR_GOOGLE_MAPS_APIKEY")
You can also use your user and APIKEY:
let credentials: Credentials = Credentials(user: "YOUR_DASHBOARD_USER", password: "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 the plist file in your project 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: programatically or through your storyboard.
Option 1: Programmatically #
Create a “SitumMapsLibrary” object and specify the containing superview and its controller:
let library: SitumMapsLibrary = SitumMapsLibrary(containedBy: containerSuperview, controlledBy: containerSuperviewController)
Set your credentials that we created in Step 2 (in the first option):
Use the “SitumMapsLibrary” object to load the “SitumView “by selecting the building for positioning:
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.
For more information, please check our docs.