invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

Update ShortcutBadger #356

Closed MatthieuPeyrot closed 7 years ago

MatthieuPeyrot commented 7 years ago

Hi

I have an issue on my samsung galaxy S6 , it crash when i try to update the badgeNumber. I thing it because you are not using the last version of ShortcutBadger

you are using : compile 'me.leolin:ShortcutBadger:1.1.10@aar' now it's : compile 'me.leolin:ShortcutBadger:1.1.18@aar'

that's the crash :

0 | io.invertase.firebase.messaging.BadgeHelper.setBadgeCount | BadgeHelper.java:33 1 | io.invertase.firebase.messaging.MessagingService.handleBadge | MessagingService.java:41 2 | io.invertase.firebase.messaging.MessagingService.onMessageReceived | MessagingService.java:23 3 | com.google.firebase.messaging.FirebaseMessagingService.handleIntent | Unknown Source 4 | com.google.firebase.iid.zzc.run | Unknown Source 5 | java.util.concurrent.ThreadPoolExecutor.runWorker | ThreadPoolExecutor.java:1133 6 | java.util.concurrent.ThreadPoolExecutor$Worker.run | ThreadPoolExecutor.java:607 7 | java.lang.Thread.run | Thread.java:762

  1. Target Platform (Android):
  2. Development Operating System (macOS Sierra):
  3. React Native version (0.47.2):
  4. RNFirebase Version (2.1.3):
MatthieuPeyrot commented 7 years ago

screenshot_20170824-125516

gusgard commented 7 years ago

Have the same issue but using the last version of me.leolin:ShortcutBadger:1.1.18@aar doesn't fix it.

MatthieuPeyrot commented 7 years ago

Me neither

chrisbianca commented 7 years ago

@MatthieuPeyrot I'm unable to reproduce this. Can you send the contents of your app/build.gradle?

MatthieuPeyrot commented 7 years ago

hi i maybe find a solution i don't have the red screen by adding this in the build.gradle

repositories { mavenCentral() }

but the notif badge don't change on my samsung device.

erezrokah commented 7 years ago

The ShortcutBadger lib has an app to test if it works on your phone: https://play.google.com/store/apps/details?id=me.leolin.isbadgeworking

I got the link from their repo: https://github.com/leolin310148/ShortcutBadger

We tried it on several phones and only one of them actually showed the badge

MatthieuPeyrot commented 7 years ago

it work on the samsung galaxy s5 (android 6 )but not on the s6 edge (android 7 ) But i have to add compile 'me.leolin:ShortcutBadger:1.1.18@aar' and repositories { mavenCentral() } on my build.gradle not on react native firebase that's weird

chrisbianca commented 7 years ago

I've updated the dependency to the latest version of Shortcut Badger for the upcoming v3 release

cluny85 commented 7 years ago

Still happen this problem with the last version. I don't know why because i can see ShortcutBadger exported like a Library in the react-native-firebase project. But it works like @MatthieuPeyrot said. Could be my version of gradle (2.3.3)? is necessary to have 3.0> ?

hegelstad commented 6 years ago

This still happens with latest build.

kkusanagi commented 6 years ago

There is no documentation after v3.3.x. I think they had remove it.

haseebnaseem commented 6 years ago

Still happening with 4.2.0

turboc commented 6 years ago

implementation "com.google.firebase:firebase-messaging:17.1.0" implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

I've downloaded the 'isBadgeWorking?' in a Samsung and it's working. But it does not work when my app receives a message and shows the notification.

kkusanagi commented 6 years ago

About this, it got a simple method. Follow the step below. react-native-push-notifications-with-firebase-cloud-functions

Use below payload while sending notification.

let payload = {
      notification: {
      title: 
      body:
      sound:
      badge:
     }
    }

Or,

Use firebase console to send a notification to your mobile phone by token. Of course, you can also send a notification to all mobile that use the app.

if your phone receive notification, mean it works. if not, there is something wrong with your setting.

Finally as for this thread issue, you need to use

firebase.notifications().setBadge(10). //to set badge number

firebase.notifications().getBadge() // to get badge number

Firebase Notification Library

Biplovkumar commented 4 years ago

implementation "com.google.firebase:firebase-messaging:17.1.0" implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

I've downloaded the 'isBadgeWorking?' in a Samsung and it's working. But it does not work when my app receives a message and shows the notification.

thanku so much @turboc . u saved my day.

mikehardy commented 4 years ago

Careful - ShortcutBadger hasn't really been updated in 2 years https://github.com/leolin310148/ShortcutBadger - it doesn't work on all vendors and Google specifically will not support badging. Attempting to do badging on Android is fighting the platform - something that always results in resources spent for little gain

huent-1493 commented 3 years ago

Hi, I have a issue: setBadge(0) in android not working , getBadge() in android is 0 but in icon app show number >0.

    const currentNumber = await firebase.notifications().getBadge()
    console.log('currentNumber ', currentNumber) // in here currentNumber = 0
    if (number <= 0) {
      await firebase.notifications().setBadge(0)
      // go to here but in icon app, badge >0
    } else {
      await firebase.notifications().setBadge(number)
    }

Please help me. "react-native-firebase": "5.5.6" "react-native": "0.63.3"

mikehardy commented 3 years ago

No help whatsoever is offered for react-native-firebase v5 And specifically, badging in general is an anti-pattern on Android because it is not part of the platform and specifically not a desired feature in AOSP. It was removed on purpose