I am developing a mobile app for iOS and when testing it in my device I get that once I terminate it (with the red button after double click on home and long touch) and then open it again, it is still in the state it was when I decided to terminate it.
So my question is:
Can I refresh my app with javascript when it opens after termination? Which is the event I need to look for?
EDIT:
If I use the structure below, I get the PAUSE event to work but not the RESUME one…Why?
var app = {
ready: false,
initialize: function() {
this.bind();
},
bind: function() {
document.addEventListener('deviceready', this.deviceready, false);
},
deviceready: function() {
app.report('deviceready');
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
},
report: function(id) {
console.log("report:" + id);
}
};
function onPause() {
console.log("I've been paused");
}
function onResume() {
console.log("I've been resumed");
}
EDIT 2: Ok I solved it. It looks like when your device is plugged to the computer the RESUME event does not fire because when KILLING the app Xcode stops tasks, which will make the app to freeze. Then when opening back, the app is messed up and unresponsive.
Thanks for your help.
The edit above should work.
From what I can see in the PhoneGap documentation you may be able to use the resume event to refresh your app.
For example:
Take a look at http://docs.phonegap.com/en/2.3.0/cordova_events_events.md.html#resume
Note: I haven’t used PhoneGap and this isn’t tested by any means.