我正在开发一个 Cordova 应用程序,该应用程序向外部服务器发送数据(注册和图像),它已经可以工作,但如果用户在注册时没有互联网,该应用程序正在后台运行等待互联网,那么我想这样做连接发送数据,怎么做?
最佳答案
使用这个插件
cordova plugin add cordova-plugin-network-information
并在此回调函数中调用您的代码
document.addEventListener("online", onOnline, false);
function onOnline() {
// Handle the online event
}
当互联网可用时,它将自动运行您的代码
另一种方法是实现后台服务,但这是简单又好的方法
https://github.com/apache/cordova-plugin-network-information
关于android - 在后台运行应用程序 Cordova,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30037529/