firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.71k stars 3.97k forks source link

🐛 [firebase_messaging] getNotificationSettings() doesn't return correct settings in PWA after user changed the permission from device Settings UI #11369

Open dioseltorre opened 1 year ago

dioseltorre commented 1 year ago

Bug report

Describe the bug In iOS PWA, getNotificationSettings() doesn't return the correct current notification settings after the user changed the notification permission manually from the device Settings UI. But in Android PWA it returns the settings correctly.

Steps to reproduce

Steps to reproduce the behavior:

  1. Launch the PWA from Homescreen
  2. On app startup, tap the Request Permissions button, tap Deny when permission popup is shown
  3. This should return the settings with AuthorizationStatus.denied value
  4. Go to Settings -> Notifications -> yourAppName
  5. Turn On the Allow Notifications toggle
  6. Return to the app
  7. Tap the Reload Permissions button. This still returns the settings with AuthorizationStatus.denied value

Expected behavior

It should return the settings with AuthorizationStatus.authorized value.

Sample project

reproducible_example.zip

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.10.4, on Microsoft Windows [Version 10.0.22621.1992], locale en-US) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [√] Chrome - develop for the web [!] Visual Studio - develop for Windows (Visual Studio Build Tools 2017 15.9.9) X Visual Studio 2019 or later is required. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2022.1) [!] Android Studio (version 4.1) X Unable to determine bundled Java version. [√] VS Code (version 1.80.1) [√] Connected device (3 available) [√] Network resources ! Doctor found issues in 2 categories. ```

danagbemava-nc commented 1 year ago

Hi @dioseltorre, can you share a minimal reproducible code sample in a repo that we can clone so we can verify this? I tried using the plugin example but safari can't get the permission.

Also, what version of firebase_messaging are you using?

dioseltorre commented 1 year ago

Hi @danagbemava-nc, I've attached the reproducible code please check on the Sample project section. Also, you can try this sample app and check the PWA behavior by adding it to your device Homescreen.

Also, what version of firebase_messaging are you using?

I'm using the versions below:

  firebase_core: ^2.14.0
  firebase_messaging: ^14.6.4
danagbemava-nc commented 1 year ago

Hi @dioseltorre, just for reference, what android device did you test this on? On my pixel 7 I get the same behaviour as the iOS device.

dioseltorre commented 1 year ago

Hi @dioseltorre, just for reference, what android device did you test this on? On my pixel 7 I get the same behaviour as the iOS device.

@danagbemava-nc Below are the Android device information and also the sample video of the behavior.

Device: Samsung Galaxy A31 OS: Android 12 Chrome version: 114.0.5735.196

https://github.com/firebase/flutterfire/assets/14935048/73cb5029-34ee-46c6-be4d-3ddf99514687

danagbemava-nc commented 1 year ago

Thanks for the info. It seems like it might work on some devices but not work on others. This might be more a flutter issue than an actual issue with flutterfire, but for now I'll label this for further insight from the team.

iOS Pixel 7