2014-06-13 2 views
1

원본 알림 샘플을 수정하려고 시도했지만 이전 webit 알림이 더 이상 작동하지 않는 것으로 나타났습니다. 그래서 크롬 알림으로 변경되었습니다. 기본적으로, 나는 여전히이 같은 배경 페이지를 재사용 :크롬 확장 : 배경 스크립트에서 바탕 화면 알림

"permissions": [ 
    "notifications", 
    "http://*/*" 
    ], 
    "options_page": "options.html", 
    "background": { "scripts": ["background.js"], "persistent": false }, 

에 해당하는 경우에는 background.js 그냥 이렇게 있습니다 : 뭔가 권리가 구성되지 않은 내가 알림을 볼 수 없습니다처럼

console.log("Before create " + notID + " notification"); 
chrome.notifications.create("id"+notID++, options, creationCallback); 


function creationCallback(ID) { 
    console.log("Succesfully created " + ID + " notification"); 
} 

보인다. 다음 로그가 표시됩니다.

Before create 0 notification background.js:87 
Succesfully created undefined notification background.js:92 

여기에 무엇이 있습니까?

감사

업데이트 : 여기 여기에 완성의 manifest.json가 수정 된 background.js

window.addEventListener('load', function() { 
    var opt = { 
    iconUrl: "48.png", 
    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!');console.log(chrome.runtime.lastError)}); 
}); 

입니다 :

{ 
    "name": "Notification Demo", 
    "version": "1.1", 
    "description": 
    "Shows off desktop notifications, which are \"toast\" windows that pop up on the desktop.", 
    "icons": {"16": "16.png", "48": "48.png", "128": "128.png"}, 
    "permissions": [ 
    "notifications", 
    "http://*/*" 
    ], 
    "options_page": "options.html", 
    "background": { "scripts": ["background.js"]}, 
    "manifest_version": 2, 

    // crbug.com/134315 
    "web_accessible_resources": [ 
    "48.png" 
    ] 
} 
+0

질문에 알림 옵션을 포함하지 않으 셨습니다. 아마도 거기에 오류가 있으며, 생성되지 않습니다. 콜백 내에서'chrome.runtime.lastError'도 확인할 수 있습니다. – Xan

+0

참고로 WebkitNotifications의 직계 하위 항목은 [Notification API] (https://developer.mozilla.org/en/docs/Web/API/notification)입니다. – Xan

+0

옵션이 업데이트되었습니다. 네트워크에서 48.png를 볼 수 있으므로 아이콘이 좋을 것입니다. 마지막 오류는 알 수없는 오류입니다. Object {message : "알 수없는 오류입니다."} –

답변

0

그것은 어떤 경우 계속 오류가있을 가능성이 높습니다. Google은 최근에 확인되지 않은 chrome.runtime.lastError에 대한 오류를 기록하기 시작 했으므로 새로운 버전의 Chrome에서 시도해보십시오.

+0

"chrome.runtime.lastError'의 체크되지 않은 에러를 기록하는 것이 무엇을 의미하는지 더 자세히 말할 수 있습니까? – Xan

관련 문제