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

Samsung running Android 8 is reported as supported, but is not #266

Open
eirikwah opened this issue Feb 27, 2018 · 12 comments · May be fixed by #268
Open

Samsung running Android 8 is reported as supported, but is not #266

eirikwah opened this issue Feb 27, 2018 · 12 comments · May be fixed by #268

Comments

@eirikwah
Copy link

Tested on Samsung Galaxy S8 running Android 8.0 (Oreo).

Calling ShortcutBadger.isBadgeCounterSupported(context) returns true, but setting the badge has no effect. (This worked correctly before updating from Android 7.1 to Android 8.0.)

It seems that the Samsung launcher on Android 8.0 rather uses the normal Android 8 function for badges instead (coupling it to active notifications).

Data from "IsBadgeWorking?":

deviceModel: "SM-G950F"
deviceBrand: "samsung"
shortcutBadgerVersion: "1.1.18"
androidVersion: "8.0.0"
launcherPackage: "com.sec.android.app.launcher"
launcherVersionName: "9.0.01.84"
launcherVersionCode: "900106084"

eirikwah added a commit to eirikwah/ShortcutBadger that referenced this issue Feb 28, 2018
Note that the DefaultBadger also must check for Samsung on Android 8, or
it will be used on those devices.

This fixes leolin310148#266
@eirikwah
Copy link
Author

I have now submitted a pull request, #268, as my suggestion to how to fix this.

@eirikwah
Copy link
Author

eirikwah commented Mar 5, 2018

Just a clarification: On Samsung Galaxy S8 with Android 8.0, badges are still supported, but not by the same API as before, and it behaves differently.

Users can configure the "app icon badges" in the "Home screen settings". Users can choose to turn off badges, to show them without number, or show them with a number. This is a global setting for all apps, and app developers (such as us users of ShortcutBadger) can not override this.

In addition, badges can be disabled per app in the app settings.

Badges are only shown while there are visible notifications for the app. The number shown (if enabled by the user) is either the number of visible notifications, or the value set in the notification API method NotificationCompat.Builder.setNumber(int) when creating the notification.

And to be clear: In my opinion, I don't think this new way of adding app icon badges should be a part of the ShortcutBadger API. When creating notifications, app developers should always call NotificationCompat.Builder.setNumber(int) regardless. So ShortcutBadger can co-exist, and take effect on the still supported devices/Android versions.

@canberkcakmak
Copy link

@eirikwah i have a same problem. But i can't understand how you solve this. Please help me. Thank you

@eirikwah
Copy link
Author

@canberkcakmak, you can see my suggested fix at the pull request #268. However, if you do not want to build a fork of ShortcutBadger, the fix is simply this wrapper code:

public boolean isBadgeCounterSupported() {
    // Workaround for bug in ShortcutBadger in version 1.1.19, registered as
    // https://github.com/leolin310148/ShortcutBadger/issues/266
    if (Build.MANUFACTURER.equalsIgnoreCase("Samsung") && Build.VERSION.SDK_INT >= 26) {
        Log.d("LOG_TAG", "Launcher icon badge (ShortcutBadger) is not supported on Samsung devices running Android 8 (or newer).");
        return false;
    }

    return ShortcutBadger.isBadgeCounterSupported(context);
}

As for applying badges from your notifications, see the Android documentation, and note the section "Set custom notification count".

@7fe
Copy link

7fe commented Mar 22, 2018

I don't have a Samsung device to test this, but I have to ask(Running a Nexus right now).

Will Nova Launcher(with Tesla unread) now not work on Samsung Oreo devices with this update?

I need to read more of the code but I'm assuming the answer is yes it works fine.

EDIT: I support this assuming it doesn't break Nova Launcher(and other install able launchers).

@eirikwah
Copy link
Author

I don't have a Samsung device to test this, but I have to ask(Running a Nexus right now).

Will Nova Launcher(with Tesla unread) now not work on Samsung Oreo devices with this update?

I need to read more of the code but I'm assuming the answer is yes it works fine.

I do have a Samsung Galaxy S8 running Oreo, but I don't want to buy "Nova Launcher Prime" to test badges. I did test "Nova Launcher" (the free version), and this does not support badges on Samsung Galaxy S8 running Oreo. (I did the testing without the pull request #268 applied).

@zengziwei789
Copy link

zengziwei789 commented Apr 11, 2018

@eirikwah for Android 8, if the app has active notifications, there will be count on the launch icon. Will your fix just replace that count with your own. Or you do combine them together?

Update: It looks like the new badge will replace the original one by the system.

@SaeedRe
Copy link

SaeedRe commented Jun 23, 2018

One alternative way is to create a low importance notification channel and set the setShowBadge(true);, and then set the badge number on Notification builder with setNumber(int); and show it when the app starts.
In this way a small notification always will be visible in the notification panel and when user dismiss it, the badge will be gone.

@Harmonickey
Copy link

@eirikwah so what are users of Ionic 3/4 (inherently using https://github.com/katzer/cordova-plugin-badge plugin) supposed to do because they don't have a choice to just use setNumber()? Do we just need to wait for an update to ShortcutBadger? But you say it shouldn't even be a part of the ShortcutBadger API... This is a pressing issue right now for Ionic developers deploying to the newest Android versions in the market.

@eirikwah
Copy link
Author

@eirikwah so what are users of Ionic 3/4 (inherently using https://github.com/katzer/cordova-plugin-badge plugin) supposed to do because they don't have a choice to just use setNumber()? Do we just need to wait for an update to ShortcutBadger? But you say it shouldn't even be a part of the ShortcutBadger API... This is a pressing issue right now for Ionic developers deploying to the newest Android versions in the market.

Hi, @Harmonickey. I am not familiar with Cordova nor Ionic, so this is a generic answer:

It seems that @leolin310148 or other contributors have not had the time to update this project in a while. I myself have not forked this project and created any new release, as I did find a workaround that worked for my project (see my previous comments).

However, is not a big problem that the fix is not merged into the main branch and released, as this is open source. :-) I suggest that you fork this project (feel free to include my pull request and/or code from the previous comments on this issue). Then you can include these changes in Cordova by following the guide they have written at https://github.com/katzer/cordova-plugin-badge#contributing .

Sorry for (probably) not giving you the answer you were looking for. I hope things work out for your project.

@Harmonickey
Copy link

@eirikwah no worries, I appreciate the thoughtful response. I give your suggestions a try.

@rakshithshettycs
Copy link

@eirikwah
If all notifications are received from FCM cloud messaging, is it possible to reset the badge count to 0 locally upon opening the app without clearing notifications from the notification bar?

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

Successfully merging a pull request may close this issue.

7 participants