Skip to content

Proximity Triggers

Optional

Needed if your app reacts to users entering, leaving or dwelling in areas.

Introduction

Oriient Indoor Positioning System (IPS) Proximity Triggers provide tools to add proximity-related events to your mobile application.

Implementation

Observing Proximity Events

To observe the proximity events, use IPSProximity.addProximityEventsListener() and implement the methods of the IPSProximityEventsListener interface. Each of the event types will be reported to the corresponding method of the listener, and will contain the IPSProximityTrigger and the IPSRegion related to the event. The metadata of the region and the trigger might be used to customize how the event is handled.

Important

The proximity events will be triggered only during an active Positioning session, and if current position is considered locked.

Info

The lock progress of a position is measured from 0 (not locked) to 1 (locked).

Observing Triggers

It is possible to observe all the triggers available on the current active map. Use IPSProximity.addTriggersListener() and implement the methods defined in the IPSTriggersListener interface. The SDK will notify applications regarding all the added, removed, or updated triggers. When the listener is assigned, all the triggers currently available will be reported as added.

Local Proximity Events

The triggers described above are configured remotely via the Dashboard or REST API, and are tied to Regions. If you need proximity behavior that's defined entirely on the client — with no Dashboard configuration — use IPSLocalProximityEvent instead.

Each IPSLocalProximityEvent is defined by answering three questions:

IPSLocalProximityEvent(
    groupId = "Product promotions", // used to remove a batch of events at once, see below
    buildingId = "Oriient building id",
    floorOrder = 0,
    trigger = IPSLocalProximityEventTrigger.onEnter(),
    locationDefinition = IPSLocalProximityLocationDefinition.closeWalkingDistance(coordinate),
    repetitionStrategy = IPSLocalProximityEventRepetitionStrategy.once(),
    action = {
        // Called when the event triggers
    }
)

Managing Events

Register events using IPSProximity.setLocalProximityEvents() (replaces the current list) or IPSProximity.addLocalProximityEvents() (adds to it). Remove them with IPSProximity.removeLocalProximityEvents() (by reference), IPSProximity.removeAllLocalProximityEvents(), or IPSProximity.removeLocalProximityEventsByGroupIds() to remove every event sharing a groupId.

data class ProductPromotion(
    val productLocation: IPSCoordinate,
    val productFloor: Int,
    val promotionText: String
)

fun onProductPromotionsLoaded(promotions: List<ProductPromotion>, store: IPSBuilding) {
    val events = promotions.map { promotion ->
        IPSLocalProximityEvent(
            groupId = null,
            buildingId = store.id,
            floorOrder = promotion.productFloor,
            trigger = IPSLocalProximityEventTrigger.onEnter(),
            locationDefinition = IPSLocalProximityLocationDefinition.closeWalkingDistance(promotion.productLocation),
            repetitionStrategy = IPSLocalProximityEventRepetitionStrategy.once(),
            action = {
                handle(promotion)
            }
        )
    }

    IPSProximity.setLocalProximityEvents(events)
}

fun onUserLogout() {
    IPSProximity.removeAllLocalProximityEvents()
}

fun handle(promotion: ProductPromotion) {
    // navigate to the promotion screen
}

Data Structure

Proximity Trigger Object

The proximity events in the system are managed using IPSProximityTrigger objects. Each IPSProximityTrigger can contain several events (IPSTriggerEvent). When circumstances defined by the event parameters are met the event is triggered and the application using the IPS SDK is notified about this event. Define trigger metadata and then assign that trigger to one or several regions on a map to receive events related to those particular areas.

Proximity Events

The event types supported by the system are:

Event Type Triggered when the device
Enter enters one of the specified regions.
Exit exits one of the specified regions.
Dwell enters one of the specified regions and remains there for a defined period.

Info

An overview of the content structure in the system is available here. The regions, triggers, and all their metadata can be configured in the Dashboard, or using the REST API. The metadata defined for a trigger will be available at the IPSProximityTrigger.getMetadata() method. The metadata field opens a wide range of customization options for the proximity service. In our Demo Project, the metadata field is used to show users notifications, show/hide regions, and activate/deactivate triggers.