새 chrome.notifications
API를 사용하여 내 확장 프로그램에서 표시 할 알림을받을 수 없습니다. 가장 기본적인 알림조차도 나에게 나타나지 않지만 오류가 발생하지 않고 콜백 함수가 제대로 실행됩니다.
{
"name": "notify",
"version": "0.0.0",
"manifest_version": 2,
"permissions": [
"notifications"
],
"background": {
"scripts": ["main.js"]
}
}
window.addEventListener('load', function() {
var opt = {
type: 'list',
title: 'Primary Title',
message: 'Primary message to display',
priority: 1,
items: [{ title: 'Item1', message: 'This is item 1.'},
{ title: 'Item2', message: 'This is item 2.'},
{ title: 'Item3', message: 'This is item 3.'}]
};
chrome.notifications.create('notify1', opt, function() { console.log('created!'); });
});
배경 페이지를 살펴보면 "만들었습니다!" 콘솔에 있지만 데스크톱에 알림이 표시되지 않습니다. 나는 소용이없는 여러 가지 우선 순위 값을 시도했습니다. 내가 무엇을 잘못하고 있지?
불행히도 chrome.notifications에 대한 자세한 오류 메시지는 아직 진단하지 않은 버그로 인해 콘솔에서 표시되지 않습니다. 알림이 표시되지 않는 이유는 필수 "iconUrl"매개 변수를 제공하지 않기 때문입니다. 내가 설치 한 확장 프로그램의 배경 페이지에서 다음을 시도했을 때 :
var opt = {
iconUrl: "http://www.google.com/favicon.ico",
type: 'list',
title: 'Primary Title',
message: 'Primary message to display',
priority: 1,
items: [{ title: 'Item1', message: 'This is item 1.'},
{ title: 'Item2', message: 'This is item 2.'},
{ title: 'Item3', message: 'This is item 3.'}]
};
chrome.notifications.create('notify1', opt, function() { console.log('created!'); });
알림이 성공적으로 생성됩니다. chrome.runtime.lastError를 확인하는 것이 좋습니다.
var opt = {
type: 'list',
title: 'Primary Title',
message: 'Primary message to display',
priority: 1,
items: [{ title: 'Item1', message: 'This is item 1.'},
{ title: 'Item2', message: 'This is item 2.'},
{ title: 'Item3', message: 'This is item 3.'}]
};
chrome.notifications.create('notify1', opt, function(id) { console.log("Last error:", chrome.runtime.lastError); });
실제로 필요한 속성이 있고 하나가 누락되었음을 보여 주었을 것입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다