pwa-builder / PWABuilder

The simplest way to create progressive web apps across platforms and devices. Start here. This repo is home to several projects in the PWABuilder family of tools.
https://docs.pwabuilder.com
Other
2.71k stars 280 forks source link

[BUG] In android 13+ push notification permission is not getting enabled. #4817

Closed akshaywali closed 1 week ago

akshaywali commented 1 week ago

What happened?

On Android 13+ the push notification permission is disabled by default . Using One Signal we are able to show permission prompt but notification permission is still being disabled . This Issue has nothing to do with One Signal since we tried with custom service worker code as well but it didn't worked.

Point to note is that if you got to app notification setting it is disabled (as it should) but you can not enable it manually .

When added notification permission to AndroidManifest.xml <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> then we were able to manually enable it but still it was not getting enabled by accepting notification prompt.

Since notification permission is enabled by default in Android 12 and below so it is working fine on them.

Hoping for some fix from your side.

How do we reproduce the behavior?

  1. Add push notification support to your PWA website
  2. Generate APK with enableNotification flag as true.
  3. Install apk on Android 13+
  4. Open app and accept notification prompt
  5. Go to app setting and check notification section, you will find that permission is still not enabled.

What do you expect to happen?

There are substantial changes in Notification API in Android 13+. So somehow enableNotification is missing some implementation to match these changes. Normally notification should be enabled when prompt is accepted.

What environment were you using?

OS: ANDROID 14 CHROME : 129.0.6668.54 Android System Webview : 128.0.6613.146

Additional context

No response

maiconcarraro commented 1 week ago

@akshaywali I'd recommend you to open the issue on https://github.com/GoogleChromeLabs/bubblewrap that's the actual CLI that PWABuilder uses behind the scene, or open the issue on android-browser-helper that is the actual dependency to handle notification https://github.com/GoogleChrome/android-browser-helper/issues

I have a question, what's your actual device? is it a Samsung? I helped a person through discord that had a similar issue, it was related to their Samsung device, I tested w/ Google Pixel and the notification worked without having to enable it. If that's related I'd also recommend opening an issue on Samsung similar to this https://eu.community.samsung.com/t5/galaxy-s23-series/app-notifications-blocked/td-p/8583480/page/2

maiconcarraro commented 1 week ago

This is the PR to support notification on Android +13 https://github.com/GoogleChromeLabs/bubblewrap/pull/731 so definitely looks like a bug for specific manufacturers, it may have some workaround or may depend on their own solution.

jgw96 commented 1 week ago

I have also tested this on my Pixel and notifications work fine, same thing on my co-workers device. She also has a Pixel, although an older one. I agree with @maiconcarraro here and will be closing this one for now. Thanks all!

akshaywali commented 1 week ago

@maiconcarraro @jgw96 Thanks for your valuable insights. Yes actually the issue is with bubblewrap but https://github.com/GoogleChromeLabs/bubblewrap/pull/731 didn't helped me . Will be opening ticket in bubblewrap repo soon. I have tested this on Samsung , One Plus, Motorola and Nokia phones. Although it is working in Pixel but we have multiple client having millions of users , so we are looking for a general solution rather then just telling them it works on this and not that :)

maiconcarraro commented 1 week ago

@akshaywali I understand and agree, but this repo is not the maintainer of the generated apk, it's just a wrapper, I shared some evidence with you that may help you where to open the issue.

The PR that I sent is just an example of a random dev fixing one of the issues in the correct repo.

akshaywali commented 1 week ago

@maiconcarraro Yes I completely understand your point and will be opening ticket at https://github.com/GoogleChromeLabs/bubblewrap/pull/731 after doing some further testing of the issue. Thank you very much for your help.