diff --git a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java index a6d8a5ef..ba8d8231 100644 --- a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java +++ b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java @@ -129,6 +129,18 @@ public class RNFirebaseNotificationManager { } } + public void deleteChannelGroup(String groupId) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + notificationManager.deleteNotificationChannelGroup(groupId); + } + } + + public void deleteChannel(String channelId) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + notificationManager.deleteNotificationChannel(channelId); + } + } + public void displayNotification(ReadableMap notification, Promise promise) { Bundle notificationBundle = Arguments.toBundle(notification); displayNotification(notificationBundle, promise); diff --git a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java index f8236e23..d9ffd5c3 100644 --- a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java +++ b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java @@ -157,6 +157,18 @@ public class RNFirebaseNotifications extends ReactContextBaseJavaModule implemen notificationManager.createChannels(channelsArray); promise.resolve(null); } + + @ReactMethod + public void deleteChannelGroup(String channelId, Promise promise) { + notificationManager.deleteChannelGroup(channelId); + promise.resolve(null); + } + + @ReactMethod + public void deleteChannel(String channelId, Promise promise) { + notificationManager.deleteChannel(channelId); + promise.resolve(null); + } ////////////////////////////////////////////////////////////////////// // End Android specific methods ////////////////////////////////////////////////////////////////////// diff --git a/lib/index.d.ts b/lib/index.d.ts index 695d9bf3..c7bf9fb2 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1097,6 +1097,8 @@ declare module 'react-native-firebase' { channelGroups: Android.ChannelGroup[] ): Promise; createChannels(channels: Android.Channel[]): Promise; + deleteChannelGroup(groupId: string): Promise; + deleteChannel(channelId: string): Promise; } interface Notifications { diff --git a/lib/modules/notifications/AndroidNotifications.js b/lib/modules/notifications/AndroidNotifications.js index bd644a60..6873f052 100644 --- a/lib/modules/notifications/AndroidNotifications.js +++ b/lib/modules/notifications/AndroidNotifications.js @@ -91,4 +91,32 @@ export default class AndroidNotifications { } return Promise.resolve(); } + + deleteChannelGroup(groupId: string): Promise { + if (Platform.OS === 'android') { + if (typeof groupId !== 'string') { + throw new Error( + `AndroidNotifications:deleteChannelGroup expects an 'string' but got type ${typeof groupId}` + ); + } + return getNativeModule(this._notifications).deleteChannelGroup( + groupId + ); + } + return Promise.resolve(); + } + + deleteChannel(channelId: string): Promise { + if (Platform.OS === 'android') { + if (typeof channelId !== 'string') { + throw new Error( + `AndroidNotifications:deleteChannel expects an 'string' but got type ${typeof channelId}` + ); + } + return getNativeModule(this._notifications).deleteChannel( + channelId + ); + } + return Promise.resolve(); + } }