Skip to content

Login

Required

Needed by every integration.

Before using any of the IPSFramework features in your application, it is essential that you first log in.

Attention

Keep in mind that the login process is an asynchronous command, requiring an active Internet connection.

Additionally, it is crucial to use a pair of API Keys (Development and Production) for login purposes. Beware that there's an assertion in place which may cause the application to terminate if you use a Production API Key while debugging via Xcode or any other debugging tool.

Use the IPSLoginDelegate to handle the result of the login command.

  1. First, assign the IPSCore.loginDelegate.

  2. Then, use IPSCore.login to login.

import Foundation
import IPSFramework

class PositioningLoginManager {
    func initiateLogin(){
        // Most simple way to login
        // IPSCore.login(apiKey: "[Your API Key]")

        // Login with more configurations
        IPSCore.login(
            apiKey: "[Your API Key]",
            ipsDomain: "[Your IPS Domain]", // Optional, by default uses EU cluster
            userID: "[User ID]" // Optional, may help to debug and attribute sessions
        ) { (error) in
            if let error = error {
                print("Could not log in to IPSFramework. Reason: \(error.message)")
                return
            }

            // The selection of a Space is optional, but recommended
            IPSCore.setSelectedSpaceId("[Your Space ID]") { (error) in
                if let error = error {
                    print("Could not set a Space ID. Reason: \(error.message)")
                    return
                }
            }
        }
    }
}

Note

All location-based content, including maps, is categorized by 'Spaces'. By default, the Framework will utilize your first Space, which typically is the only Space available. However, as Spaces can be modified through the dashboard or REST API, Oriient recommends explicitly selecting one after login. See Spaces below.

Pre-loading the data required for positioning (optional)

Upon successful login, you have the option to pre-load the data necessary for positioning within a specific building. This step requires a specified buildingId and should be executed only if you have prior knowledge of the building where the user will be using the feature. Otherwise, this step can be omitted. Generally, this is an optional process. If not implemented, the data will be automatically downloaded when the user is inside the geofence, or at a later stage when you invoke IPSPositioning.startPositioning(). See Positioning Guide for more reference.

To start the data pre-loading, simply call the following endpoint:

IPSDataManager.prepareData(for: buildingId)

The next step is also optional - you may implement the data status observer IPSDataStatusObserver, to observe the status of the data downloading, see an example from our demo app:

extension IndoorPositioningCoreServiceImpl: IPSDataStatusObserver {

    func onDataStatusChanged(for buildingId: String, newStatus: IPSFramework.IPSDataStatus) {
        switch newStatus {
        case .requiresPreparation, .ready:
            isPositioningDataPreloading.value = false
        case .preparing:
            isPositioningDataPreloading.value = true
        @unknown default:
            break
        }
    }

    func onDataPreparationFailed(for buildingId: String, error: IPSFramework.IPSError) {
        positioningDataPreloadingError.send(error)
    }   
}

Lastly, add the observer via:

IPSDataManager.addDataStatusObserver(self)

Spaces

All the location content in Oriient IPS, including maps, is grouped by Spaces. The Spaces concept facilitates control over which maps and location content will be accessible through the IPSFramework. The Space object in the system is represented by the IPSSpace object.

Selected Space

Currently selected Space ID is available using the IPSCore.getSelectedSpaceId() method. In case the login command was not executed, the resulting value will be nil.

Get Available Spaces List

The list of spaces currently available can be obtained using IPSCore.getAvailableSpaces(). In case the login command was not executed, the result will be empty. This list is directly related to the API key used for the login.

Switching Spaces

You can switch between currently available spaces using IPSCore.setSelectedSpaceId().

Recommendation

Selecting a space immediately following execution of the login command is recommended. This holds true even if there is only one Space currently available for your API key.