GitHub user breautek added a comment to the discussion: Cordova Plugin 
Background Mode - Cordova 12

Just to give you an answer, I don't use any "background modes" but I can give 
some insight on why there might be a lack of a response or lack of available 
(or perhaps working) plugins.

Depending on what you want to do, running background JS tasks may not be 
possible or reliable.

On iOS for example, WKWebView does not process any JS events (the engine itself 
is effectively paused) while the app is in the background. Android does allow 
backgound processing of the webview however it's not guarenteed. Depending on 
the vendor and device's available resources the OS may restrict processing time 
of the application when it's in in the background, or the OS may even kill it. 
On Android, allowing background JS execution in the webview is more of a 
request and if the user is using another resource-expensive app, the OS will 
likely not give your app any CPU time.

In native programming, android and iOS has special constructs that allows you 
to run background tasks on behalf of an application, that can run independently 
of your application process, even if the process was killed or closed. These 
constructs however tends to have limitations, like not having access to the UI, 
which the webview requires. 

In theory, it is possible to launch a background JS environment that is 
external the webview (known as `JavaScriptCore` which I believe can be ran as a 
background task, but the Cordova API won't be supported in this kind of 
environment, so functionality may be limited. Depending on your requirements, 
it might be necessary to build an application-specific plugin that imports 
native code to register the background tasks and also handles the business 
logic of that task.

GitHub link: 
https://github.com/apache/cordova/discussions/465#discussioncomment-8249054

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to