Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background action working only for 30 second in iOS #2033

Closed
Skvitthani opened this issue May 24, 2024 · 4 comments
Closed

Background action working only for 30 second in iOS #2033

Skvitthani opened this issue May 24, 2024 · 4 comments
Labels

Comments

@Skvitthani
Copy link

Plugin version: 2.11.0
Platform: iOS
OS version: 14.4
Device manufacturer / model: Apple iPhone 12
React Native version: 0.72.7
Plugin config
BackgroundGeolocation.ready({
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 25,
stopTimeout: 10,
debug: false,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
stopOnTerminate: false,
startOnBoot: true,
url: "http://yourserver.com/locations",
batchSync: false,
autoSync: true,
disableMotionActivityUpdates : true,
headers: {
"X-FOO": "bar"
},
}, (state) => {
if (!state.enabled) {
BackgroundGeolocation.start(function() {
console.log("- Start success");
});
}
});

BackgroundGeolocation.onLocation(({ coords }) => {
  try {
    if (coords) {
      const { latitude, longitude} =
        coords;
        reduxActions.location.updateLocation(
          latitude,
          longitude,
        );
    }
  } catch (error: unknown) {
    console.log('error',error)
  }
});

export async function startLocationUpdateAsync() {
try {
await BackgroundService.start(veryIntensiveTask, options);
} catch (error) {
console.log('ERROR :: startLocationUpdateAsync :: ', error)
}
}

const veryIntensiveTask = async (taskDataArguments: any) => {
await new Promise(async resolve => {
try{
if(Platform.OS == 'ios'){
BackgroundGeolocation.ready({
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 25,
stopTimeout: 10,
debug: false,
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
stopOnTerminate: false,
startOnBoot: true,
url: "http://yourserver.com/locations",
batchSync: false,
autoSync: true,
disableMotionActivityUpdates : true,
headers: {
"X-FOO": "bar"
},
}, (state) => {
if (!state.enabled) {
BackgroundGeolocation.start(function() {
console.log("- Start success");
});
}
});

BackgroundGeolocation.onLocation(({ coords }) => {
  try {
    if (coords) {
      const { latitude, longitude} =
        coords;
        reduxActions.location.updateLocation(
          latitude,
          longitude,
        );
    }
  } catch (error: unknown) {
    console.log('error',error)
  }
});

}else{
Geolocation.watchPosition(
(location: any)=> {
reduxActions.location.updateLocation(
location.coords.latitude,
location.coords.longitude,
);
},
error => {},
{
enableHighAccuracy: false,
maximumAge: 0,
distanceFilter: 30,
},
);
}
}catch(e){console.log('e',e)}
})
};

Expected Behavior

It Should work in the background until the app gets killed in iOS only.

Actual Behavior

It works only for 30 seconds in the background.

@christocracy
Copy link
Member

@christocracy
Copy link
Member

Also, when testing, go outside for a walk with a real device for at least 1km.

see wiki “Philosophy of Operation” and “Debugging”.

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jun 24, 2024
Copy link

github-actions bot commented Jul 8, 2024

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

@github-actions github-actions bot closed this as completed Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants