Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening pwa via push notification links is broken on Android 15 QPR1 #8668

Open
atsjo opened this issue Dec 7, 2024 · 4 comments
Open

Opening pwa via push notification links is broken on Android 15 QPR1 #8668

atsjo opened this issue Dec 7, 2024 · 4 comments

Comments

@atsjo
Copy link

atsjo commented Dec 7, 2024

Operating System

Android 15 QPR1 (security update December 5, 2024)

Environment (if applicable)

Chrome PWA

Firebase SDK Version

11.0.2

Firebase SDK Product(s)

Messaging

Project Tooling

Nx + Angular + firebase

Detailed Problem Description

When receiving a push notification while the pwa is minimized (running in the background), clicking the notification doesn't open the pwa. This has been working for years, and stopped now with Android 15 QPR1. It still works with Android 15 QPR1 if the pwa is not running, then it opens the pwa with the link in the notification. But if the pwa is minimized and should be restored/focused (via "launch_handler.client_mode: focus-existing"), nothing happens when clicking the notification, and it seems the pwa is crashing when opening it after that... Clicking notifications for websites not installed as pwa also still works, it's just minimized pwa's having the problem....

This may of course be an android problem, it still works on all other platforms, but either webpush is broken on android 15 QPR1, or there are some new api or setting firebase has to use to make it work on the newest android version... Either way this seems like a BIG problem that google would like to know about....

I have tested this on Pixel 8 and Pixel tablet, and tested it that it was working fine before QPR1 and failing after on both.

Steps and code to reproduce issue

Try via any pwa with push notifications... for instance this pwa test app:
https://progressier.com/pwa-capabilities/push-notifications

Follow the steps, send a notification and minimize (not close) the pwa before clicking the notification...
I works on every platform, including android 15 with november update, but fails with android 15 with decemer update (QPR1)

@atsjo atsjo added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Dec 7, 2024
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@jbalidiong jbalidiong added api: messaging needs-attention and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Dec 9, 2024
@atsjo
Copy link
Author

atsjo commented Dec 9, 2024

I have now also tried via the emulator in android studio... None of the android 15 images there had the December update yet, so everything works fine for them. But the android 16 preview had the same problem as Android 15 QPR1 (December feature drop). So I guess some bug/change from android 16 have been included in android 15 qpr1, causing the issue... This should probably be reported as a bug to android...

@atsjo
Copy link
Author

atsjo commented Dec 10, 2024

To test this furter, I tried overriding the notificationclick handler in the service worker based on firebase js sdk with some code to log and focus my window, and used devtools remote debugging to see the logs from the service worker on my phone...

addEventListener('notificationclick', event => {
  const log = async () => {
    event.stopImmediatePropagation();
    event.notification.close();
    console.debug('notification', event.notification);
    console.debug('location', location.href);
    const clients = await sw.clients.matchAll({ type: 'window', includeUncontrolled: true });
    clients.forEach(o => console.debug('client', o));
    const client = clients.find(o => o.frameType === 'top-level');
    if (client) await client.focus();
  };
  event.waitUntil(log());
});

It crashes when running client.focus(), disconnecting the remote debugging.... But I can see the logging up until that point, so I guess this has to be fixed in chrome (by using some new api or acquiring some new permission needed by android 15 qpr1), or by fixing a bug introduced in android 15 qpr1....

@atsjo
Copy link
Author

atsjo commented Dec 10, 2024

I also confirmed it works to open a new window in the code above, by changing

if (client) await client.focus();

with

if (client) await sw.clients.openWindow(client.url);

So thats why clicking notifications works if no existing client is running.. Exchanging focus with openWindow means reloading the app, so this is not a working solution though...

Could someone at least acknowledge seeing the same problem as me? This is breaking my pwa on the latest android, which use push notifications for chat messages and other collaborative tasks. And it will probably break a lot of others as the latest android is rolled out to more devices...

As I assume this can't be fixed in firebase, I have open a bug in the chromium issue tracker: https://issues.chromium.org/issues/383355287

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

No branches or pull requests

3 participants