INNER CODE UNIT · TypeScript
Promise
saalikmubeen/talkhouse · client/src/notifications.ts:11
return new Promise(function (resolve, reject) {
const permissionResult = Notification.requestPermission(function (
result
) {
resolve(result);
});
if (permissionResult) {
permissionResult.then(resolve, reject);
}
}).then((result) => {
if (result !== 'granted') {
alert(
"Can't turn on the notifications. First enable notifications from the browser settings and then try again!"
);
return false;
}
return true;
});