홈>
확장 프로그램을 개발했으며 Chrome API를 사용하여 백그라운드 스크립트에서 20 초마다 알림을 보냅니다
manifest.json
{
"name": "Test",
"description": "Test",
"manifest_version": 2,
"version": "0.1",
"chrome_url_overrides" : {
"newtab": "register.html"
},
"background": {
"scripts": ["background.js"]
},
"permissions": ["idle", "tabs", "gcm", "storage", "notifications"],
"icons": { "128": "gcm_128.png" }
}
background.js // 알림을 보냅니다
function messageReceived(message) {
var messageString = '';
if(message) messageString = message;
var nid = getNotificationId();
messageString = messageString + nid;
// Pop up a notification to show the GCM message.
chrome.notifications.create(nid, {
title: 'Kukdu Kuuu',
iconUrl: 'gcm_128.png',
type: 'basic',
message: messageString
}, function() {});
}
// Returns a new notification ID used in the notification.
function getNotificationId() {
var id = Math.floor(Math.random() * 9007199254740992) + 1;
return id.toString();
}
setInterval(function() {
console.log('running - ');
messageReceived('test notification ');
}, 20000);
Chrome 브라우저가 아닌 경우, 즉 초점이 맞지 않을 때 알림을 표시합니다. 하지만 크롬 작업을 할 때 알림을받지 않습니다.
API를 실행할 때
chrome.notifications.getAll()
, 전체 ID 대기열을 얻습니다.
그러나 시스템에 알림이 즉시 표시되지 않습니다. 무엇이 문제 일 수 있습니까? 그러나 Windows 시스템에서는 잘 작동합니다.
- 답변 # 1
트렌드
- OpenCv의 폴더에서 여러 이미지 읽기 (python)
- 파이썬 셀레늄 모든 "href"속성 가져 오기
- html - 자바 스크립트 - 클릭 후 변경 버튼 텍스트 변경
- javascript - 현재 URL에서 특정 div 만 새로 고침/새로 고침
- JSP에 대한 클래스를 컴파일 할 수 없습니다
- JavaScript 변수를 HTML div에 '출력'하는 방법
- git commit - 자식 - 로컬 커밋 된 파일에 대한 변경을 취소하는 방법
- jquery - JavaScript로 현재 세션 값을 얻으시겠습니까?
- javascript - swiperjs에서 정지, 재생 버튼 추가
- python - 화면에서 찾은 요소를 찾을 수없는 경우 셀레늄
크롬에서 공개 된 문제입니다.
링크는 다음과 같습니다
https://bugs.chromium.org/p/chromium/issues/detail?id=583746#
중요한 의견 및 요약,
와이즈 비즈현재 푸시 알림 동작
와이즈 비즈