A browser notification is an interruption outside the current page. Browser permission is required, but permission alone is not a product preference for every alert category. Ask after the person chooses a clear, time-sensitive use case and explain what will arrive. Store a separate, current application preference for assignment alerts, quiet periods, and device scope as needed by the product. A denied, dismissed, or unsupported browser path must leave an in-app inbox or other authorized route to the same work. Do not request a prompt on first load just because the API is available.
Notification Opt-In and Channel Preference
Working case
Reviewer 29 receives case assignments across several districts. The case-review app offers Notify me about urgent assignments after the reviewer opens notification settings, not while they are reading an ordinary report. The screen explains that the alert will contain a generic assignment message and a link requiring sign-in. If browser permission is denied, the reviewer can still inspect the in-app assignment inbox and a visible count. Changing the product preference to Off stops future sends even if browser permission stays Granted. An old permission grant is not a reason to restart alerts silently.
Implementation boundary
function mayScheduleAlert(settings, browserState) {
return settings.urgentAssignments === true && browserState === "granted";
}
console.log(mayScheduleAlert({ urgentAssignments: false }, "granted"));
// Output: falseSeparate browser permission state, product opt-in, and active subscription state in the data model. Only call the browser permission request from an intentional user action, and handle granted, denied, default, and API absence without assuming one browser prompt behavior. Register and subscribe only after current product consent and permission requirements are met. On opt-out, mark the server preference Off first, stop scheduling sends, then remove or invalidate device subscriptions with retry if the browser is unavailable. The in-app inbox remains the authoritative list of assignments, subject to current server authorization.
Cost and boundaries
Reading local state is O(1), but repeated permission prompts cost trust and cannot be forced after denial. Keeping a subscription per device adds O(d) stored records for d devices and requires a cleanup path. An in-app inbox adds persistence and query cost, yet it supplies the durable result that a transient notification cannot. Measure the proportion of users who complete setup, the time from opt-out to no further sends, and whether denied users can still find urgent work. Do not optimize only for prompt acceptance.
Failure trace
The app requests notification access before showing any case. Many reviewers deny it, and the app then hides assignment counts as if alerts were the only route to work. Restore the inbox and move the request behind settings. Another defect reads Notification.permission as Granted and sends marketing-style alerts despite the product toggle being Off. Require both states before scheduling. Open two devices, disable the category on one, and verify the server policy reaches both. Test a suspended tab, a revoked browser permission, and a browser without the push feature.
Verification
- A permission request follows a clear user action.
- Product opt-out blocks future sends despite a browser grant.
- Denied devices retain an authorized in-app inbox.
Practice drill
Start with browser permission Default, product preference Off, and no subscription. Enable urgent alerts through the settings action, then test Granted, Denied, and dismissed outcomes. Disable the category while a job is queued; verify the send decision rechecks the current preference. Leave one device offline during opt-out and inspect its later subscription cleanup. Confirm that the in-app inbox contains the same assignments under current authorization whether or not push is enabled.
Decision note
Treat browser permission as one technical gate, and product opt-in as the continuing decision about which alerts to send.
Common Mistakes
- Treating a browser grant as consent to every alert.
- Requesting permission during first-page load.
- Removing the in-app path when permission is denied.
Connected lessons
Web Push and Notification Delivery; Push Subscription Account Binding and Rotation; Private Notification Payload and Click Routing; Push Delivery Retries, Expiry, and Inbox Fallback; Permission Request Timing and Manual Fallback; Preference Change Propagation and Audit; Live Update Reconnect and Event Ordering.
Apply and check
Build Project: private urgent assignment alerts and review Web Development: push notification decisions quiz.
