Red-Folder / bgs-core

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

Keep service and change page #66

Closed chlamy closed 7 years ago

chlamy commented 7 years ago

Hello,

I use this plugin on my app, it works when I call start function but when I change page the service is canceled.

I have this

function start() {
    service.getStatus(function(r){startService(r);}, function(e){handleError(e);});
}

function startService(data) {
   if (data.ServiceRunning) {
      enableTimer(data);
   } 
   else {
        service.startService(function(r){enableTimer(r);}, function(e){handleError(e);});
   }
}

function enableTimer(data) {
   if(data.TimerEnabled) {
        allDone();
   } 
   else {
        service.enableTimer(1, function(r){allDone(r);}, function(e){handleError(e);});
   }
}

function allDone() {
    setInterval(function(){showNotif();},5000);
}

Thanks.

Red-Folder commented 7 years ago

How do you know that the background service has been cancelled?

Note that nothing in JavaScript would continue to work between page changes (because the entire JavaScript environment is recreated). So the background service maybe working - you just can't see if because you are looking at JavaScript to monitor it

Red-Folder commented 7 years ago

Closing ... no response