Add Android API to delete channel and channel group
This commit is contained in:
parent
bcd655d765
commit
57901cd29a
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1097,6 +1097,8 @@ declare module 'react-native-firebase' {
|
|||
channelGroups: Android.ChannelGroup[]
|
||||
): Promise<void>;
|
||||
createChannels(channels: Android.Channel[]): Promise<void>;
|
||||
deleteChannelGroup(groupId: string): Promise<void>;
|
||||
deleteChannel(channelId: string): Promise<void>;
|
||||
}
|
||||
|
||||
interface Notifications {
|
||||
|
|
|
@ -91,4 +91,32 @@ export default class AndroidNotifications {
|
|||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
deleteChannelGroup(groupId: string): Promise<void> {
|
||||
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<void> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue