初步使用Web Notification 实现浏览器消息通知

mesgNotice(data){
                if(data.length>0){
                    if(window.Notification && Notification.permission !== "denied") {
                        let count = 0;
                        for (let [index,item] of data.entries()) {
                            if(item.IsForceSell || item.IsAlert){
                                setTimeout(() => {
                                Notification.requestPermission().then(function (permission) { 
                                                let notice_ = new Notification('新的消息', { body: `${item.StockCode}:${item.StockName},达到${item.IsForceSell?'止损线':item.IsAlert?'预警线':''},请及时处理`});
                                            });
                                }, count*500);
                                count++;
                            }
                            
                        }
                        
                    }else{
                        alert('当前浏览器不支持消息通知');
                    }
                    
                     
                }
                 
            },

 

posted @ 2019-06-11 15:14  崔凯通  阅读(387)  评论(0编辑  收藏  举报