【发布时间】:2014-09-10 08:13:10
【问题描述】:
我正在开发一个帮助用户学习外语的应用程序。我们一直在使用 chrome 托管的应用程序 + 背景页面,该页面通过webkitNotifications.createNotification 发送通知(例如带有要学习单词的抽认卡)
但最近 chrome 已经建立了自己的丰富通知 api(这里是示例 github repo:https://github.com/GoogleChrome/chrome-app-samples/tree/master/rich-notifications),它不适用于 hosts_apps 并阻止 webkitNotifications
现在我负责解决这个问题,并创建新的应用程序,但新的通知 API 只能通过打包的应用程序和扩展程序使用。
到目前为止,我一直在使用打包的应用程序,但遇到了一个我无法通过的严重问题:chrome 打包的应用程序无法访问 chrome.cookies api,这是我获取自定义数据所需的每个用户的通知。
我的问题是:是否有可能在打包的应用程序中访问 cookies api?还有没有可能创建 LEGACY 打包应用程序(它似乎有我需要的两个 api)
这是我到目前为止所做的:
manifest.json
{
"name": "__APP__",
"description": "__DESC__",
"short_name": "__APPNAME__",
"version": "1.0",
"default_locale": "en",
"offline_enabled": false,
"app": {
"background": {
"scripts": ["main.js", "app.js"],
"persistent": true
}
},
"icons": {
"128": "icon_128.png"
},
"permissions": [
"notifications", "http://my.site.com/*"
],
"manifest_version": 2
}
main.js(它为我提供了与托管应用程序相同的行为)
chrome.app.runtime.onLaunched.addListener(function () {
window.open("http://my.site.com/");
});
app.js 是一个从我的服务器获取 json 数据并尝试创建通知的文件(此处不粘贴,因为它现在不相关)
【问题讨论】:
标签: google-chrome manifest hosted-app