Skip to content

[Bug]: Null check error on flutter web when notification permissions are reset #9213

@paramsinghvc

Description

@paramsinghvc

Operating System

macOS 15.6

Environment (if applicable)

Chrome 139.0.7258.128

Firebase SDK Version

10.13.2

Firebase SDK Product(s)

Messaging

Project Tooling

Flutter web app with Firebase setup and firebase messaging

Detailed Problem Description

Having setup a demo Flutter project with latest versions after I faced the same issue in my production Flutter app, I'm facing this error

token-manager.ts:102 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'pushManager')

  | Mt | @ | token-manager.ts:102
  | await in Mt |   |  
  | (anonymous) | @ | sw-listeners.ts:60
  | (anonymous) | @ | register.ts:84

Image

Apparently the swRegistration is expected to be present and asserted in the code.

 await messaging.swRegistration!.pushManager.getSubscription();

During the first time when the app is loaded, everything is perfect but the moment you reset the permissions on the app settings in the address bar menu and then reload the page and go through the permissions flow again, it throws this error.

Image

Steps and code to reproduce issue

Live App Link: https://pushtest-df676.web.app/

  • Open the dev console.
  • Notice the fcm token
  • Reset the app permissions from app settings in the chrome address bar
  • Reload
  • Notice the error in the console

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions