在后台运行科尔多瓦应用 [英] Run application in background Cordova

查看:216
本文介绍了在后台运行科尔多瓦应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发外部服务器发送数据(登记和图像)一科尔多瓦的应用程序,它已经工作,但要使其如果用户在注册时没有互联网,应用程序运行在后台等待着互联网连接发送数据时,如何做到这一点?

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?

推荐答案

使用这个插件

   cordova plugin add cordova-plugin-network-information

和CAL您code在这个回调函数

and cal your code in this callback function

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

function onOnline() {
// Handle the online event
 }

它会自动运行您code时可用互联网将

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

这篇关于在后台运行科尔多瓦应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆