Configure indoor positioning for iOS

This tutorial describes how to configure indoor positioning for use with the indoor positioning iOS SDK.

The indoor positioning SDK provides an API for developers to create location aware apps for navigation inside buildings at supported venues.

Pre-requisites

The pre-requisites for setting up the indoor positioning iOS SDK are as follows:

  1. Include the indoor positioning SDK dependency in your app.
  2. Add the build phase script.
  3. Add the post-action script.
  4. Add your HERE license keys.

Include the indoor positioning SDK dependency in your app

Link and embed navenioSDK.xcframework within your project.

Note

The iOS Navenio SDK will be available through SPM at a later date.

Add the build phase script

Add the build phase script to your project:

echo "${EXPANDED_CODE_SIGN_IDENTITY}" > /tmp/sign-identity
Adding the build phase script
Figure 1. Adding the build phase script

Add the post-action script

Add the post-action script to your project:

Edit scheme -> Build -> Post-actions

CODE_SIGN_IDENTITY=`cat /tmp/sign-identity`
find "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/navenioSDK.framework/Frameworks" -mindepth 1 -maxdepth 1 -type d -exec /usr/bin/codesign --force --sign ${CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements {} \;
Adding the post-action script
Figure 2. Adding the post-action script

Add your HERE license keys

The indoor positioning SDK uses the same OAuth2 credentials as the HERE SDK from the same location. Hence, when you have the HERE SDK set up, the indoor positioning SDK OAuth2 keys are set up as well.

Note

For more information on gathering credentials, see Indoor positioning SDKs.

Import the indoor positioning SDK library

Import the navenioSDK library before using it in your code:

import navenioSDK

Declare the indoor positioning SDK

Within your ViewController, declare an instance of the indoor positioning SDK:

let navenioManager = NavenioManagerProvider.externalShared

Download and get indoor positioning data

Download indoor positioning data for a given venue:

navenioManager.fetchVenue(indoorMapName:onSuccess:onError:)

The following table defines the values used in the above code sample:

Value Definition
indoorMapName The string corresponding to your indoor map, provided by HERE. In subsequent releases the HERE indoor map ID will be used instead.
onSuccess Closure where the indoor positioning data object is returned after the data have been downloaded.
onError Closure where the Error object is returned with information about an error.

Get current location data

Add a delegate to receive location update callbacks from the location engine:

navenioManager.addLocationListener(self)

Start the location engine:

navenioManager.startLocating(venue: venue, captureData: true)

The following table defines the values used in the above code sample:

Value Definition
venue Indoor positioning data object returned from the fetchVenue() call (required).

Conform a class to the LocationListener protocol to receive level changes, indoor locations, and geo locations:

extension ViewController: LocationListener {

    func onLocationChange(location: Location) {
        switch location {
        case .indoorLocation(let indoorLocation):
            print("\(#function) \(indoorLocation)")
        case .geoLocation(let geoLocation):
            print("\(#function) \(geoLocation)")
        default:
            break
        }
    }

    func onLevelChange(levelId: String) {
        print("\(#function) \(levelId)")
    }
}

Stop the location engine after it is no longer needed to prevent the indoor positioning SDK from sampling in the background:

navenioManager.stopLocating()

Stop and clean up resources

Ensure that you call stopLocating() when you are finished so that the indoor positioning SDK stops sampling in the background. HERE also recommends calling destroy() so that the SDK can release its resources. Any listeners are unregistered, and resources that are no longer required when you are finished are released.

results matching ""

    No results matching ""