Skip to content

web: notifications fail in Android PWA #49961

Open

Description

@AdiY00

Summary

System notifications do not appear when a session completes or fails in the Android PWA. Chrome on Android rejects the web app's use of the Notification constructor and requires ServiceWorkerRegistration.showNotification().

Environment

  • opencode version: 2.0.8
  • Device: OnePlus 15
  • OS: Android 16
  • Browser: Chrome 153.0.0.0
  • Terminal: Not applicable (standalone PWA)
  • Shell: Not applicable (standalone PWA)
  • Install/channel: https://beta.opencode.ai, installed as a PWA

Reproduction

  1. Install https://beta.opencode.ai as an Android PWA.
  2. Grant notification permission and enable opencode session notifications.
  3. Open the PWA from its home-screen icon.
  4. Start a session and switch to another Android app before it completes.
  5. Wait for the session to complete.

Expected Behavior

An Android system notification should appear when the session completes or fails. Selecting it should return to the corresponding opencode session.

Actual Behavior

No system notification appears.

The following values were confirmed through remote DevTools:

  • Notification.permission: granted
  • Standalone display mode: true
  • Service-worker registration: null

Calling the same notification API used by the web platform produces:

TypeError: Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.

The failure also reproduced during a controlled session-completion test while the PWA was in the background.

Additional Context

packages/app/src/runtime/platform/web.ts creates notifications with new Notification(...). Chrome on Android does not support this constructor and requires ServiceWorkerRegistration.showNotification().

The generated service worker also has no notificationclick handler, which is required to implement notification click behavior.

There is a separate service-worker installation failure on the current beta deployment:

Fetch API cannot load https://beta.opencode.ai/_assets/__vite-browser-external-2447137e-BvRk9kiK.js. SRI's integrity checks failed.
sw.js:1 Uncaught (in promise) TypeError: Failed to fetch. SRI's integrity checks failed.

The browser reported the resource's computed SHA-256 integrity as:

8swVqH0fwc8XDDvPqJf6xzG3/DAwdGgKhA+t9mMRYQQ=

Because the service worker is not currently registered, showNotification() could not be tested on this deployment.

Activity

  1. AdiY00 commented on Sep 19, 2026

    @AdiY00
    ContributorAuthor

    For what it’s worth, I was able to get ServiceWorkerRegistration.showNotification() to display a notification using a different service worker, so the API itself works on this device.

  2. WolfieLeader commented on Sep 19, 2026

    @WolfieLeader

    Had the same issue

  3. balducci22 commented on Oct 1, 2026

    @balducci22

    Yeah i'm having a similar issue, with iOS its working fine however with android i'm getting a silenced notification that doesnt pops up on the screen.. any ideas how to solve it?

  4. bilogic commented on Oct 7, 2026

    @bilogic

    The PWA installer button does not show on my desktop chrome, are you guys sure it is a PWA?

  5. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report and the DevTools findings.

    I couldn't reproduce the notification failure here. It only happens in Chrome on Android, and this sandbox has no Android device or emulator. Desktop Chrome accepts new Notification(...), so the "Illegal constructor" error doesn't appear there.

    I did read the code on the latest dev (62ae125). The web platform's notify() in packages/app/src/runtime/platform/web.ts still uses new Notification(...) with no ServiceWorkerRegistration.showNotification() fallback. The generated service worker (packages/app/vite.pwa.ts, generateSW) still has no notificationclick handler. Both match what you describe.

    The service-worker SRI error didn't happen when I checked. sw.js on beta.opencode.ai currently lists __vite-browser-external-2447137e-BvRk9kiK.js with the hash of an empty file, and the server returns that file empty, so the two match. If you still see the integrity error, clearing the site data and reinstalling the PWA might tell us whether a cached copy was involved.

    A maintainer with an Android device will need to confirm the notification problem.

  6. Eslamasabry commented on Oct 31, 2026

    @Eslamasabry

    Not a fix for the PWA bug, but if you need notifications today: I'm the author of OpenCode Mobile (unofficial, MIT), an Android app that connects to an OpenCode server and uses normal Android notifications, with Allow once and Reject on permission requests. Repo: https://github.com/Eslamasabry/opencode-mobile-next. Android has to allow notifications for it, and the app's Notifications page has a test button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions