Skip to content

Commit

Permalink
Merge pull request #8 from eliot-ye/master
Browse files Browse the repository at this point in the history
fix android getCurrentLocation
  • Loading branch information
sriharshamadamanchi authored Nov 20, 2024
2 parents 4e338db + a2c352c commit a01053b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.google.android.gms.location.Geofence.GEOFENCE_TRANSITION_ENTER
import com.google.android.gms.location.Geofence.GEOFENCE_TRANSITION_EXIT
import com.google.android.gms.location.GeofencingRequest
import com.google.android.gms.location.LocationServices
import com.google.android.gms.location.Priority
import com.google.android.gms.tasks.CancellationTokenSource
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import java.util.Locale
Expand Down Expand Up @@ -54,7 +56,10 @@ class GeofenceManager(private val context: Context) {
val response = Arguments.createMap()
val activity = (context as ReactApplicationContext).currentActivity ?: return
val fusedLocationClient = LocationServices.getFusedLocationProviderClient(activity)
fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
fusedLocationClient.getCurrentLocation(
Priority.PRIORITY_HIGH_ACCURACY,
CancellationTokenSource().token
).addOnSuccessListener { location: Location? ->
if (location == null) {
promise.reject(Error("Location is undefined"))
return@addOnSuccessListener
Expand Down

0 comments on commit a01053b

Please sign in to comment.