-
Notifications
You must be signed in to change notification settings - Fork 444
[Bug]: Android getCurrentPosition timesout when user grants Approximate WhenInUse permission #2543
Copy link
Copy link
Open
Labels
Description
Required Reading
- Confirmed
Plugin Version
5.0.5
Mobile operating-system(s)
- iOS
- Android
Device Manufacturer(s) and Model(s)
samsung, emulator
Device operating-systems(s)
Android 16
React Native / Expo version
expo SDK 55
What happened?
- Grant
Approximate(IMPORTANT)While using the apppermission. - Choose
cancelforBackground rationalalert (x2) - Choose
Keep approximate location(IMPORTANT) when asked again.
The app will timeout when calling BackgroundGeolocation.getCurrentPosition()
HOWEVER, when I provide DesiredAccuracy.Lowest it works (does not timeout) is this expected?
BackgroundGeolocation.getCurrentPosition({
desiredAccuracy: BackgroundGeolocation.DesiredAccuracy.Lowest
});Minimal repo https://github.com/mwmcode/rn-bg-location-timeout
Plugin Code and/or Config
{
// https://transistorsoft.github.io/react-native-background-geolocation/latest/interfaces/AppConfig.html
app: {
preventSuspend: false,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
backgroundPermissionRationale: {
title: 'Background rationale',
message: 'my-app needs background location location',
positiveAction: 'grant it',
negativeAction: 'cancel',
},
},
// https://transistorsoft.github.io/react-native-background-geolocation/latest/interfaces/GeoConfig.html
geolocation: {
locationAuthorizationRequest: 'Always',
useSignificantChangesOnly: true,
desiredAccuracy: BackgroundGeolocation.DesiredAccuracy.Medium,
showsBackgroundLocationIndicator: false,
distanceFilter: 1000,
stationaryRadius: 500,
disableLocationAuthorizationAlert: true,
locationAuthorizationAlert: {
titleWhenNotEnabled: 'background-location not enabled',
titleWhenOff: 'background-location off',
instructions: 'grant location permission to my-app',
cancelButton: 'cancel',
settingsButton: 'settingsButton',
},
},
// https://transistorsoft.github.io/react-native-background-geolocation/latest/interfaces/ActivityConfig.html
activity: {
disableMotionActivityUpdates: true, // not needed
},
// https://transistorsoft.github.io/react-native-background-geolocation/latest/interfaces/PersistenceConfig.html
persistence: {
maxRecordsToPersist: 25,
locationTemplate:
'{ "Latitude":<%= latitude %>, "Longitude":<%= longitude %> }',
},
// https://transistorsoft.github.io/react-native-background-geolocation/latest/interfaces/HttpConfig.html
http: {
url: 'https://example.com',
autoSync: true,
batchSync: false,
maxBatchSize: 1,
autoSyncThreshold: 1,
rootProperty: 'Filters',
},
logger: {
logMaxDays: 1,
logLevel: BackgroundGeolocation.LogLevel.Debug,
},
}Relevant log output
04-01 13:03:45.158 15415 15463 I TSLocationManager: [c.t.l.http.HttpService flush]
04-01 13:03:45.158 15415 15463 I TSLocationManager: ╔═════════════════════════════════════════════
04-01 13:03:45.158 15415 15463 I TSLocationManager: ║ HTTP Service (count: 0)
04-01 13:03:45.158 15415 15463 I TSLocationManager: ╠═════════════════════════════════════════════
04-01 13:03:45.162 15415 15456 I TSLocationManager: [c.t.l.l.LocationAuthorization withBackgroundPermission]
04-01 13:03:45.162 15415 15456 I TSLocationManager: 🔵 LocationAuthorization: Requesting Background permission
04-01 13:03:45.871 15415 15415 D TSLocationManager: [c.t.l.l.LifecycleManager e] ☯️ onPause
04-01 13:03:48.493 15415 15415 D TSLocationManager: [c.t.l.l.LifecycleManager f] ☯️ onResume
04-01 13:03:48.494 15415 15415 I TSLocationManager: [c.t.l.l.LocationAuthorization d]
04-01 13:03:48.494 15415 15415 I TSLocationManager: 🔵 Should show backgroundPermissionRationale? true
04-01 13:03:49.734 15415 15455 I ReactNativeJS: 'granted ', { permission: 4 }
04-01 13:03:49.750 15415 15455 I ReactNativeJS: running useEffect...
04-01 13:03:49.752 15415 15455 I ReactNativeJS: initializing.....
04-01 13:03:49.759 15415 15456 D TSLocationManager: [c.t.locationmanager.a.j a] NotificationChannel{mId='bggeo', mName=BackgroundGeolocation, mDescription=, mImportance=3, mBypassDnd=false, mLockscreenVisibility=-1, mSound=null, mLights=false, mLightColor=0, mVibrationPattern=null, mVibrationEffect=null, mUserLockedFields=0, mUserVisibleTaskShown=false, mVibrationEnabled=false, mShowBadge=false, mDeleted=false, mDeletedTimeMs=-1, mGroup='null', mAudioAttributes=null, mBlockableSystem=false, mAllowBubbles=-1, mImportanceLockedDefaultApp=false, mOriginalImp=-1000, mParent=null, mConversationId=null, mDemoted=false, mImportantConvo=false, mLastNotificationUpdateTimeMs=0}
04-01 13:03:49.760 15415 15415 D TSLocationManager: [c.t.l.event.EventManager c] 🛜 ⚡️ providerchange
04-01 13:03:49.763 15415 15455 I ReactNativeJS: '[onProvider] - ', { accuracyAuthorization: 1,
04-01 13:03:49.763 15415 15455 I ReactNativeJS: gps: true,
04-01 13:03:49.763 15415 15455 I ReactNativeJS: status: 4,
04-01 13:03:49.763 15415 15455 I ReactNativeJS: enabled: true,
04-01 13:03:49.763 15415 15455 I ReactNativeJS: network: false }
04-01 13:03:49.763 15415 15455 I ReactNativeJS: '[onProviderChange]: ', { accuracyAuthorization: 1,
04-01 13:03:49.763 15415 15455 I ReactNativeJS: gps: true,
04-01 13:03:49.763 15415 15455 I ReactNativeJS: status: 4,
04-01 13:03:49.763 15415 15455 I ReactNativeJS: enabled: true,
04-01 13:03:49.763 15415 15455 I ReactNativeJS: network: false }
04-01 13:03:49.769 15415 15415 D TSLocationManager: [c.t.l.event.EventManager c] 🛜 ⚡️ providerchange
04-01 13:03:49.769 15415 15456 I TSLocationManager: [c.t.l.l.LocationAuthorization withBackgroundPermission]
04-01 13:03:49.769 15415 15456 I TSLocationManager: 🔵 LocationAuthorization: Requesting Background permission
04-01 13:03:49.769 15415 15455 I ReactNativeJS: '[onProvider] - ', { accuracyAuthorization: 1,
04-01 13:03:49.769 15415 15455 I ReactNativeJS: gps: true,
04-01 13:03:49.769 15415 15455 I ReactNativeJS: status: 4,
04-01 13:03:49.769 15415 15455 I ReactNativeJS: enabled: true,
04-01 13:03:49.769 15415 15455 I ReactNativeJS: network: false }
04-01 13:03:49.769 15415 15455 I ReactNativeJS: '[onProviderChange]: ', { accuracyAuthorization: 1,
04-01 13:03:49.769 15415 15455 I ReactNativeJS: gps: true,
04-01 13:03:49.769 15415 15455 I ReactNativeJS: status: 4,
04-01 13:03:49.769 15415 15455 I ReactNativeJS: enabled: true,
04-01 13:03:49.769 15415 15455 I ReactNativeJS: network: false }
04-01 13:03:49.770 15415 15456 I TSLocationManager: [c.t.l.l.LocationAuthorization d]
04-01 13:03:49.770 15415 15456 I TSLocationManager: 🔵 Should show backgroundPermissionRationale? true
04-01 13:03:50.476 15415 15463 I TSLocationManager: - Enable: false → true, trackingMode: 1
04-01 13:03:50.478 15415 15463 D TSLocationManager: [c.t.l.event.EventManager c] 🛜 ⚡️ enabledchange
04-01 13:03:50.481 15415 15463 I TSLocationManager: [c.t.l.g.TSGeofenceManager start]
04-01 13:03:50.481 15415 15463 I TSLocationManager: 🎾 Start monitoring geofences
04-01 13:03:50.482 15415 15463 D TSLocationManager: [c.t.l.http.HttpService startMonitoringConnectivityChanges]
04-01 13:03:50.482 15415 15463 D TSLocationManager: 🎾 Start monitoring connectivity changes
04-01 13:03:50.487 15415 15463 D TSLocationManager: [c.t.l.device.DeviceSettings startMonitoringPowerSaveChanges]
04-01 13:03:50.487 15415 15463 D TSLocationManager: 🎾 Start monitoring powersave changes
04-01 13:03:50.496 15415 15463 I TSLocationManager: [c.t.locationmanager.a.l c]
04-01 13:03:50.496 15415 15463 I TSLocationManager: 🔴 Stop heartbeat
04-01 13:03:50.499 15415 15501 D TSLocationManager: [c.t.l.http.HttpService a]
04-01 13:03:50.499 15415 15501 D TSLocationManager: ╔═════════════════════════════════════════════
04-01 13:03:50.499 15415 15501 D TSLocationManager: ║ 📶 Connectivity change: connected? true
04-01 13:03:50.499 15415 15501 D TSLocationManager: ╠═════════════════════════════════════════════
04-01 13:03:50.500 15415 15415 D TSLocationManager: [c.t.l.l.LifecycleManager d] ☯️ onWindowFocusChanged: true
04-01 13:03:50.501 15415 15415 D TSLocationManager: [c.t.l.event.EventManager c] 🛜 ⚡️ connectivitychange
04-01 13:03:50.506 15415 15463 I TSLocationManager: [c.t.l.service.TrackingService a]
04-01 13:03:50.506 15415 15463 I TSLocationManager: 🔵 setPace: false → false
04-01 13:03:50.510 15415 15455 I ReactNativeJS: calling getCurrentPosition...
04-01 13:03:50.534 15415 15415 D TSLocationManager: [c.t.l.l.SingleLocationRequest trySatisfyLastLocation] 📍
04-01 13:03:50.534 15415 15415 D TSLocationManager: ╟─ age: 1179916ms
04-01 13:03:50.534 15415 15415 D TSLocationManager: ╟─ maximumAge: 30000
04-01 13:03:50.534 15415 15415 D TSLocationManager: ╟─ desiredAccuracy: 20.0
04-01 13:03:50.534 15415 15415 D TSLocationManager: ╟─ meetsAccuracy: false
04-01 13:03:50.534 15415 15415 D TSLocationManager: ╟─ meetsStaleness: false
04-01 13:03:50.535 15415 15415 I TSLocationManager: [c.t.l.l.LocationAuthorization withPermission]
04-01 13:03:50.535 15415 15415 I TSLocationManager: 🔵 LocationAuthorization: Requesting permission
04-01 13:03:50.537 15415 15415 D TSLocationManager: [c.t.l.l.SingleLocationRequest trySatisfyLastLocation] 📍
04-01 13:03:50.537 15415 15415 D TSLocationManager: ╟─ age: 1179919ms
04-01 13:03:50.537 15415 15415 D TSLocationManager: ╟─ maximumAge: 0
04-01 13:03:50.537 15415 15415 D TSLocationManager: ╟─ desiredAccuracy: 500.0
04-01 13:03:50.537 15415 15415 D TSLocationManager: ╟─ meetsAccuracy: false
04-01 13:03:50.537 15415 15415 D TSLocationManager: ╟─ meetsStaleness: true
04-01 13:03:50.537 15415 15415 I TSLocationManager: [c.t.l.l.LocationAuthorization withPermission]
04-01 13:03:50.537 15415 15415 I TSLocationManager: 🔵 LocationAuthorization: Requesting permission
04-01 13:03:50.566 15415 15415 D TSLocationManager: [c.t.l.l.LifecycleManager d] ☯️ onWindowFocusChanged: false
04-01 13:03:50.567 15415 15415 I TSLocationManager: [c.t.l.s.TSScheduleManager oneShot]
04-01 13:03:50.567 15415 15415 I TSLocationManager: ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588)
04-01 13:03:51.244 15415 15415 D TSLocationManager: [c.t.l.l.LifecycleManager e] ☯️ onPause
04-01 13:03:51.500 15415 15463 I TSLocationManager: [c.t.l.http.HttpService flush]
04-01 13:03:51.500 15415 15463 I TSLocationManager: ╔═════════════════════════════════════════════
04-01 13:03:51.500 15415 15463 I TSLocationManager: ║ HTTP Service (count: 0)
04-01 13:03:51.500 15415 15463 I TSLocationManager: ╠═════════════════════════════════════════════
04-01 13:03:53.022 15415 15415 D TSLocationManager: [c.t.l.l.LifecycleManager f] ☯️ onResume
04-01 13:03:53.041 15415 15415 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:03:53.041 15415 15415 D TSLocationManager: 🎾 start [LocationRequestService startId: 1, eventCount: 1]
04-01 13:03:53.042 15415 15463 I TSLocationManager: [c.t.l.l.SingleLocationRequest startUpdatingLocation]
04-01 13:03:53.042 15415 15463 I TSLocationManager: 🔵 [SingleLocationRequest start, action: 1, requestId: 1]
04-01 13:03:53.044 15415 15463 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:03:53.044 15415 15463 D TSLocationManager: ⚙️︎ FINISH [LocationRequestService startId: 1, eventCount: 0, sticky: true]
04-01 13:03:53.050 15415 15415 D TSLocationManager: [c.t.l.l.LifecycleManager d] ☯️ onWindowFocusChanged: true
04-01 13:03:53.051 15415 15415 I TSLocationManager: [c.t.l.s.TSScheduleManager cancelOneShot]
04-01 13:03:53.051 15415 15415 I TSLocationManager: ⏰ Cancel OneShot: TERMINATE_EVENT
04-01 13:03:53.053 15415 15415 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:03:53.053 15415 15415 D TSLocationManager: 🎾 start [LocationRequestService startId: 2, eventCount: 1]
04-01 13:03:53.055 15415 15463 I TSLocationManager: [c.t.l.l.SingleLocationRequest startUpdatingLocation]
04-01 13:03:53.055 15415 15463 I TSLocationManager: 🔵 [SingleLocationRequest start, action: 2, requestId: 2]
04-01 13:03:53.056 15415 15463 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:03:53.056 15415 15463 D TSLocationManager: ⚙️︎ FINISH [LocationRequestService startId: 2, eventCount: 0, sticky: true]
04-01 13:03:58.983 15415 15415 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:03:58.983 15415 15415 D TSLocationManager: 🎾 2:2 [LocationRequestService startId: 3, eventCount: 1]
04-01 13:03:58.984 15415 15463 I TSLocationManager: [c.t.l.s.LocationRequestService b]
04-01 13:03:58.984 15415 15463 I TSLocationManager: ℹ️ Location availability: false
04-01 13:03:58.984 15415 15463 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:03:58.984 15415 15463 D TSLocationManager: ⚙️︎ FINISH [LocationRequestService startId: 3, eventCount: 0, sticky: true]
04-01 13:03:58.985 15415 15415 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:03:58.985 15415 15415 D TSLocationManager: 🎾 1:1 [LocationRequestService startId: 4, eventCount: 1]
04-01 13:03:58.985 15415 15463 I TSLocationManager: [c.t.l.s.LocationRequestService b]
04-01 13:03:58.985 15415 15463 I TSLocationManager: ℹ️ Location availability: false
04-01 13:03:58.985 15415 15463 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:03:58.985 15415 15463 D TSLocationManager: ⚙️︎ FINISH [LocationRequestService startId: 4, eventCount: 0, sticky: true]
04-01 13:04:50.515 15415 15415 W TSLocationManager: [c.t.l.l.SingleLocationRequest finish]
04-01 13:04:50.515 15415 15415 W TSLocationManager: ⚠️ 📍 SingleLocationRequest TIMEOUT: 2
04-01 13:04:50.516 15415 15415 W TSLocationManager: [c.t.l.l.TSLocationManager onLocationError]
04-01 13:04:50.516 15415 15415 W TSLocationManager: ⚠️ TSLocationManager received location error: 408
04-01 13:04:50.517 15415 15415 W TSLocationManager: [c.t.l.a.BackgroundGeolocation _onLocationError]
04-01 13:04:50.517 15415 15415 W TSLocationManager: ⚠️ Location error: 408
04-01 13:04:50.517 15415 15415 D TSLocationManager: [c.t.l.event.EventManager c] 🛜 ⚡️ locationerror
04-01 13:04:50.526 15415 15415 D TSLocationManager: [c.t.l.service.AbstractService b]
04-01 13:04:50.526 15415 15415 D TSLocationManager: 🎾 STOP [LocationRequestService startId: 5, eventCount: 1]
04-01 13:04:50.526 15415 15415 D TSLocationManager: [c.t.l.service.AbstractService a]
04-01 13:04:50.526 15415 15415 D TSLocationManager: ⚙️︎ FINISH [LocationRequestService startId: 5, eventCount: 0, sticky: false]
04-01 13:04:50.529 15415 15455 E ReactNativeJS: '[onLocation]: NO COORDS ', { error: 408 }
04-01 13:04:50.536 15415 15455 E ReactNativeJS: '[BackgroundGeolocation] init error:', { [Error: 408] nativeStackAndroid: [], userInfo: null, code: 'EUNSPECIFIED' }
04-01 13:04:50.734 15415 15415 D TSLocationManager: [c.t.l.service.AbstractService f]
04-01 13:04:50.734 15415 15415 D TSLocationManager: ⚙️︎ LocationRequestService.stopSelfResult(5): true
04-01 13:04:50.750 15415 15415 D TSLocationManager: [c.t.l.service.AbstractService onDestroy]
04-01 13:04:50.750 15415 15415 D TSLocationManager: 🔴 LocationRequestService stoppedReactions are currently unavailable