问题
I'm developing a Cordova application that sends data (registration and image) for external server, it is already working but would like to make it if the user has no internet at registration, the application is running in background waiting for internet connection to send data, how to do this?
回答1:
Use this plugin
cordova plugin add cordova-plugin-network-information
and cal your code in this callback function
document.addEventListener("online", onOnline, false);
function onOnline() {
// Handle the online event
}
It will automatically run your code when internet will available
other way is to implement background service but this is simple and nice way
https://github.com/apache/cordova-plugin-network-information
来源:https://stackoverflow.com/questions/30037529/run-application-in-background-cordova