Chrome pushmessaging api 向后兼容性

Chrome pushmessaging apis backward compatibility

一年前,我使用以下 apis 启用 chrome 推送消息(现在是 gcm)从服务器发送 gcm 消息。

那些api现在好像完全坏掉了

chrome.pushMessaging.getChannelId(function(google_chrome_channel_id){})

使用上述函数报错

TypeError: Cannot read property 'getChannelId' of undefined

chrome GCM apis 已根据此文档更改 https://developers.google.com/cloud-messaging/chrome/client

这些 api 是否有任何解决方法,或者我是否应该根据新的 api 重写应用程序的某些部分?

旧的 API 是 deprecated in May 2014。强调我的:

Developers will start to see a deprecation message in the console if they use chrome.pushMessaging, and no new Chrome apps and extensions will be accepted to the Chrome Web Store if they use the deprecated API. Beginning in mid-January 2015, Chrome apps and extensions that continue to use chrome.pushMessaging will be delisted in the Chrome Web Store. When upgraded to use chrome.gcm, these apps will once again be discoverable via searching and browsing the Web Store. In early March, the chrome.pushMessaging API will be removed and all Chrome apps and extensions that continue to reference it will be automatically disabled. They can be enabled once again when upgraded to use chrome.gcm.

到现在为止,它的文档甚至都不存在了。

所以是的,您别无选择,您需要迁移到 chrome.gcm