package com.servdiary.mobile.data import android.annotation.SuppressLint import android.content.Context import com.google.android.gms.location.LocationServices import com.google.android.gms.location.Priority import com.google.android.gms.tasks.CancellationTokenSource import kotlinx.coroutines.tasks.await class LocationHelper(context: Context) { private val client = LocationServices.getFusedLocationProviderClient(context) @SuppressLint("MissingPermission") suspend fun currentLatLng(): Pair { val cts = CancellationTokenSource() val location = client.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, cts.token).await() ?: throw IllegalStateException("Unable to read device location") return location.latitude to location.longitude } }