Run application in background Cordova

你。 提交于 2020-01-15 06:19:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!