Using CrowdConnected
To get started with CrowdConnected positioning, you can either create your own implementation by using the MPPositionProvider
interface from the MapsIndoors SDK to visualize position updates from CrowdConnected or you can use the MapsIndoors CrowdConnected Positioning Provider, which handles this work for you, requiring minimal setup. This guide shows how to make use of it.
This guide assumes you already have an app with MapsIndoors.
Add Swift Package to your app project
First, add the MapsIndoors CrowdConnected Swift Package to your dependencies
Using Swift Package Manager in Xcode
In Xcode, open your project.
Go to
File
->Add Package Dependencies…
Enter the repository URL for the MapsIndoors CrowdConnected package (https://github.com/MapsPeople/mapsindoors-crowdconnected-ios.git)
Follow the prompts to select the package and target for installation.
Using Swift Package Manager Manifest
Add the following to your Package.swift
file:
Fork the project
Get iOS permissions
Ensure your Info.plist
file includes the necessary privacy-sensitive usage descriptions for location services, as required by both the MapsIndoors and CrowdConnected SDKs. This typically includes:
NSLocationWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
(if your app requires background location)NSBluetoothPeripheralUsageDescription
(since your app needs to use Bluetooth for the CrowdConnected IPS to work)
When you provide the necessary keys and initialize the CrowdConnected Position Provider, the user will be prompted to grant the required permissions.
Show the user position on the map
The last step to get the positioning shown on the map is to enable it in MPMapControl
. This is typically done when creating the MPMapControl
, but it can be turned on at any time. In the following example we turn on positioning when creating our MPMapControl
.
If you keep a reference to the position provider, it makes it easy to enable and disable positioning at any time:
App Lifecycle
It is important to ensure that your user positioning implementation respects the iOS App Lifecycle. The position provider should be properly started, paused, and resumed according to the app lifecycle to prevent memory leaks or unexpected behavior.
Example Using UISceneDelegate
Last updated
Was this helpful?