Skip to content

Commit 5d82843

Browse files
author
Naveen Kumar Sangi
authored
Web Notifications: Check for compatibility
Not all mobile browsers support Web Notifications yet. Reference: https://caniuse.com/?search=notifications
1 parent 33335a4 commit 5d82843

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

app/components/DropZone.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class DropZone extends Component {
1212

1313
constructor(props) {
1414
super(props);
15-
Notification.requestPermission();
15+
if ('Notification' in window) {
16+
Notification.requestPermission();
17+
}
1618

1719
// For a full list of possible configurations,
1820
// please consult http://www.dropzonejs.com/#configuration
@@ -33,7 +35,7 @@ class DropZone extends Component {
3335
success = (file, path) => {
3436
FilesActions.updateFileList(path);
3537
const body = `Filename : ${file.name}`;
36-
if(Notification.permission === 'granted') {
38+
if('Notification' in window && Notification.permission === 'granted') {
3739
new Notification('File uploaded successfully',{ body , icon });
3840
}
3941
}

0 commit comments

Comments
 (0)