React native 为什么世博会后台位置在5分钟后停止发送位置?

React native 为什么世博会后台位置在5分钟后停止发送位置?,react-native,expo,React Native,Expo,我在App.js中定义了任务,一切正常!但5分钟后,它停止发送位置,我不知道为什么。 我正在使用这个软件包: TaskManager.defineTask(位置任务名称,异步({data,error})=>{ console.log(“Esta entrando al任务”) 如果(错误){ console.log(错误) //发生错误-有关详细信息,请查看“Error.message”。 返回; } 如果(数据){ const{locations}=数据; 让getLastTime=等待Asy

我在App.js中定义了任务,一切正常!但5分钟后,它停止发送位置,我不知道为什么。 我正在使用这个软件包:

TaskManager.defineTask(位置任务名称,异步({data,error})=>{
console.log(“Esta entrando al任务”)
如果(错误){
console.log(错误)
//发生错误-有关详细信息,请查看“Error.message”。
返回;
}
如果(数据){
const{locations}=数据;
让getLastTime=等待AsyncStorage.getItem('lastTime');
如果(getLastTime){
让timeInterval=moment(new Date()).diff(getLastTime,'seconds'))
if(时间间隔{
等待AsyncStorage.setItem('lastTime',new Date().toString())
}).catch(错误=>{
console.log(错误)
console.log(“en-el任务”)
})
//对背景中捕获的位置执行一些操作
}
});
TaskManager.defineTask(LOCATION_TASK_NAME, async ({ data, error }) => {

  console.log("Esta entrando al task")
    if (error) {
        console.log(error)
      // Error occurred - check `error.message` for more details.
      return;
    }
    if (data) {
      const { locations } = data;
  

      let getLastTime = await AsyncStorage.getItem('lastTime');
 
      if(getLastTime){

        let timeInterval = moment(new Date()).diff(getLastTime,'seconds')

        if(timeInterval<=10) {
          return
        }
        
 
      }

     await LocationAPI.sendCurrentLocation(locations[0].coords).then(async res=>{
        await AsyncStorage.setItem('lastTime',  new Date().toString())
    

      }).catch(err=>{

      console.log(err)
      console.log("en el task")
      })


   
      // do something with the locations captured in the background
    }
  });