Cordova-plugin-firebase: Badge should be set before opening the app.

Created on 7 Jan 2017  Â·  13Comments  Â·  Source: arnesson/cordova-plugin-firebase

As far as I understand... the badge needs to be displayed before the user opens the app, so the plugin would need to do it automatically with a config to be saved in the first app open and read when the app is in background and a new notification arrives.
The developer can update the badge number after the user interaction with the app.

Most helpful comment

@rolandjitsu What is the point of this. Just agree without really thinking
about it. With the other libraries you cannot set the notification while
app is in the background for Android. There is really minimal choose
supporting the badge functions just leave them there.

This is why the plugin community is so shitty and fragmented.

On Fri, Feb 3, 2017 at 6:37 AM Roland Groza notifications@github.com
wrote:

@robertarnesson https://github.com/robertarnesson I agree, the plugin
should only reflect Firebase's SDK APIs. As for badge, there is a more
comprehensive plugin out there.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/arnesson/cordova-plugin-firebase/issues/140#issuecomment-277261841,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACKNRI97zZ-snyLpAOEPuYRVn3IicWxdks5rYzuYgaJpZM4LdVWR
.

All 13 comments

on ios you can set the badge from the notification payload. But I'm considering removing all badge methods from this plugin since its not part of firebase. There are other plugins for handling the badge and they have more functionality

Please don't remove support for the badge or badge methods. Yes there are other plugins but the badge cannot be set from received push while app is in the background or closed (not in memory).

@robertarnesson I agree, the plugin should only reflect Firebase's SDK APIs. As for badge, there is a more comprehensive plugin out there.

@rolandjitsu What is the point of this. Just agree without really thinking
about it. With the other libraries you cannot set the notification while
app is in the background for Android. There is really minimal choose
supporting the badge functions just leave them there.

This is why the plugin community is so shitty and fragmented.

On Fri, Feb 3, 2017 at 6:37 AM Roland Groza notifications@github.com
wrote:

@robertarnesson https://github.com/robertarnesson I agree, the plugin
should only reflect Firebase's SDK APIs. As for badge, there is a more
comprehensive plugin out there.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/arnesson/cordova-plugin-firebase/issues/140#issuecomment-277261841,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACKNRI97zZ-snyLpAOEPuYRVn3IicWxdks5rYzuYgaJpZM4LdVWR
.

@jwebcat you cannot see badges in the background anyway. They are only visible when the screen is unlocked, right? If you'd like to be able to have your app work in the background, please see cordova-plugin-background-mode.

For badges, the same author has developed cordova-plugin-badge which, for Android, is using ShortcutBadger to provide support for more launchers since badges are not a thing in Android (see this post for more info).

Furthermore, please check the description of cordova-plugin-badge:

The essential purpose of badge numbers is to enable an application to inform its users that it has something for them — for example, unread messages — when the application isn’t running in the foreground.

I just stated my opinion on mixing Firebase related APIs with other unrelated functionality which has nothing todo with Firebase. But it's really not up to me, but to the authors of this plugin :)

@rolandjitsu

Yes agreed is up to the author of the plugin. But plugin authors sometimes
make decisions based on the feedback of the community, agreed?

I don't think you understood correctly what I meant. In order to add
support for the badge while app is in the background or closed, you only
have to add a couple lines of code to the onMessageReceived Java function,
because shortcut badger is already included with the plugin.

If the support was removed then adding support for background badge
notifications would involve adding shortcut badger to the Gradle file etc.

As badge notifications should be part of the push messaging, IMO, it makes
sense to have it be part of the plugin, whether firebase follows suit or
not.

On Fri, Feb 3, 2017 at 10:18 AM Roland Groza notifications@github.com
wrote:

@jwebcat https://github.com/jwebcat you cannot see badges in the
background anyway. They are only visible when the screen is unlocked,
right? If you'd like to be able to have your app work in the background,
please see cordova-plugin-background-mode
https://github.com/katzer/cordova-plugin-background-mode.

For badges, the same author has developed cordova-plugin-badge
https://github.com/katzer/cordova-plugin-badge which, for Android, is
using ShortcutBadger https://github.com/leolin310148/ShortcutBadger to
provide support for more launchers since badges are not a thing in Android
(see this http://stackoverflow.com/a/17565479/1092007 post for more
info).

I just stated my opinion on mixing Firebase related APIs with other
unrelated functionality which has nothing todo with Firebase. But it's
really not up to me, but to the authors of this plugin :)

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/arnesson/cordova-plugin-firebase/issues/140#issuecomment-277321741,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACKNRFQb_N8RXEV8IGgmYwr_1EQU9rC9ks5rY2-SgaJpZM4LdVWR
.

It should be noted that you can send a badge field with a push notification which automatically changes the badge number without the app having to be open.

It should be noted that you can send a badge field with a push notification which automatically changes the badge number without the app having to be open.

@ccorcos how would that be done with this plugin only. I can only see one method(onNotificationOpen()) that won't work for this case. I think we need a method like onNotificationReceived() or onNotification() for that right? Does anyone have ideas regarding this?

yes, i want the same functionality when notification recieved on IOS device at that time the badge should be change and Badge should be set before opening the app.

i check this onNotificationOpen() method. but when i tap on notification then it calls.

but is there a method that calls when the notification recieved on IOS device?

I think this comment is related and useful for me :)

How do I show my badge when my app is in the background?
https://github.com/arnesson/cordova-plugin-firebase/issues/183#issuecomment-291160150

on ios you can set it in the fcm payload.

closing as resolved

Was it resolved? Can you link the resolution? I'm struggling with this today.

Was this page helpful?
0 / 5 - 0 ratings