firebase / firebase/firebase-js-sdk

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

Open
#9,213 5 comments 0 reactions 0 assignees View on GitHub
api: messaging bug reproducible
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.