# Schedule background task

**URL:** <https://forum.ionicframework.com/t/schedule-background-task/26975>\
**Category:** cordova\
**Created:** [June 23, 2015, 10:06am UTC](https://forum.ionicframework.com/t/schedule-background-task/26975 "2015-06-23T10:06:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MisterJack49](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/misterjack49/32/81354_2.png) [@MisterJack49](https://forum.ionicframework.com/u/MisterJack49)\
**Post date:** [June 23, 2015, 10:06am UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/1 "2015-06-23T10:06:10Z")

</div>

Hi,  
I’d like to call a service function daily to keep data up to date, is there a way to launch such task in background ?  
I thought to use localNotification to do so, is it the right way ?

Regards

---

<div class="post-metadata">

**Author:** ![MisterJack49](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/misterjack49/32/81354_2.png) [@MisterJack49](https://forum.ionicframework.com/u/MisterJack49)\
**Post date:** [July 6, 2015, 12:28pm UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/2 "2015-07-06T12:28:18Z")

</div>

Hi,

Any ideas ?

Thanks

---

<div class="post-metadata">

**Author:** ![boltex](https://avatars.discourse-cdn.com/v4/letter/b/ba9def/32.png) [@boltex](https://forum.ionicframework.com/u/boltex)\
**Post date:** [July 6, 2015, 1:43pm UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/3 "2015-07-06T13:43:38Z")

</div>

[http://forum.ionicframework.com/t/did-you-ever-found-a-solution-for-some-regular-background-activity/25843](http://forum.ionicframework.com/t/did-you-ever-found-a-solution-for-some-regular-background-activity/25843)

---

<div class="post-metadata">

**Author:** ![MisterJack49](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/misterjack49/32/81354_2.png) [@MisterJack49](https://forum.ionicframework.com/u/MisterJack49)\
**Post date:** [July 6, 2015, 2:08pm UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/4 "2015-07-06T14:08:49Z")

</div>

Hi,

thanks but the topic is private, i can’t access it.

---

<div class="post-metadata">

**Author:** ![boltex](https://avatars.discourse-cdn.com/v4/letter/b/ba9def/32.png) [@boltex](https://forum.ionicframework.com/u/boltex)\
**Post date:** [July 6, 2015, 3:13pm UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/5 "2015-07-06T15:13:37Z")

</div>

on android: same as many other problems: only active while plugged in (or when the app is in the foreground)… without a partial wakelock!

So I made my own solution, [https://github.com/boltex/cordova-plugin-powermanagement](https://github.com/boltex/cordova-plugin-powermanagement)

I modified the power management plugin : I changed SCREEN\_DIM\_WAKE\_LOCK to PARTIAL\_WAKE\_LOCK

here’s how i use it along with the background mode plugin so the app is never in bakcground and always running as a service…:

if( ionic.Platform.isAndroid() ){  
cordova.plugins.backgroundMode.enable();

window.powerManagement.dim(function() {  
console.log(‘Wakelock acquired’);  
}, function() {  
console.log(‘Failed to acquire wakelock’);  
});  
window.powerManagement.setReleaseOnPause(false, function() {  
console.log(‘setReleaseOnPause successfully’);  
}, function() {  
console.log(‘Failed to set’);  
});

}

---

<div class="post-metadata">

**Author:** ![KanyiJames](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@KanyiJames](https://forum.ionicframework.com/u/KanyiJames)\
**Post date:** [January 13, 2017, 6:28am UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/6 "2017-01-13T06:28:58Z")

</div>

Hi. How did you get to access this link? Thanks

---

<div class="post-metadata">

**Author:** ![KanyiJames](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@KanyiJames](https://forum.ionicframework.com/u/KanyiJames)\
**Post date:** [January 13, 2017, 6:29am UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/7 "2017-01-13T06:29:32Z")

</div>

How can I access this link? Thanks

---

<div class="post-metadata">

**Author:** ![boltex](https://avatars.discourse-cdn.com/v4/letter/b/ba9def/32.png) [@boltex](https://forum.ionicframework.com/u/boltex)\
**Post date:** [January 13, 2017, 2:54pm UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/8 "2017-01-13T14:54:19Z")

</div>

it’s what i posted on july 15. copy pasted as-is. again , just look at [https://github.com/boltex/cordova-plugin-powermanagement](https://github.com/boltex/cordova-plugin-powermanagement)

---

<div class="post-metadata">

**Author:** ![pimol](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@pimol](https://forum.ionicframework.com/u/pimol)\
**Post date:** [July 3, 2019, 3:15pm UTC](https://forum.ionicframework.com/t/schedule-background-task/26975/9 "2019-07-03T15:15:37Z")

</div>

Thanks a lot, @boltex, it seem really a solution.
