在后台Cordova中运行应用程序

Vin*_*Vaz 2 mobile android phonegap-plugins cordova cordova-plugins

我正在开发一个为外部服务器发送数据(注册和图像)的Cordova应用程序,它已经正常工作但是如果用户在注册时没有互联网,应用程序正在后台运行等待互联网连接发送数据,怎么办?

Ass*_*sad 5

使用此插件

   cordova plugin add cordova-plugin-network-information
Run Code Online (Sandbox Code Playgroud)

并在此回调函数中调用您的代码

document.addEventListener("online", onOnline, false);

function onOnline() {
// Handle the online event
 }
Run Code Online (Sandbox Code Playgroud)

当互联网可用时,它会自动运行您的代码

另一种方式是实现后台服务,但这是简单而好的方式

https://github.com/apache/cordova-plugin-network-information