Coder Social home page Coder Social logo

Comments (11)

lin-xin avatar lin-xin commented on May 22, 2024 1

@liujinge file:// 文件协议是没有通知的。

from blog.

 avatar commented on May 22, 2024

新版Chrome61好像无效啊
Notification.requestPermission().then(function (permission) {
if (permission === 'granted') {
console.log(Notification)
var n = new Notification('状态更新提醒',{
body: '你的朋友圈有3条新状态,快去查看吧',
tag: 'linxin',
icon: 'http://blog.gdfengshuo.com/images/avatar.jpg',
data: {
url: 'http://blog.gdfengshuo.com'
},
requireInteraction: true
})

		console.log(n)

		/*setTimeout(function () {
			n.close()
		}, 3000)*/
	}
})

from blog.

lin-xin avatar lin-xin commented on May 22, 2024

@18664363461 我用 60 的有效啊,61居然没效,我试试。

from blog.

gookyn avatar gookyn commented on May 22, 2024

用的Google 60,为什么没有通知呢?

Notification.requestPermission().then(function(permission) { if(permission === 'granted'){ console.log('用户允许通知'); }else if(permission === 'denied'){ console.log('用户拒绝通知'); } });

var notification = new Notification('状态更新提醒',{ body: '你的朋友圈有3条新状态,快去查看吧', tag: 'linxin', icon: 'http://blog.gdfengshuo.com/images/avatar.jpg', requireInteraction: true })

from blog.

 avatar commented on May 22, 2024

浏览器设置里面消息通知是否允许了呢?我用的windows Chrome61是无效,FireFox是可以的。

from blog.

lin-xin avatar lin-xin commented on May 22, 2024

@18664363461 你的是不是也是直接双击打开的呢?还是有用服务器打开的

from blog.

 avatar commented on May 22, 2024

直接本地写的demo(双击打开),如果要本地服务打开好像Chrome要https才可以

from blog.

lin-xin avatar lin-xin commented on May 22, 2024

@18664363461 那确实不行。不用https,用 http://localhost 都可以

from blog.

 avatar commented on May 22, 2024

可以了 api没问题了,我在https网页console测试了可以的。好的 localhost我试试!谢谢啊

from blog.

gookyn avatar gookyn commented on May 22, 2024

from blog.

xiguazhiPrince avatar xiguazhiPrince commented on May 22, 2024

我看到ins和哔哩哔哩,明明没有打开他们的网站,但是还是收到了桌面通知,是可以服务端推送吗?

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.