Illustration of web push OTP and 2FA codes, a padlock beside a laptop with a notification bell and a key Illustration of web push OTP and 2FA codes, a padlock beside a laptop with a notification bell and a key

Can Web Push Notifications Be Used for One-Time Passwords or 2FA?

Can you send OTP or 2FA codes with web push? Why it’s a poor login factor, better alternatives, and where push helps with account security.

You technically can send OTP or 2FA codes through web push notifications, but it’s a poor fit. Web push delivery isn’t guaranteed, desktop browsers must be running, iPhone needs a Home Screen web app, and codes can appear on a lock screen. Use passkeys, an authenticator app or SMS for codes, and web push for login alerts.

This question comes up because web push looks like a free, instant channel to a user’s device. On paper, it can carry six digits as easily as a headline. In practice, a login code has much stricter needs than a news alert. It must arrive every time, quickly, only to the right person, and it must not leak. Below I compare web push with the usual options and show where push genuinely helps with account security.

Can web push notifications be used for one-time passwords or 2FA?

Yes, it’s technically possible, but I don’t recommend web push OTP or 2FA codes as the main method. A service worker can show any text in a notification, including a code. The problems are reliability, reach and privacy, not the code itself.

A login factor that fails even occasionally locks users out. As a result, support tickets rise and people abandon sign-ups. Web push is built for helpful updates, so its design accepts some messages arriving late or not at all.

Why is web push unreliable for login codes?

Web push depends on several things you don’t control. Any one of them can stop a code from arriving in time.

  • Browser must be running on desktop. The web.dev push notifications FAQ explains that on desktop, you receive messages only while the browser is running. If Chrome is closed, the code waits.
  • Push services can drop messages. Under the Web Push protocol, RFC 8030, the push service holds a message for its time-to-live (TTL) and may keep it for less time than you asked. After that, it’s gone.
  • Subscriptions expire. A browser can drop a subscription, and people clear data or switch devices. My post on how long web push subscriptions last covers why.
  • Permission can be revoked. A user who blocks notifications from your site also blocks their codes.
  • Notifications can be silenced. Focus or Do Not Disturb modes may hide the alert until later.

Does web push OTP work on iPhone?

Only in a limited way. Safari on iOS and iPadOS 16.4 and later supports web push for web apps added to the Home Screen, as WebKit announced in its post on web push for web apps on iOS and iPadOS.

So a visitor using your site in a normal Safari tab can’t receive web push at all. For a login factor, that rules out a large share of iPhone users unless they install your web app first. My guide on getting web push working on iPhone explains the steps.

Is it safe to put a code in a push notification?

It’s risky. A notification can appear on the lock screen, so anyone holding the phone or glancing at a laptop may see the code. My post on whether web push notifications show on the lock screen covers the settings involved.

There’s also an identity issue. A push subscription identifies a browser profile, not a verified person. If someone else uses that browser, they receive the code too. The payload is encrypted in transit under RFC 8291, but once displayed it’s plain text on screen.

What about “approve this login” push prompts?

Approve-or-deny prompts are a known attack target. CISA’s fact sheet on number matching describes “MFA fatigue”, also called push bombing. An attacker with a stolen password triggers repeated prompts until the user taps approve by mistake.

CISA recommends phishing-resistant MFA, and number matching as an interim step for push-based apps. Dedicated authenticator apps have built that in. A simple web push “Approve” button usually doesn’t, so I wouldn’t build one from scratch.

What should you use instead of web push for OTP?

Pick a method designed for authentication. Here’s how the main options compare:

MethodPhishing resistantWorks without your site openMain drawback
Passkeys (WebAuthn)YesNot needed, built into sign-inUsers need a supported device or password manager
Authenticator app (TOTP)NoYes, works offlineUsers must install and set up an app
SMS codeNoYesCost per message and SIM-swap risk
Email code or linkNoYesSlower, depends on inbox access
Web push codeNoOnly if browser running (desktop)Not guaranteed; iPhone needs Home Screen app

Passkeys use the Web Authentication API, and Google’s passkeys developer guide covers implementation. Authenticator apps follow the TOTP standard in RFC 6238. If you use SMS, the WebOTP API can fill the code automatically on supported browsers.

Where does web push help with account security?

Web push works well as a security alert, not as the factor itself. These uses don’t break anything if a message arrives late:

  1. Send a “new sign-in from a new device” alert after login.
  2. Notify users when their password or email address changes.
  3. Remind users to set up 2FA or a passkey.
  4. Warn about an expiring session or subscription.
  5. Link each alert to the account security page, never to a login form.

That last rule matters. Never put a “log in here” link in a security alert, since phishers copy that pattern. Instead, tell people to open your site directly. Also, keep alerts sparse; a welcome push notification and occasional account notices are fine, but noise trains people to ignore you.

Where LaraPush fits

LaraPush is a self-hosted web push panel for marketing and content notifications, installed on your own VPS. It isn’t an authentication or OTP service, and I wouldn’t use it as one. Its REST API can send notifications from your own app, which suits account alerts like “new sign-in detected”.

The trade-offs: you run the server, a licence covers one server, and there’s no free plan. Prices start from $499 one-time; check LaraPush pricing for the current price. The features page lists what’s included, and my push notification API guide for developers covers integration. For broader options, see my comparison of push notification services.

Frequently asked questions

Can I send OTP codes through web push notifications?

Technically yes, but it’s not reliable enough for login. Delivery isn’t guaranteed, desktop browsers must be running, and iPhone needs a Home Screen web app. Codes can also appear on a lock screen. Use passkeys, an authenticator app or SMS instead.

Is web push 2FA secure?

Not as a main factor. A push subscription identifies a browser, not a person, and the code is readable once shown. Approve-or-deny push prompts are also targeted by MFA fatigue attacks. Phishing-resistant options such as passkeys are stronger.

Is web push free compared with SMS OTP?

Sending web push doesn’t carry a per-message carrier fee the way SMS usually does. However, the lower cost doesn’t help if codes fail to arrive. For authentication, reliability and security matter more than message cost.

What’s a good use of web push for account security?

Security alerts. Notify users about new sign-ins, password or email changes, and reminders to enable 2FA. These messages are useful even if they arrive a little late, and they don’t lock anyone out if they fail.

Can web push replace an authenticator app?

No. Authenticator apps generate codes on the device, even offline, using the TOTP standard. Web push needs a working subscription, a running browser on desktop and a reachable push service, so it can’t match that reliability.

Leave a Reply

Your email address will not be published. Required fields are marked *