简体   繁体   English

如果没有互联网连接(PhoneGap),如何显示消息/图片警报?

[英]How to display a message/picture alert if there is no internet connection (PhoneGap)?

Problems (PhoneGap): 问题(PhoneGap):

  1. How to display a message/picture alert if there is no internet connection? 如果没有互联网连接,如何显示消息/图片警报?
  2. How to prevent user to use/fully open the application after the alert (quit the application and display alerts later until user connects to the Internet)? 警报后如何防止用户使用/完全打开应用程序(退出应用程序并稍后显示警报,直到用户连接到Internet)?

Thank you in advance. 先感谢您。

There's Phonegap documentation on this here . 有PhoneGap的文档在这个位置 It discusses creating an 'alert' for various connection states. 它讨论了为各种连接状态创建“警报”。

I don't have much experience on platforms other than Android, but if you use the Phonegap database feature , data storage is persistant within a table if the app is 'force closed' or simply suspended. 我在Android以外的平台上没有太多经验,但是如果您使用Phonegap 数据库功能 ,则在应用程序“强制关闭”或只是暂停的情况下,数据存储可持久保存在表中。

To achieve what you're looking for, I would create a very simple table with a boolean value corresponding to whether there is network availability, which is updated through a function call based around timed javascript functions . 为了实现您的期望,我将创建一个非常简单的表,该表具有一个布尔值,该值对应于是否存在网络可用性,该值通过基于计时javascript函数的函数调用进行更新。 A simple if(){} statement can then check the database value and either limit or enable functionality in the app. 然后,一个简单的if(){}语句可以检查数据库值,并限制或启用应用程序中的功能。

Depending on how persistant you want the data to be, you could also do away with the database and just make a timed call to return the network status. 根据所需数据的持久性,您也可以删除数据库,而只需进行定时调用以返回网络状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM