Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3254208
D6227.id20784.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D6227.id20784.diff
View Options
diff --git a/native/android/app/src/main/java/app/comm/android/MainApplication.java b/native/android/app/src/main/java/app/comm/android/MainApplication.java
--- a/native/android/app/src/main/java/app/comm/android/MainApplication.java
+++ b/native/android/app/src/main/java/app/comm/android/MainApplication.java
@@ -6,6 +6,7 @@
import androidx.annotation.NonNull;
import androidx.multidex.MultiDexApplication;
import app.comm.android.newarchitecture.MainApplicationReactNativeHost;
+import app.comm.android.notifications.CommAndroidNotificationsPackage;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
@@ -44,6 +45,7 @@
packages.add(new RNFirebaseMessagingPackage());
packages.add(new RNFirebaseNotificationsPackage());
packages.add(new KeyboardInputPackage(this.getApplication()));
+ packages.add(new CommAndroidNotificationsPackage());
return packages;
}
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
new file mode 100644
--- /dev/null
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
@@ -0,0 +1,38 @@
+package app.comm.android.notifications;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.service.notification.StatusBarNotification;
+import com.facebook.react.bridge.NativeModule;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.bridge.ReactContext;
+import com.facebook.react.bridge.ReactContextBaseJavaModule;
+import com.facebook.react.bridge.ReactMethod;
+
+public class CommAndroidNotifications extends ReactContextBaseJavaModule {
+ private NotificationManager notificationManager;
+
+ CommAndroidNotifications(ReactApplicationContext reactContext) {
+ super(reactContext);
+ Context context = reactContext.getApplicationContext();
+ this.notificationManager = (NotificationManager)context.getSystemService(
+ Context.NOTIFICATION_SERVICE);
+ }
+
+ @Override
+ public String getName() {
+ return "CommAndroidNotifications";
+ }
+
+ @ReactMethod
+ public void removeAllActiveNotificationsForThread(String threadID) {
+ for (StatusBarNotification notification :
+ notificationManager.getActiveNotifications()) {
+ String threadIDCharArray =
+ notification.getNotification().extras.getString("threadID");
+ if (threadIDCharArray != null && threadIDCharArray.equals(threadID)) {
+ notificationManager.cancel(notification.getTag(), notification.getId());
+ }
+ }
+ }
+}
diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsPackage.java b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsPackage.java
new file mode 100644
--- /dev/null
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotificationsPackage.java
@@ -0,0 +1,28 @@
+package app.comm.android.notifications;
+
+import com.facebook.react.ReactPackage;
+import com.facebook.react.bridge.NativeModule;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.uimanager.ViewManager;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class CommAndroidNotificationsPackage implements ReactPackage {
+
+ @Override
+ public List<ViewManager>
+ createViewManagers(ReactApplicationContext reactContext) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List<NativeModule>
+ createNativeModules(ReactApplicationContext reactContext) {
+ List<NativeModule> modules = new ArrayList<>();
+
+ modules.add(new CommAndroidNotifications(reactContext));
+
+ return modules;
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 7:35 PM (19 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2501655
Default Alt Text
D6227.id20784.diff (3 KB)
Attached To
Mode
D6227: Implement native Android module that can remove all active notifications for a given thread
Attached
Detach File
Event Timeline
Log In to Comment