|Service||Code (AppBuilder), Telerik Platform General|
|Mobile development type||Hybrid (Apache Cordova app)|
Your app needs to execute tasks on specified intervals when running in the background.
Given the differences in the means iOS and Android are granting to apps for working in the background there may be different approaches to do so. You will usually need a Apache Cordova plugin to register and execute your code in the background and ensure that the strict requirements and guidelines of the respective OS are met.
iOS has a set of defined modes for background activities which your app should specify to be allowed to run tasks in the background while the app is suspended (for example, playing audio, tracking location, etc.). You can read more about the subject in App Programming Guide for iOS — Background Execution. The supported modes are listed the
UIBackgroundModes section here.
On Android this can be done via a plugin that is registering a service implemented with native code. A popular option for Android in the community is the Cordova Background Plugin (while it may not be compatible with the App Store requirements for using background modes).
Even that the app is allowed to run in the background the OS may determine that the background tasks are too intensive, frequent or battery-heavy and interrupt them. Ensure that you are using the correct plugin and native code implementation and required configuration for your task if you need to run a background task.
In many cases it may be sufficient to run your code using the application life-cycle events when the app is paused or resumed, or use push notifications or local notifications for the purpose.
Community plugins may not be compatible with the vendor stores and requirements for background execution. Consult the respective plugin and functionality documentation and the purpose of the plugin beforehand.