Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Please help add an option to enable / disable auto notifications on Firebase Messaging. #8818

Open
tiennguyen1293 opened this issue Feb 28, 2025 · 4 comments

Comments

@tiennguyen1293
Copy link

Operating System

MacOS 14.6.1

Environment (if applicable)

Chrome 133.0.6943.142

Firebase SDK Version

^11.3.1

Firebase SDK Product(s)

Messaging

Project Tooling

I built a Google Extension with Firebase Messaging

Detailed Problem Description

I am facing an issue with duplicate notifications between my custom notification and Firebase auto-notification. I am using a single Firebase project for both Android and the Extension, causing duplication.

Steps and code to reproduce issue

Init Firebase Messaging and add more

self.registration.showNotification('This is title', {
      title: '',
      body: 'This is body',
      icon: 'images/logo.png',
      data: {
         ...
      },
    })
@tiennguyen1293 tiennguyen1293 added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Feb 28, 2025
@jbalidiong jbalidiong added api: messaging and removed question new A new issue that hasn't be categoirzed as question, bug or feature request labels Feb 28, 2025
@DellaBitta
Copy link
Contributor

Hi @tiennguyen1293,

By Auto Notifications, do you mean notifications originating form Firebase Services like Database, etc. I believe this would require a Firebase service change and we can't achieve this by updating the SDK's API. I recommend reaching out to Firebase Support, they should be able to handle this feature request.

If I'm misunderstanding then please let us know. Thanks!

@tiennguyen1293
Copy link
Author

Thank you for your quick response, @DellaBitta.

I am using onBackgroundMessage from firebase/messaging/sw, and this triggers an automatic push notification if my data message contains notification:

{
  "to": "<FCM_TOKEN>",
  "data": {
    "title": "Your Custom Title",
    "body": "Your Custom Message",
    "customKey": "customValue"
  },
  "content_available": true,
  "priority": "high",
  "notification": {
    "title": "Hello User!",
    "body": "This is an auto-displayed notification",
    "image": "https://example.com/image.jpg"
  }
}

However, I cannot remove notification since it is related to other platforms using the same Firebase project.

That’s what I mean—do we have a way to prevent this from initializeApp?

import { initializeApp, getApps } from 'firebase/app'
import { getToken } from 'firebase/messaging'

app = initializeApp({ ...firebaseConfig, isDisableAutoPushNotification: true })
const messaging = getMessaging(app)

Thanks for your help.

@hsubox76
Copy link
Contributor

hsubox76 commented Mar 6, 2025

Ok, I see. Confirmed, onBackgroundMessage() does always display a notification when received, if the payload has a "notification" property. We'll count this is a feature request.

@HourtashHAJI
Copy link

Operating System

MacOS 14.6.1

Environment (if applicable)

Chrome 133.0.6943.142

Firebase SDK Version

^11.3.1

Firebase SDK Product(s)

Messaging

Project Tooling

I built a Google Extension with Firebase Messaging

Detailed Problem Description

I am facing an issue with duplicate notifications between my custom notification and Firebase auto-notification. I am using a single Firebase project for both Android and the Extension, causing duplication.

Steps and code to reproduce issue

Init Firebase Messaging and add more

self.registration.showNotification('This is title', {
      title: '',
      body: 'This is body',
      icon: 'images/logo.png',
      data: {
         ...
      },
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants