Skip to content

Quickstart

This page walks through install, configure, start, and observing locations on every platform. Pick your platform once — the tabs stay synced as you scroll.

The platform-specific OS configuration (manifest, plist, pubspec) is in the per-platform setup deep-dives:

app/build.gradle.kts
dependencies {
implementation("io.github.wayqteam:beekon:0.0.3")
}

Min SDK 26, Kotlin 2.x. Maven Central is included by default in AGP — no extra repo needed.

configure sets the gate (interval + distance). Call it once before start(); you can call it again mid-session to live-tune the gate without restarting the location subscription.

Beekon.initialize(context) is one-time and idempotent — call it once in Application.onCreate. It wires the SDK to the application context and rehydrates persisted intent (so a process restart can resume tracking automatically).

Application.onCreate
class App : Application() {
override fun onCreate() {
super.onCreate()
Beekon.initialize(this)
Beekon.configure(
BeekonConfig(
intervalSeconds = 30,
distanceMeters = 100.0,
notification = BeekonConfig.Notification(
title = "Beekon",
text = "Tracking your location",
smallIcon = R.drawable.ic_stat_beekon,
),
),
)
}
}

All Notification fields are optional — leave them null to inherit the host app’s label and launcher icon. Channel id and notification id are SDK-internal constants. See Background execution for the foreground-service mechanics.

start() requests location updates and brings up the platform’s background-execution machinery (Android foreground service, iOS CLBackgroundActivitySession). It throws if permission is missing or the platform refuses.

lifecycleScope.launch {
try {
Beekon.start()
} catch (e: BeekonError.PermissionDenied) {
// request ACCESS_FINE_LOCATION + ACCESS_BACKGROUND_LOCATION, then retry
} catch (e: BeekonError.LocationServicesDisabled) {
// device has Location Services off, or no Google Play Services
}
}

State and locations are streamed; consume with whatever’s idiomatic for your platform.

// Latest state — StateFlow replays the current value to new collectors
val state by Beekon.state.collectAsStateWithLifecycle()
// Live fixes — SharedFlow with DROP_OLDEST(64); slow consumers don't block writes
LaunchedEffect(Unit) {
Beekon.locations.collect { loc ->
Log.d("beekon", "${loc.latitude}, ${loc.longitude} acc=${loc.horizontalAccuracyMeters ?: "—"}m")
}
}

History is the native library’s own SQLite database. It survives process death; the live stream does not. Retention is TTL 7 days + 100,000 row cap, auto-pruned every 200 inserts.

val now = Instant.now()
val hourAgo = now.minus(1, ChronoUnit.HOURS)
val points: List<Location> = Beekon.history(from = hourAgo, to = now)

See Persistence & history for the schema.

  1. Wire OS-level config: Android, iOS, or Flutter.
  2. Read Lifecycle & states — the state machine that drives state.
  3. Read Background execution for what’s actually keeping your app alive.