Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web-basic-sample/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
sourceType: 'module'
},
rules: {
'linebreak-style': ['error', 'unix'],
'linebreak-style': ['error', 'windows'],
quotes: ['warn', 'single'],
semi: ['warn', 'always'],
'no-console': 1,
Expand Down
2 changes: 1 addition & 1 deletion web-basic-sample/src/js/const.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const APP_ID = '9DA1B1F4-0BE6-4DA8-82C5-2E81DAB56F23';
export const APP_ID = 'C9C493CF-0BD3-472F-9E24-F1D0B31FAC78';
export const USER_ID = 'user_id';
export const DISPLAY_NONE = 'none';
export const DISPLAY_BLOCK = 'block';
Expand Down
4 changes: 4 additions & 0 deletions web-basic-sample/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { body, UPDATE_INTERVAL_TIME } from './const';
import { SendBirdConnection } from './SendBirdConnection';
import { SendBirdEvent } from './SendBirdEvent';
import { LeftListItem } from './components/LeftListItem';
import { notify } from './utils';

const sb = new SendBirdAction();

Expand Down Expand Up @@ -98,6 +99,9 @@ document.addEventListener('DOMContentLoaded', () => {
updateGroupChannelTime();
chatLeft.getGroupChannelList(true);
})
.then(()=>{
notify('Welcome to the Team!');
})
.catch(() => {
redirectToIndex('SendBird connection failed.');
});
Expand Down
26 changes: 26 additions & 0 deletions web-basic-sample/src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,29 @@ export const protectFromXSS = text => {
.replace(/\'/g, ''')
: text;
};

export const notify = (message) => {
// Let's check if the browser supports notifications
if (!('Notification' in window)) {
alert('This browser does not support desktop notification');
}

// Let's check whether notification permissions have already been granted
else if (Notification.permission === 'granted') {
// If it's okay let's create a notification
var notification = new Notification(message);
}

// Otherwise, we need to ask the user for permission
else if (Notification.permission !== 'denied') {
Notification.requestPermission().then(function (permission) {
// If the user accepts, let's create a notification
if (permission === 'granted') {
var notification = new Notification(message);
}
});
}

// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them any more.
}