JavaScript PushManager hasPermission() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

PushManager.hasPermission() was a legacy instance method that returned a Promise resolving to a PushPermissionStatus: "granted", "denied", or "default" (MDN).

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call pushManager.hasPermission. Start with this line.

JavaScript
pushManager.hasPermission()
CallWhat it does
pushManager.hasPermission()Primary signature.
pushManager.hasPermission(...)Call with the arguments your case needs.

Built into the browser. Call hasPermission(...) on a PushManager — no import required.

Library declarations
JavaScript
pushManager.hasPermission()

Parameters

ParameterDescription
Feature detectRequired. Missing in most modern browsers

Return Value

Return ValueDescription
*Resolves to status string

JavaScript Examples

Example 1 — Legacy hasPermission() Shape

MDN idea: await the Promise and read the status string (do not ship this).

JavaScript
// Historical pattern — require feature detect in real browsers
const registration = await navigator.serviceWorker.ready;
const status = await registration.pushManager.hasPermission();

console.log(status); // "granted" | "denied" | "default"
Try It Yourself

How It Works

  1. Wait for the worker. Push lives on registration.pushManager.
  2. Call with no args. MDN: hasPermission() takes none.
  3. Await the Promise. Unlike some legacy push APIs, this one was Promise-based.
  4. Read the string. Branch on granted / denied / default.

Example 2 — Feature Detect, Then Fall Forward

Safe helper when you must touch legacy codepaths.

JavaScript
async function getPushPermission(pm) {
  if (pm && typeof pm.hasPermission === "function") {
    return pm.hasPermission(); // legacy
  }
  if (pm && typeof pm.permissionState === "function") {
    return pm.permissionState({ userVisibleOnly: true });
  }
  return typeof Notification !== "undefined"
    ? Notification.permission
    : "unsupported";
}

const hasLegacy =
  typeof PushManager !== "undefined" &&
  typeof PushManager.prototype.hasPermission === "function";

console.log(hasLegacy ? "legacy available" : "use permissionState()");
Try It Yourself

How It Works

  1. Prefer modern. Try permissionState when legacy is missing.
  2. Detect before call. Calling a missing method throws.
  3. Optional sync fallback. Notification.permission is a simple sync string.
  4. Expect “use permissionState()”. That is the common result today.

Example 3 — Migrate to permissionState()

Recommended replacement for new push projects.

JavaScript
const registration = await navigator.serviceWorker.ready;
const status = await registration.pushManager.permissionState({
  userVisibleOnly: true,
});

if (status === "granted") {
  console.log("Push allowed");
} else if (status === "denied") {
  console.log("Push blocked");
} else {
  console.log("Not decided yet (prompt)");
}
Try It Yourself

How It Works

  1. Use the standard API. permissionState() is the MDN replacement.
  2. Pass subscribe options. Match what you will use with subscribe().
  3. Branch on three values. prompt replaces legacy default.
  4. Then subscribe. Only call subscribe() when UX is ready.

Browser Support

PushManager.hasPermission() is Deprecated and Non-standard on MDN. It is missing or removed in modern browsers. Prefer permissionState() (Baseline Widely available).

✓ Deprecated · Non-standard

PushManager.hasPermission()

Legacy push permission Promise — avoid in new code. Use permissionState() instead.

Legacy Deprecated API
Google Chrome Not supported — use permissionState()
Not supported
Mozilla Firefox Legacy only — use permissionState()
Legacy only
Apple Safari Use permissionState() / Notification.permission
Not supported
Microsoft Edge Follow Chromium — use permissionState()
Not supported
Opera Follow Chromium
Not supported
Internet Explorer No Push API
Not supported
hasPermission() Limited

Bottom line: Feature-detect before calling. Build new push features with permissionState() and subscribe() after serviceWorker.ready.

Frequently Asked Questions

It returns a Promise that resolves to a PushPermissionStatus string: "granted", "denied", or "default" — whether the web app has push permission (MDN).
Yes. MDN marks it Deprecated and Non-standard. It is not Experimental. Prefer PushManager.permissionState() in new code.
Use PushManager.permissionState() (modern Push API). For a quick sync notification check, Notification.permission may also help.
No. MDN documents hasPermission() with no parameters. Call it on registration.pushManager.
Legacy hasPermission used "default" for undecided. Modern permissionState uses "prompt" for the same idea. granted and denied mean the same in both.
You may see it in old tutorials. Knowing it helps you migrate safely to permissionState() without breaking legacy checks.

Next: permissionState()

Learn the modern, standardized way to check push permission before subscribe().

permissionState() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful