[bug][notification] Windows: init script always sets `window.Notification.permission` to `"denied"` at startup

Aperta Adatta ai principianti
#3,512 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@Legend-Master ci sta già lavorando.

Dal 18/8/2026.

  • #3540 di @AatmanAJ — aperta
  • #3541 di @Legend-Master — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
rust, typescript
Ambito
desktop

Direzione di ricerca

Inizia in plugins/notification/guest-js/init.ts, leggendo lo shim di Notification, isPermissionGranted() e il bootstrap che chiama setNotificationPermission(). Confronta questo flusso con il comportamento di permission_state() del backend descritto nell’issue. Il lavoro è completo quando un avvio pulito di Windows riflette il backend come autorizzato e requestPermission() continua a riportare lo stato previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

platform: windows plugin: notification type: bug

Describe the bug

On Windows, the notification plugin's injected init script stamps
window.Notification.permission = "denied" on every page load, even though the
desktop backend unconditionally reports PermissionState::Granted on Windows.
Any app that reads window.Notification.permission (or gates sending on it)
concludes notifications are blocked.

In guest-js/init.ts:

async function isPermissionGranted(): Promise<boolean> {
  if (window.Notification.permission !== 'default' || __TEMPLATE_windows__) {
    return await Promise.resolve(window.Notification.permission === 'granted')
  }
  return await invoke('plugin:notification|is_permission_granted')
}

By the time this runs, window.Notification has already been replaced by the shim
defined earlier in the same IIFE, whose permission is initialized to 'default'.
With __TEMPLATE_windows__ === true the function therefore always returns
'default' === 'granted' → false, and the bootstrap at the bottom of the file maps
false → 'denied':

void isPermissionGranted().then(function (response) {
  if (response === null) {
    setNotificationPermission('default')
  } else {
    setNotificationPermission(response ? 'granted' : 'denied')
  }
})

The Windows short-circuit presumably predates the shim replacement (it would make
sense reading the native WebView2 permission), but as written it can only ever
observe the shim's own initial value.

Reproduction

Any Tauri v2 app on Windows with the notification plugin registered:

console.log(window.Notification.permission)          // "denied" — always, fresh profile
await window.Notification.requestPermission()        // "granted"
console.log(window.Notification.permission)          // "granted" — until next launch

Observed in the wild in block/buzz (block/buzz#2445), where the settings UI
reads window.Notification.permission, sees "denied", and tells users to enable
notifications in system settings (where nothing is disabled).

Expected behavior

On Windows the bootstrap should reflect the backend (permission_state() returns
Granted), i.e. initialize to "granted" — or fall through to
invoke('plugin:notification|is_permission_granted') like other platforms:

async function isPermissionGranted(): Promise<boolean> {
  if (window.Notification.permission !== 'default') {
    return window.Notification.permission === 'granted'
  }
  return await invoke('plugin:notification|is_permission_granted')
}

Platform and versions

  • OS: Windows 11 (10.0.26200), WebView2 Evergreen
  • tauri-plugin-notification: 2.3.3 (bug still present on v2 branch tip)
  • tauri: 2.x
Lingua principale
Rust
Stelle
1.8k
Fork
637
Merge medio
5g 3h
PR unite (30g)
36

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tauri-apps/plugins-workspace

Tutte le issue di tauri-apps/plugins-workspace

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.