我可以在我的Chrome通知创建方法中插入json文件中的值吗?我想从json文件中获取图标和内容
答案 0 :(得分:0)
首先,您需要在manifest.json中添加权限:
"permissions": [ "storage", "history", "notifications" ],
我假设你有这样的json:
var noti = {
"iconUrl":"logo.png",
"title":"Frst Notification",
"message":"This is a chrome extension notification"
};
使用此简单代码创建通知。
chrome.notifications.create('Notifiy-1', {
type: 'basic',
iconUrl: noti.iconUrl,
title: noti.title,
message: noti.message
}, function(notificationId) {});