Red-Folder / bgs-core

Core code for the Cordova Background Service
Other
236 stars 105 forks source link

Cannot run setConfiguration on service if it's not started #71

Closed scarabdesign closed 7 years ago

scarabdesign commented 7 years ago

The idea is to set the configuration object to my custom service before it starts so that when it starts it has the correct config already. That does not seem possible because I get the error INVALID_ACTION when trying to run setConfiguration before the service is started. Is there a reason for this?

Red-Folder commented 7 years ago

As the code is written, yes the service needs to have been started. Note that the timer doesn't have to be enabled.

As the service is responsible for its own configuration persistence, then the service (think of this as a separate app) needs to be running (started).

From what you describe, you want to:

An alternative would be for you write some other persistence mechanism for the config which you populate prior to starting the service, then get the service to read from that on start. You'd probably want to create your own plugin to set that config (maybe save to SQLite db or similar).

scarabdesign commented 7 years ago

Ok, thank you.