2017-09-20 2 views
0

나는 고객에게 데스크톱 알림을 밀어 코드를 사용 알림 설정을 클라이언트에 알림을 표시하거나 허가를 요청하지 않는 Allowed 또는 Default (Ask) 브라우저로 설정되어있는 동안크롬 데스크톱 알림

// Let's check if the browser supports notifications 
if (!("Notification" in window)) { 
    toast(type, title, body); 
} 

// Let's check whether notification permissions have already been granted 
else if (Notification.permission === "granted") { 
    // If it's okay let's create a notification 
    var notification = new Notification(title, options); 
} 

// Otherwise, we need to ask the user for permission 
else if (Notification.permission !== 'denied') { 
    Notification.requestPermission(function (permission) { 
     // If the user accepts, let's create a notification 
     if (permission === "granted") { 
      var notification = new Notification(title, options); 
     } else { 
      // toast(type, title, body); 
     } 
    }); 
} 

문제입니다.
위의 코드와 관계없이 Chrome 개발자 도구 콘솔에 Notification.permission을 입력하면 Allowed으로 설정되며 입니다.
크롬 버전은 63.x입니다.

답변

0

알림을 거부하면 즉시 다시 알림 메시지가 표시되지 않습니다. 이것은 사이트가 사용자를 스팸하는 것을 막기위한 것입니다.

테스트 중에 문제가 될 수 있습니다. 다행히 Chrome의 알림 설정을 열면 항목을 삭제할 수 있습니다.이 항목을 사용하면 처음 방문자 흐름을 통과 할 수 있습니다. 알림 설정은 수시로 옮겨 지므로 주위를 찌를 필요가 있습니다. 크롬 60 인 설치 버전에는 chrome : // settings/content/notifications에 알림 설정이 있습니다.

관련 문제