2
我的瀏覽器擴展程序不斷拋出一個錯誤,這個功能Chrome擴展程序 - GCM通知會引發錯誤,但信息在那裏?
function messageReceived(message) {
// A message is an object with a data property that
// consists of key-value pairs.
// Pop up a notification to show the GCM message.
chrome.notifications.create(getNotificationId(), {
title: message.data.name,
iconUrl: 'assets/img/cat.jpg',
type: 'basic',
message: message.data.prompt,
buttons : [
{ title: "Accept" },
{ title: "Reject" }
]
}, function() {});
}
錯誤:
Unchecked runtime.lastError while running notifications.create: Some of the required properties are missing: type, iconUrl, title and message. at messageReceived
然而,所有這些都是實際存在的。錯誤到達每次我添加以下功能
function notificationBtnClicked(notification, ibtn) {
console.log(notification)
console.log(ibtn)
if (ibtn==0) {
chrome.storage.local.get("name", function(name){
chrome.storage.local.get("email",function(email){
//call other users
var email = email
var name = name
$.ajax({
url: 'some api',
data:'{email:email, name:name}',
ajax:true,
success: function(result)
{
alert(result);
}
});
});
})
}else {
//snooze
}
}
但是,我不明白是什麼問題。我通過下載一些chrome擴展來檢查chrome.storage,它允許你查看它和它的存在。
爲什麼錯誤不正確? :/
chrome.gcm.onMessage.addListener(messageReceived);
chrome.notifications.onButtonClicked.addListener(notificationBtnClicked);
嗨@Newbie。你有沒有想過這個?我有同樣的問題! – Nathan