firebase / firebase/firebase-js-sdk

navigator.setAppBadge does not work within onBackgroundMessage

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

Description

### Operating System

macOS 14.4.1 and iOS 17.5.1

### Browser Version

Chrome (macOS) and Safari PWA (iOS)

### Firebase SDK Version

10.4.0

### Firebase SDK Product:

Messaging

### Describe your project's tooling

Reace - CRA

### Describe the problem

within messaging.onBackgroundMessage, I'm unable to get navigator.setAppBadge to work in my service worker file.

But if I use navigator.setAppBadge when service worker initiates, it works as expected.

### Steps and code to reproduce issue

```
messaging.onBackgroundMessage((payload) => {

++badgeCounter;

console.log("badgeCounter", badgeCounter);

navigator.setAppBadge(badgeCounter);
}
```

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.