Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
La recuperación de fondo de Expo se inicializa pero nunca se ejecuta

Mientras desarrollo mi aplicación nativa de reacción, necesito hacer una búsqueda periódica en segundo plano en otro servidor. Así que importo 2 clases de expo:

 import * as BackgroundFetch from 'expo-background-fetch'; import * as TaskManager from 'expo-task-manager';

e inicializar mi tarea de fondo:

 const fetchFunc = async () => { try{ console.log("Hi from fetch function !") return BackgroundFetch.BackgroundFetchResult.NoData; } catch(err) { return BackgroundFetch.BackgroundFetchResult.Failed; } }

Registre esta tarea:

 async function registerBackgroundFetchAsync() { try{ await BackgroundFetch.registerTaskAsync("func-fetch", { minimumInterval: 5, // 5 second }) console.log("background fetch enabled") } catch(err){ console.error(err); } }

y crea una función para ejecutarlos todos:

 async function initBackgroundFetch() { if(!TaskManager.isTaskDefined("func-fetch")){ TaskManager.defineTask("func-fetch", fetchFunc) } await registerBackgroundFetchAsync(); }

Ahora, trato de iniciarlo cuando mi componente está montado (uso class y typescript):

 class MainPage extends Component { componentDidMount() { initBackgroundFetch(); } . . . }

Pero en la salida de mi consola acabo de obtener la "búsqueda de fondo habilitada" del registro... Creo que mi initBackgroundFetch está en el lugar equivocado, pero no puedo encontrar dónde debo ponerlo.

PD: mis diagnósticos de exposición

 Expo CLI 5.0.3 environment info: System: OS: Linux 5.15 Kali GNU/Linux Rolling 2021.4 Shell: 5.8 - /usr/bin/zsh Binaries: Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node npm: 8.1.0 - ~/.nvm/versions/node/v14.16.1/bin/npm npmPackages: expo: ^43.0.3 => 43.0.3 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: expo-cli: 5.0.3 Expo Workflow: managed
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!