'use strict'; import React from 'react'; import io from 'socket.io-client'; export default class NotifPage extends React.Component { constructor(props) { super(props); this.state = { haveperm: false } } componentDidMount() { let socket = io.connect(); let room = this.props.urlid; socket.on('connect', () => { socket.emit('room', room); }); socket.on('message', (data) => { new Notification(data); }); } checkperm(permission) { if (permission === 'granted') { this.setState({haveperm: true}); } } render() { let supported = ("Notification" in window); if (supported) { Notification.requestPermission(permission => { this.checkperm(permission); }.bind(this)); } return (
Error: This browser does not support desktop notifications :(
Please give this site permission to display notifications.
this.checkperm(Notification.permission)}> Check AgainThis page is now monitoring for notifications.
}