-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
bug(badge): set(...)
only works after creating a notification.
#3
Comments
Can you provide a screen recording so that I better understand the problem? |
This comment was marked as resolved.
This comment was marked as resolved.
You need to await the promise: function async setBadge() {
console.log("Setting badge count to: ", this.badgeCount);
await Badge.set({ count: this.badgeCount });
const result = await Badge.get();
console.log("Get Badge Count: ", result);
} |
I'm facing the same problem in Android. I've got this reponse from plugin in Chrome console:
But the icon badge is not showing. |
@felipenunesdev The app needs to be installed as PWA. Edited: I updated the docs. |
@robingenz Thanks for your reply! Actually I'm using a native app. In IOS it works like a charm, the icon badge shows the correct counter, but in Android the badge is not showing. |
@robingenz the |
@felipenunesdev Please have a look at the documentation:
Not all Android launcher are supported. Please have a look at ShortcutBadger and check if your device is supported. If you have more questions, please create a new issue. |
This comment was marked as resolved.
This comment was marked as resolved.
@mahen23 Please provide a Minimal, Reproducible Example (see How to create a Minimal, Reproducible Example) so I can debug the issue. |
This comment was marked as resolved.
This comment was marked as resolved.
@mahen23 Can you please publish the example as GitHub repo? |
This comment was marked as resolved.
This comment was marked as resolved.
Just create a normal GitHub repository and push all files:
|
This comment was marked as resolved.
This comment was marked as resolved.
|
This comment was marked as resolved.
This comment was marked as resolved.
You should only pass integers as count.
Besides that, please let me know if this demo works for you: https://capacitor-plugin-demo-robingenz.vercel.app/badge |
This comment was marked as resolved.
This comment was marked as resolved.
This is the first time you have referred to Android. You have specified I will take another look soon. |
Hey @robingenz, I've created a sample Capacitor app here: https://github.com/dtarnawsky/cs-badge. The problem appears to be Android specific and requires you to have sent at least one notification to the app for the badge to appear. The sample app has a button to send a local notification to the app in order for the badge to begin showing. This may be a requirement of Android and it appears that the Cordova plugin |
@dtarnawsky Great, thanks for pointing this out! |
set(...)
only works after creating a notification.
I set a bounty of $50 to solve the issue. I am looking for a clean solution, not a workaround. There is no guarantee that a solution exists. |
In case a notification is needed... FYI: Just tossing an idea, didn't look at the details (yet). 😊 |
Plugin version:
Platform(s):
generic #91~18.04.1-Ubuntu SMP Fri Jul 23 13:36:29 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Current behavior:
Using Badge.set does not work, but works after creating a notification
Expected behavior:
Badge.set should work fine.
Steps to reproduce:
Badge.clear();
Badge.set({count: 10});
console.log("Badge Count: ", Badge.get()); // count is 0
Related code:
Other information:
Capacitor doctor:
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 4.6.2
@capacitor/core: 4.6.2
@capacitor/android: 4.6.2
@capacitor/ios: 4.6.2
Installed Dependencies:
@capacitor/cli: 4.4.0
@capacitor/ios: 4.4.0
@capacitor/core: 4.4.0
@capacitor/android: 4.4.0
[success] Android looking great! 👌
The text was updated successfully, but these errors were encountered: