免責聲明:我不是一個Chrome開發者。
根據文檔,notifications.create方法需要在對象中提供幾個選項,第一個參數是通知的ID。
function notify(title, callback) {
var options = {
title: title,
message: "Message goes here"
type: "basic", // Which type of notification to display - https://developer.chrome.com/extensions/notifications#type-TemplateType
iconUrl: "someimage.jpg" // A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
};
// The first argument is the ID, if left blank it'll be automatically generated.
// The second argument is an object of options. More here: https://developer.chrome.com/extensions/notifications#type-NotificationOptions
return chrome.notifications.create("", options, callback);
}
notify("Testing", function(notification){
// Do whatever you want. Called after notification is created.
});
編輯:競猜需要,那麼所有的參數。上面更新的代碼。這對於簡單的通知應該可以正常工作,但是當你開始做任何先進的事情時,你應該read the docs。
您沒有足夠接近創建方法。文檔實際上非常清晰和簡潔。你看這裏? https://developer.chrome.com/extensions/notifications#method-create – Antiga 2014-08-31 04:19:40