我正在开发一个帮助用户学习外语的应用程序。我们一直在使用 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)
这是我到目前为止所做的事情:
清单.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 数据并尝试创建通知的文件(不粘贴在这里,因为它现在不相关)