2016-07-28 60 views

回答

0

您可以發送像這樣的通知,但首先你必須問用戶他是否要允許通知。

Notification.requestPermission(function() { 
    if (Notification.permission === 'granted') { 
     // user approved. 
     // use of new Notification(...) syntax will now be successful 
     new Notification('Success', { body: 'Success!' }); 
    } else if (Notification.permission === 'denied') { 
     // user denied. 
    } else { // Notification.permission === 'default' 
     // user didn’t make a decision. 
     // You can’t send notifications until they grant permission. 
    } 
}); 
+0

對不起,我以爲這個問題是關於JavaScript – Black