transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
655 stars 277 forks source link

Background fetch failing on Android #1347

Closed nanshaki closed 1 month ago

nanshaki commented 2 years ago

Your Environment


## Expected Behavior
App tracks in the background

## Actual Behavior
App stoops tracking and log shows that the url for background tracking is not found 

## Steps to Reproduce
1. Allow background (Always) on location to the app2. 
2. Shutdown the app 
3.  Move at least 200 Meters

## Context
<!--- What were you trying to do? -->

## Debug logs
<!-- include iOS / Android logs

-->
<details>
    <summary>Logs</summary>

```<!-- Syntax highlighting:  DO NOT REMOVE -->

christocracy commented 2 years ago

This is what your server said to the plugin:

[HttpService$i onResponse] ⚠️ Response: 401,

nanshaki commented 2 years ago

Hi Thank you for your response. However the server does not say this on IOS Same setup. Happens only in the background. In foreground the app tracks fine and url is found Any clues?

christocracy commented 2 years ago

The only reason your server would return 401 is that it's not satisfied with the provided auth credentials.

You should debug this at your server and log the provided credentials.

nanshaki commented 2 years ago

I am a little confused by the process on Android. Would you mind giving me a quick rundown on the process:

Why would the access token (Our authentication credential) be invalid on Android while it works fine on IOS

Thank you!

christocracy commented 2 years ago

You are placing your auth token in the http headers. Both iOS and Android operate identically.

Presumably, your server is not happy with that token associated with that particular device.

Query your server logs to find out why.

nanshaki commented 2 years ago

Hello again We think that we understand the issue on Android now better. We are using Access tokens and Refresh Tokens when the Access tokens expire within a set amount of time. However the onHTTP is not triggering and I see why that is from this post. https://github.com/transistorsoft/react-native-background-geolocation/issues/710

Android Headless Mode for Cordova https://github.com/transistorsoft/cordova-background-geolocation-lt/wiki/Android-Headless-Mode

christocracy commented 2 years ago

Why do you reference the React Native version? You are posting here on the Cordova version.

For Cordova, you must reference the Android Headless Mode in the Wiki here.

Cordova users must write their Android headless code using Java, unlike React Native which allows headless code to be written in Javascript.

Also search the API docs here for "Config.authorization".

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

github-actions[bot] commented 1 month ago

This issue was closed because it has been inactive for 14 days since being marked as stale.