You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/06/05 12:24:52 UTC

[GitHub] [cordova] dariosalvi78 opened a new issue #120: Run background jobs

dariosalvi78 opened a new issue #120: Run background jobs
URL: https://github.com/apache/cordova/issues/120
 
 
   # Feature Request
   
   ## Motivation Behind Feature
   Currently, there is no way to schedule code execution in the background in Cordova apps.
   Android supports this through [jobs](https://www.vogella.com/tutorials/AndroidTaskScheduling/article.html) and iOS [is going to support this functionality too](https://developer.apple.com/documentation/backgroundtasks) soon.
   In browsers, one could use service workers (which are not available in Webviews) and in desktops, one could use other native systems ([Windows](https://docs.microsoft.com/en-us/windows/desktop/taskschd/task-scheduler-start-page) and [MacOS](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html))
   
   ## Feature Description
   The feature would allow to schedule future execution of JS code, in background, while having access to global variables and plugins, like it was running on the webview, but without access to the DOM.
   An example of the code could be:
   
   ```js
   cordova.backgroundSchedule({
     requiresNetwork: true,
     requiresExternalPower: false,
     when: new Date() // some time in the future
     }, function () {
     // my code here has access to the plugins
   })
   ```
   
   
   
   ## Alternatives or Workarounds
   I don't know if this idea would fit better as a new plugin or as a platform-wise feature.
   
   Running JS code in iOS outside of the Webview is possible through the [JavaScriptCore](https://developer.apple.com/documentation/javascriptcore), while in Android, there are [a bunch of alternatives](https://medium.com/tech-quizlet/comparison-shopping-searching-for-javascript-engines-for-android-bdc656538f2e).
   Same applies for Desktop ([Windows](https://stackoverflow.com/questions/5742128/javascript-standalone-compiler-or-interpreter-for-windows) and [MacOS](https://developer.apple.com/documentation/javascriptcore)).
   
   Currently, the only way to execute background code is through [this plugin](https://github.com/katzer/cordova-plugin-background-mode), but it comes with limitations (e.g. execution cannot be scheduled).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org