Skip to main content

Usage

Token detection

The SDK uses the microphone to capture the surrounding sound and search for SonicMedia tokens, and requires the microphone permission.

The token detection can be started and stopped at any time.

detectionService?.start()

// ...

detectionService?.stop()

Synchronization

The SDK synchronizes the campaign scheduling metadata. It is run automatically when the SDK is initialized and can be manually requested from the application by calling the synchronize method.

The synchronization process occurs in the background and uses differential updates to minimize data usage. It also downloads and caches the images for the campaigns that could be potentially triggered.

detectionService?.synchronize {
// Called when synchronization finishes
}
info

It's not required to pause the detection process to do a synchronization.

Event handling

When a token is detected, the SDK checks for the campaigns that meet the conditions defined in the CMS (schedule, categories, repetition time, etc.), and if a matching campaign is found, then an event with all the relevant data is raised in order for the web app to take appropriate actions, like displaying the campaign image.

detectionService?.setAdDetectedListener { ad ->
// Process the event
val name = ad.name
val url = ad.url
val thumbnail = detectionService?.getAdThumbnail(ad)
val image = detectionService?.getAdImage(ad)
// ...
}