如何检查Google Chrome扩展程序是否需要更新? [英] How do I check if a Google Chrome Extension needs to be updated?

查看:379
本文介绍了如何检查Google Chrome扩展程序是否需要更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在网上商店中托管的扩展程序,当我推送更新时,Google会自动更新用户的扩展程序,但存在延迟(几个小时)。

有没有扩展的方法来检测是否有新的更新尚未应用?最简单的方法是以某种方式查询webstore上的当前版本并将其与安装的版本进行比较,我想知道API中是否有任何内容。

我知道chrome.app.getDetails()。版本为我提供了当前安装的版本,但是有没有获取当前网络商店版本的方法?在最糟糕的情况下,我可以为我的扩展Web商店页面发出一个http get,并从那里提取版本,但这似乎是超级哈希,所以我'd更喜欢不这样做。 您错过了它,它位于 chrome中。运行时 API:




















<请注意,服务器可能会限制您的请求。请注意,服务器可能会限制您的请求。请求更新检查此应用程序/扩展。如果发生这种情况,你应该检查它在回调中的响应并减少你的请求频率。



如果你想要更积极主动, href =https://developer.chrome.com/extensions/gcm =nofollow>推送通知进行更新检查。这可能是矫枉过正的 - 考虑到网上商店运行自动检查更新,发布后可以持续长达一个小时。


I know for extensions hosted on the webstore, when I push updates Google will automatically update the extensions of users but there is a lag (couple of hours).

Is there a way for the extension to detect if there is a new update that hasn't been applied? The easiest way to do this would be to somehow query for the current version on the webstore and compare it to the installed version and I was wondering if there was anything in the API for this.

I know that chrome.app.getDetails().version gives me the current installed version but is there a way to get the current web store version? Thanks.

In the worst case, I could issue an http get for my extensions web store page and extract the version out from there but that seems to be super hacky so I'd prefer not to do it this way.

解决方案

You missed it, it's in the chrome.runtime API:

chrome.runtime.requestUpdateCheck(function callback)

Requests an update check for this app/extension.

Do note that the server may throttle your requests. You are supposed to check for its response in the callback and reduce your request frequency if that happens.

If you want to be even more proactive about that, you could implement push notifications for your update check. That's probably overkill, though - considering Web Store runs automated checks on updates that can last up to an hour anyway after you publish.

这篇关于如何检查Google Chrome扩展程序是否需要更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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