Skip to content

Basic Features

Start proximity service

To start Proximity, call:

val venues: List<Int> = listOf(YOUR_VENUE_ID_1, YOUR_VENUE_ID_2)
NextomeProximitySdk.instance.startService(venues) {
    // Service started
}
let venues: [KotlinInt] = [YOUR_VENUE_ID_1, YOUR_VENUE_ID_2] 
NextomeProximitySdk.shared.instance.startService(venues: venues){
    // Service started
}

The startService method accept a list of integers that represent the venues id where you want to start the proximity service. After service is started, a callback will be returned.

Background Mode

The proximity service start must be called when application is in foreground mode.

Stop proximity

When you want to stop proximity service, call:

NextomeProximitySdk.instance.stopService {
    // Service stopped
}
NextomeProximitySdk.shared.instance.stopService(){
    // Service stopped
}

Background Mode

The proximity service will be stopped on all venues where proximity services has been started.

Observe for interaction trigger event

It's possible to observe when an interaction has been fired by the Proximity SDK. Visit Interaction to know more about interaction object.

val state: Flow<NextomeSdkState> = nextomeSdk.getStateObservable()
yourScope.launch {
    NextomeProximitySdk.instance.getInteractionsObservables()?.collect {
        // The interaction is fired by the SDK. Do something.      
        var interaction: NextomeInteraction = it          
    }
}

Observeble into a scope

To avoid concurrency problem, getInteractionsObservables method need to live inside a coroutine scope.

Observeble at application start

Is strongly recommanded to call this method at Application.onCreate method as shown at Getting Started section to be sure that a Enter/Exit region event can be correctly dispatched by operative system to the application.

NextomeProximitySdk.shared.instance.getInteractionsObservables().watch(block: { interaction in
    // The interaction is fired by the SDK. Do something. 
})

Get observed venues

It's possible get a list of venues id where proximity service is on. That's is hopeful when you open the application again after service has been started. This method allow you to know which venues, so which interactions, the application is listening for.

val observed: List<Int> = NextomeProximitySdk.instance.getObservedVenues()
var observed: [Int] = []
NextomeProximitySdk.shared.instance.getObservedVenues().forEach{ venueId in
    observed.append(venueId.intValue)
}


© 2024 Nextome srl | All Rights Reserved.