Open Rajam0310 opened 1 year ago
With WhenInUse
authorization, you must manually toggle the plugin into the "tracking" state while your app is in the foreground, like a Jogging App, where the user clicks a [Start Workout]
button.
the method to manually toggle location-tracking ON is BackgroundGeolocation.changePace(true)
. See the api docs.
Apps cannot automatically trigger location tracking in the background with WhenInUse
authorization, when the device is detected to be moving.
We are getting these kind of ANR error from firebase console while detecting background geo-location, and then user not able to receive push notifications from firebase.
Here is the error log from firebase console: [com.transistorsoft.locationmanager.notification.TSLocalNotification.build] [ANR triggered by thread waiting for a binder transaction]
ActivityThread$H.handleMessage Fatal Exception: android.app.RemoteServiceException Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{ba356a5 u0 mybundleId/com.transistorsoft.locationmanager.service.LocationRequestService}
Context.startForegroundService() did not then call Service.startForeground():
This is a very common Android ANR. [Google it](https://www.google.com/search?q=Context.startForegroundService()+did+not+then+call+Service.startForeground()%3A&oq=Context.startForegroundService()+did+not+then+call+Service.startForeground()%3A&aqs=chrome..69i57j0i512j0i22i30l5.446j0j4&sourceid=chrome&ie=UTF-8).
An Android Foreground-service (which this plugin makes use of), must call .startForeground()
within 5 seconds of your app launching. If your own app code (or one of your other plugins) does too much processing on the Main Thread (eg: loading records from a database, long-running http request, etc), this prevents the plugin's foreground-services from calling .startForeground()
before 5 seconds elapses.
It's your responsibility to determine what in your app is taking too much time on the Main Thread, preventing the plugin from calling .startForeground()
in time.
You can determine what is consuming time on the Main Thread by implementing Android StrictMode
in the Cordova java app Application.onCreate
method.
This is not an easy task to do in a Cordova app. It is much easier to do this sort of thing with Capacitor, React Native and Flutter.
We are getting these kind of ANR error from firebase console while detecting background geo-location, and then user not able to receive push notifications from firebase
Yes, I answered your question about this above. Implement StrictMode
in your app and observe StrictMode
violations in adb logcat
when your app boots.
This issue is stale because it has been open for 30 days with no activity.
Your Environment
cordova -v
): 11.1.0cordova platform ls
): 10.1.2#ready
:await BackgroundGeolocation.ready({ stationaryRadius: 2, distanceFilter: 3, debug: false, stopOnTerminate: true, locationAuthorizationRequest: 'WhenInUse', notification: { title: "GPS Tracking", text: "Live Location Sharing" }, backgroundPermissionRationale: { title: "Allow this app to access to this device's location in the background?", message: "In order to track your activity in the background, please enable Allow all the time location permission", } })
Expected Behavior
Location should be detected while app is running in background even when we doesn't select "Allow All The Time" in location permission. Is it possible ?
Actual Behavior
Location is not detected while app is running in background even when we doesn't select "Allow All The Time" in location permission.