INNER CODE UNIT · TypeScript

askPermission

saalikmubeen/talkhouse · client/src/notifications.ts:10

export function askPermission() {
  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;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…