const req = navigator.push.registrations();
req.onsuccess = (e) => {
if (req.result.length > 0) {
req.result.forEach((result) => {
console.log(
`Existing registration ${result.pushEndpoint} ${result.version}`,
);
});
// Reuse existing endpoints.
} else {
// Register for a new endpoint.
const register = navigator.push.register();
register.onsuccess = (e) => {
console.log(`Registered new endpoint: ${register.result}`);
};
}
};PushManager: registrations() method / notebook
PushManager: registrations() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.