크롬 데스크탑입니다 알림 경로재설정 어떻게 해야 할까요? # 39; d i& 내 자신의 코드를 사용하는 것 같다.
최근의 브라우저에서 두 가지 유형의 알림:
이 API 는 동일한 매개변수입니다 호출하십시오 제외하고 아닌 액션 support. dell. 데스크탑입니다 알림에는) 에 있으며, 잘 [매든] (https://developer.mozilla.org/en-US/docs/Web/API/notification) 과 서비스 노동자, on [Google& # 39 의 웹 기초] (https://developers.google.com/web/fundamentals/push-notifications/display-a-notification) 사이트.
다음은 크롬, 파이어폭스, 오페라, 사파리 apc® /files데스크탑 사항을 들 수 있다. 단, 보안상의 이유로 시작하여, 크롬 (62), [대한 권한을 더 이상 요청되어야 크로스 기원 5월 Notification API 에서 iframe] (https://www.chromestatus.com/feature/6451284559265792), 그래서 우리는 can& # 39 의 코드를 사용하여 이 데모, t # 39 StackOverflow& 스니핏. # 39 이 들어 있는 HTML 파일을 저장할 필요가 you&, ll, '또는' localhost:// HTTPS 사이트의 / 어플리케이션마다 및 smartupdate 사용할 수 있습니다.
<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 진정한 바벨. > 거짓값 -;
// request permission on page load
document.addEventListener('DOMContentLoaded', function() {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}
if (Notification.permission !== 'granted')
Notification.requestPermission();
});
function notifyMe() {
if (Notification.permission !== 'granted')
Notification.requestPermission();
else {
var notification = new Notification('Notification title', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: 'Hey there! You\'ve been notified!',
});
notification.onclick = function() {
window.open('http://stackoverflow.com/a/13328397/1269037');
};
}
}
<button onclick="notifyMe()">Notify me!</button>
끝 - < 스니핏 >;!
W3C 알림에는 작업하십시오 많은 브라우저 (http://otl. 대한 지원을 [카니우스] (http://caniuse.com/ # 검색 = 통지용)) 및 사용자 권한이 필요합니다. # 39 이 권한을 don& 모범 사례로서, t ask, 방망이를 맞아 떨어져. [설명하란말야 사용자에게 이유를 먼저 그녀의심장을 알림] (https://docs.google.com/document/d/1WNPIS_2F0eyDm5SS2E6LZ_75tk6XtBSnR1xNjWJ_DPE/edit #) 를 다른 [푸시 알림 패턴] (https://developers.google.com/web/fundamentals/push-notifications/common-notification-patterns).
단, t # 39 크롬 doesn& 지킬 통지용 아이콘에 linix 인해 [이 버그] (https://bugs.chromium.org/p/chromium/issues/detail? id = 962193).
그동안 횡단면도 플럭스 알림 지원, 다양한 api 를 통해 지난 몇 년간 더 이상 사용되지 않습니다. # 39, 이 경우, 이전 you& 편집을 위해 오토메이티드 대체 뭘 하고 있는지 궁금하다 행하였 작업하십시오 크롬 · 익힐 수 있는 이야기를 부유하도다 HTML 수행한다.
이제 최신 표준은 dell. https://notifications.spec.whatwg.org/.
왜 것과 동일한 효과를 you& 여부에 따라 두 가지 페이징됩니다 # 39, re in 서비스 노동자 방관하겠나 - 참조 [나는 내가 일했던 때 이 티켓을 파일링되었습니다 구글에서] (https://bugs.chromium.org/p/chromium/issues/detail? id = 590029).
[노아피오이스] 참조 (https://github.com/alexgibson/notify.js/) 의 보조 라이브러리입니다.
확인 디자인 및 apiu 사양명세 (it& # 39 의 여전히 구배하는) 또는 체크 소스에서 (페이지 더 이상 사용할 수 없음) 단순 예: # 39 의 it& 주로 전화로 '빈다우스웹킷노리피카션s.크리테노리피카션'.
스케쳐내 보다 강력한 예 (you& # 39, re trying to 직접 만들 구글 Chrome& # 39 의 확장, 어떻게 대처해야 할지 싶은 권한, 로컬 스토리지 등), 체크아웃하려고 Gmail Notifier 확장명은: 정보기술 (it), 소스 코드 파일 압축을 풀지 크레스 다운로드하십시오 설치하는 대신 읽고 있다.
'이미' 더 이상 사용되지 않으며 재거됨 빈다우스웹킷노리피카티언스 것으로 보인다. 그러나 there& # 39, s [새 apiu] (https://developer.mozilla.org/en/docs/Web/API/notification) 및 it 최신 버전의 파이어폭스 작업하십시오 것으로 잘 알려져 있다.
function notifyMe() {
// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// Let's check if the user is okay to get some notification
else if (Notification.permission === "granted") {
// If it's okay let's create a notification
var notification = new Notification("Hi there!");
}
// Otherwise, we need to ask the user for permission
// Note, Chrome does not implement the permission static property
// So we have to check for NOT 'denied' instead of 'default'
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// Whatever the user answers, we make sure we store the information
if(!('permission' in Notification)) {
Notification.permission = permission;
}
// If the user is okay, let's create a notification
if (permission === "granted") {
var notification = new Notification("Hi there!");
}
});
} else {
alert(`Permission is ${Notification.permission}`);
}
}
I like: http://www.html5rocks.com/en/tutorials/notifications/quick/ # 목차 참조용이므로 하지만, 더 이상 # 39 는 이전 com/go/4e6b330a_kr 도왔으매 데모 doesn& 빗나갔다. 이제 '웹킷노리피카티언스' '알림'.
I made 이 단순한 통지용 래퍼. 작동하잖아 켜짐이 크롬, 사파리, 파이어폭스.
하지만 난 # 39 의 뿐만 아니라 오페라, IE, 아마도 모서리까지 haven& 테스트되었습니다, 아직 없다.
그냥 여기서 파일을 내려받습니다 노아피오이스 https://github.com/gravmatt/js-notify 및 페이지에 넣습니다.
Get it on 바워
$ bower install js-notify
This is how it works.
notify('title', {
body: 'Notification Text',
icon: 'path/to/image.png',
onclick: function(e) {}, // e -> Notification object
onclose: function(e) {},
ondenied: function(e) {}
});
그러나 두 번째 인수 선택적입니다 로케이터로 json 직무명 설정할 수 있습니다.
다음은 api 에 대한 좋은 문서용으로,
https://developer.chrome.com/apps/notifications
또한, 구글이 공식 뮤직비디오가 설명
[https://developers.google.com/live/shows/83992232- 1001년] [2]
[2]: https://developers.google.com/live/shows/83992232- 1001년
주위에서 래퍼 노아피오이스 는 새로운 웹킷 수행한다. 작동하잖아 예쁜 것.
http://alxgbsn.co.uk/2013/02/20/notify-js-a-handy-wrapper-for-the-web-notifications-api/
<!DOCTYPE html>
<html>
<head>
<title>Hello!</title>
<script>
function notify(){
if (Notification.permission !== "granted") {
Notification.requestPermission();
}
else{
var notification = new Notification('hello', {
body: "Hey there!",
});
notification.onclick = function () {
window.open("http://google.com");
};
}
}
</script>
</head>
<body>
<button onclick="notify()">Notify</button>
</body>
< /html>;