File tree 1 file changed +6
-1
lines changed
android/src/main/java/com/rnbridge/geofencing
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import com.google.android.gms.location.Geofence.GEOFENCE_TRANSITION_ENTER
21
21
import com.google.android.gms.location.Geofence.GEOFENCE_TRANSITION_EXIT
22
22
import com.google.android.gms.location.GeofencingRequest
23
23
import com.google.android.gms.location.LocationServices
24
+ import com.google.android.gms.location.Priority
25
+ import com.google.android.gms.tasks.CancellationTokenSource
24
26
import com.google.gson.Gson
25
27
import com.google.gson.reflect.TypeToken
26
28
import java.util.Locale
@@ -54,7 +56,10 @@ class GeofenceManager(private val context: Context) {
54
56
val response = Arguments .createMap()
55
57
val activity = (context as ReactApplicationContext ).currentActivity ? : return
56
58
val fusedLocationClient = LocationServices .getFusedLocationProviderClient(activity)
57
- fusedLocationClient.lastLocation.addOnSuccessListener { location: Location ? ->
59
+ fusedLocationClient.getCurrentLocation(
60
+ Priority .PRIORITY_HIGH_ACCURACY ,
61
+ CancellationTokenSource ().token
62
+ ).addOnSuccessListener { location: Location ? ->
58
63
if (location == null ) {
59
64
promise.reject(Error (" Location is undefined" ))
60
65
return @addOnSuccessListener
You can’t perform that action at this time.
0 commit comments