Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3252707
D6378.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6378.diff
View Options
diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
@@ -15,6 +15,7 @@
import com.google.firebase.messaging.RemoteMessage;
import java.util.HashMap;
import java.util.Map;
+import me.leolin.shortcutbadger.ShortcutBadger;
public class CommAndroidNotifications extends ReactContextBaseJavaModule {
private NotificationManager notificationManager;
@@ -86,6 +87,15 @@
notificationManager.createNotificationChannel(channel);
}
+ @ReactMethod
+ public void setBadge(int count) {
+ if (count == 0) {
+ ShortcutBadger.removeCount(this.getReactApplicationContext());
+ } else {
+ ShortcutBadger.applyCount(this.getReactApplicationContext(), count);
+ }
+ }
+
@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
diff --git a/native/push/android.js b/native/push/android.js
--- a/native/push/android.js
+++ b/native/push/android.js
@@ -14,6 +14,7 @@
description: ?string,
) => void,
+getConstants: () => { +NOTIFICATIONS_IMPORTANCE_HIGH: number, ... },
+ +setBadge: (count: number) => void,
...
};
export type AndroidForegroundMessage = {
diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js
--- a/native/push/push-handler.react.js
+++ b/native/push/push-handler.react.js
@@ -263,7 +263,7 @@
if (Platform.OS === 'ios') {
CommIOSNotifications.setBadgesCount(curUnreadCount);
} else if (Platform.OS === 'android') {
- getFirebase().notifications().setBadge(curUnreadCount);
+ CommAndroidNotifications.setBadge(curUnreadCount);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 6:32 PM (22 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2500517
Default Alt Text
D6378.diff (1 KB)
Attached To
Mode
D6378: Implement native method to update badge count and use it in JavaScript
Attached
Detach File
Event Timeline
Log In to Comment