如何导致Chrome应用尽快更新?

编程入门 行业动态 更新时间:2024-10-23 03:33:42
本文介绍了如何导致Chrome应用尽快更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

部署chrome打包的应用程序并在chrome网站商店上发布更新可让用户自动接收应用程序更新.在某些情况下,您想知道正在运行的应用程序是否最新,然后进行更新.例如:

Deploying a chrome packaged app and publishing updates on the chrome web store allows users to automatically receive application updates. There are situations where you want to know if the running application is the most current or not, and updating it. E.G.:

  • 仅使用户保持最新版本即可.
  • 检测应用程序和服务器端API之间的不匹配,并要求客户端应用程序进行更新以使用新的服务器端API.

chrome.runtime.requestUpdateCheck()的文档提供了状态"throttled","no_update","update_available"的值,但是没有指出需要更新版本时该怎么做.

Documentation for chrome.runtime.requestUpdateCheck() offers a status of "throttled", "no_update", "update_available", but doesn't indicate what to do if a newer version is required.

推荐答案

为chrome.runtime.onUpdateAvailable安装侦听器,该侦听器在下载新的.crx文件并准备好安装新版本时触发.然后,调用chrome.runtime.requestUpdateCheck:

Install a listener for chrome.runtime.onUpdateAvailable, which fires when the new .crx file has been downloaded and the new version is ready to be installed. Then, call chrome.runtime.requestUpdateCheck:

chrome.runtime.onUpdateAvailable.addListener(function(details) { console.log("updating to version " + details.version); chrome.runtime.reload(); }); chrome.runtime.requestUpdateCheck(function(status) { if (status == "update_available") { console.log("update pending..."); } else if (status == "no_update") { console.log("no update found"); } else if (status == "throttled") { console.log("Oops, I'm asking too frequently - I need to back off."); } });

更多推荐

如何导致Chrome应用尽快更新?

本文发布于:2023-11-29 23:15:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647926.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Chrome

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!