JavaScript PushManager register() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Method

Definition

PushManager.register() was a legacy instance method that asked the system for a new push endpoint URL (MDN). On success, req.result was a string endpoint — not a full PushSubscription.

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

Syntax

Call pushManager.register. Start with this line.

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

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

Library declarations
JavaScript
pushManager.register()

Parameters

ParameterDescription
onsuccess / onerrorRequired. Handle the DOMRequest
Feature detectRequired. Missing in modern browsers

Return Value

Return ValueDescription
*DOMRequest (not a Promise)

JavaScript Examples

Example 1 — MDN register() Pattern

Request a new endpoint with onsuccess / onerror.

JavaScript
const req = navigator.push.register();

req.onsuccess = () => {
  const endpoint = req.result;
  console.log(`New endpoint: ${endpoint}`);
};

req.onerror = (e) => {
  console.error(`Error getting a new endpoint: ${e.error}`);
};
Try It Yourself

How It Works

  1. Call the legacy API. register() returns a DOMRequest, not a Promise.
  2. Wait for success. onsuccess runs when the system creates an endpoint.
  3. Read the string. req.result is the endpoint URL.
  4. Handle errors. onerror covers permission or system failures.

Example 2 — Feature Detect Before Calling

Safe pattern when you must touch legacy codepaths.

JavaScript
function legacyRegister(pushManager) {
  if (pushManager && typeof pushManager.register === "function") {
    return pushManager.register();
  }
  if (navigator.push && typeof navigator.push.register === "function") {
    return navigator.push.register();
  }
  return null; // not supported — use subscribe()
}

const req = legacyRegister(null);
console.log(req === null ? "use subscribe()" : "legacy available");
Try It Yourself

How It Works

  1. Check the method. Only call if typeof … === "function".
  2. Cover both hosts. Old samples used navigator.push; some drafts used pushManager.
  3. Return null when missing. That is the common case in Chrome, Safari, and modern Firefox.
  4. Fall forward. Treat null as a signal to use subscribe().

Example 3 — Cleanup with unregister()

MDN: if you no longer need the URL, clean up with unregister().

JavaScript
const req = navigator.push.register();

req.onsuccess = () => {
  const endpoint = req.result;
  console.log("Got:", endpoint);
  // Later, when finished:
  // navigator.push.unregister();
  console.log("Call unregister() when the endpoint is unused");
};
Try It Yourself

How It Works

  1. Create first. Legacy apps stored the endpoint string.
  2. Use it briefly. Send the URL to the app server.
  3. Clean up. MDN recommends unregister() when done.
  4. Modern twin. Call subscription.unsubscribe() instead.

Example 4 — Migrate to subscribe()

Recommended replacement for new push projects.

JavaScript
const registration = await navigator.serviceWorker.ready;
let subscription = await registration.pushManager.getSubscription();

if (!subscription) {
  subscription = await registration.pushManager.subscribe({
    userVisibleOnly: true,
    applicationServerKey: vapidPublicKey
  });
}

console.log("Endpoint:", subscription.endpoint);
Try It Yourself

How It Works

  1. Wait for the worker. serviceWorker.ready gives the active registration.
  2. Reuse if present. getSubscription() avoids creating duplicates.
  3. Subscribe when null. Pass userVisibleOnly and your VAPID key.
  4. Sync the full object. Modern servers need endpoint and encryption keys.

Browser Support

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

✓ Deprecated · Non-standard

PushManager.register()

Legacy push endpoint registration — avoid in new code. Use subscribe() instead.

Legacy Deprecated API
Google Chrome Not supported — use subscribe()
Not supported
Mozilla Firefox Legacy only — use subscribe()
Legacy only
Apple Safari Never supported — use subscribe()
Not supported
Microsoft Edge Follow Chromium — use subscribe()
Not supported
Opera Follow Chromium
Not supported
Internet Explorer No Push API
Not supported
register() Limited

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

Frequently Asked Questions

It asked the system for a new push notification endpoint. On success, the DOMRequest result was a string URL. MDN superseded it with subscribe(), which returns a full PushSubscription.
Yes. MDN marks it Deprecated and Non-standard. It is not Experimental. Prefer PushManager.subscribe() in new code.
A DOMRequest object (legacy Mozilla pattern), not a Promise. On success, req.result is the endpoint URL string.
Use PushManager.subscribe() after navigator.serviceWorker.ready. It returns a Promise that resolves to a PushSubscription with endpoint and encryption keys.
No. MDN documents register() with no parameters.
MDN says if you no longer need the URL, call PushManager.unregister(). Modern code uses PushSubscription.unsubscribe().

Next: registrations()

Legacy listing of push endpoints (also deprecated).

registrations() →

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