2021-12-16
1470
#react native
Debjyoti Banerjee
83010
Dec 16, 2021 â‹… 5 min read

Run React Native background tasks with Headless JS

Debjyoti Banerjee I'm Debjyoti, software engineer and game developer. Currently exploring JavaScript and Flutter, and trying to come up with solutions to problems in the healthcare sector. Love open source.

Recent posts:

Rust logo over black marble background.

Handling memory leaks in Rust

Learn how to manage memory leaks in Rust, avoid unsafe behavior, and use tools like weak references to ensure efficient programs.

Ukeje Goodness
Nov 20, 2024 â‹… 4 min read
Robot pretending to be a person.

Using curl-impersonate in Node.js to avoid blocks

Bypass anti-bot measures in Node.js with curl-impersonate. Learn how it mimics browsers to overcome bot detection for web scraping.

Antonello Zanini
Nov 20, 2024 â‹… 13 min read
Solving Eventual Consistency In Frontend

Solving eventual consistency in frontend

Handle frontend data discrepancies with eventual consistency using WebSockets, Docker Compose, and practical code examples.

Kayode Adeniyi
Nov 19, 2024 â‹… 6 min read
How To Use Lazy Initialization Pattern With Rust 1.80

How to use the lazy initialization pattern with Rust 1.80

Efficient initializing is crucial to smooth-running websites. One way to optimize that process is through lazy initialization in Rust 1.80.

Yashodhan Joshi
Nov 18, 2024 â‹… 5 min read
View all posts

11 Replies to "Run React Native background tasks with Headless JS"

  1. Where is the BackgroundWorker function created? Are you able to provide a sample of the project structure?

  2. please add import statements of classes. or provide the sample example repo link. android studio not importing automatically.

    1. I’m not aware of your requirements but according to the Android docs, it recommends high priority FCM messages as they are exempt from background restrictions.
      Also, you could try updating your app logic to do something in the work manager but not start a foreground service.
      You could also look into AlarmManager if that suits your use case.

  3. The lack of import statements makes this an hours-long task to reproduce. On top of that, there’s several functions here that just… don’t exist. `bundleExtras` and createChannel` are completely undefined and I can’t find anything online to replace them with or import them from. Kind of useless

    1. Intent service = new Intent(getApplicationContext(), MyTaskService.class);
      Bundle bundle = new Bundle();

      bundle.putString(“foo”, “bar”);
      service.putExtras(bundle);

      getApplicationContext().startService(service);

  4. Headless keeps the task running even when the app gets killed. How can we handle to stop the services when the app gets killed or removed from background?

  5. App is Closing when in background after approximate 3 minutes.
    —————————- PROCESS ENDED (24480) for package com.example.app—————————-
    Got this log in android studio’s logcat. How can i make it stays running even when the app is in background mode?

Leave a Reply