question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Start in foreground and finish in background if app closed?

See original GitHub issue

I’m not sure if I’m missing something, but is it possible with this library to start a task in the foreground and finish it despite the app going to the background?

To give a more concrete example: I press ‘Send’ on an email—a process which in total takes a few seconds—but leave the app before it’s finished. I would like this process to continue and finish in the background after I have left the app.

There is a beginBackgroundTask which seems to be used for this exact scenario. However, as this is not implemented, I guess this is not within the scope of this plugin?

Thanks in advance, and thanks a lot for the work on this plugin!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alexandersandbergcommented, Sep 28, 2021

@jehartzog My issue is not the time limit, but rather the use case I explained in my first post.

I press ‘Send’ on an email—a process which in total takes a few seconds—but leave the app before it’s finished. I would like this process to continue and finish in the background after I have left the app.

I need the process to continue when the app goes to the background, not run periodic background fetches when the app is already in the background.

I managed to implement this with beginBackgroundTask by creating my own plugin and wrapping tasks that need to continue if the app is closed with beginBackgroundTask. Without this, the process (e.g. sending an email) is immediately canceled when the app goes to the background, and the email is not sent.

So the question is: is it possible to do this using react-native-background-fetch as well?

1reaction
jehartzogcommented, Sep 28, 2021

@alexandersandberg Looks like you still may only get 30 seconds when using that call: https://developer.apple.com/forums/thread/85066 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run code when Android app is closed/sent to background
To check if your application is sent to background, you can call this code on onPause() or onStop() on every activity in your...
Read more >
Restrictions on starting activities from the background
Note: For the purposes of starting activities, an app running a foreground service is still considered to be "in the background". This guide...
Read more >
Windows background apps and your privacy - Microsoft Support
Stop an app from running in the background · Select Start , then select Settings > Apps > Apps & features. · Scroll...
Read more >
Timer im background Task not possible? - Apple Developer
As Claude31 says, running timers in the background is tricky because, in general, the system will suspend your app shortly after it moves...
Read more >
Auto-Start Foreground Service in Android - Medium
This permission is required for running the foreground permission which tells that your app going to run the foreground service. If you want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found