Example 1 — Basic Check
The standard call after serviceWorker.ready.
const registration = await navigator.serviceWorker.ready;
const status = await registration.pushManager.permissionState({
userVisibleOnly: true,
});
console.log(status); // "prompt" | "denied" | "granted" How It Works
- Wait for ready. You need a registered service worker.
- Pass
userVisibleOnly. Chrome requires visible notifications for web push. - Await the Promise. Resolves to a status string.
- No prompt yet. This check does not ask the user —
subscribe()may.

