Open damandeepsinghbhatia opened 3 years ago
I have the same question. It appears that the setBackgroundMessageHandler event handler has been deprecated & no longer works.
The onBackgroundMessage handler only allows you to customize a notification, but it doesn't provide a means to completely prevent all notifications from showing; FCM will still show a default notification, even if this event handler is defined as a dummy function.
How does one go about implementing logic to conditionally display a background notification???
EDIT: nevermind, I found a work-around, which is to setup my push notification as a data-only message (i.e., don't include a 'notification' field in the push request), and handle the creation of the notification object within my 'onBackgroundMessage' handler...
@csurf brilliant!!!
yes but ios not worked if field notification exclude
can you teach me how to do that? I dun get how to remove notification field works
I have tried messaging.setBackgroundMessageHandler(function(payload){
}); unfortunately this is not working. I am using 8.2.9 version importScripts('https://www.gstatic.com/firebasejs/8.2.9/firebase-app.js'); importScripts('https://www.gstatic.com/firebasejs/8.2.9/firebase-messaging.js');