Skip to content

Commit b7c8b0f

Browse files
committed
Implemented clearNotificationsFromNotificationCenter
1 parent d9af4fc commit b7c8b0f

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ declare module 'cleverpush-react-native' {
1616
static setAutoResubscribe(autoResubscribe: boolean): void;
1717
static setBadgeCount(count: number): void;
1818
static getBadgeCount(callback: (error, count: number) => void): void;
19+
static clearNotificationsFromNotificationCenter(): void;
1920

2021
static addEventListener(
2122
type: EventType,

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,11 @@ export default class CleverPush {
293293

294294
RNCleverPush.getBadgeCount(callback);
295295
}
296+
297+
// iOS only
298+
static clearNotificationsFromNotificationCenter() {
299+
if (!checkIfInitialized()) return;
300+
301+
RNCleverPush.clearNotificationsFromNotificationCenter();
302+
}
296303
}

ios/RCTCleverPush/RCTCleverPushEventEmitter.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#import "RCTCleverPushEventEmitter.h"
22
#import <CleverPush/CleverPush.h>
3+
#import <UserNotifications/UserNotifications.h>
34

45
#import "RCTCleverPush.h"
56

@@ -237,4 +238,8 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body {
237238
[CleverPush setShowNotificationsInForeground:show];
238239
}
239240

241+
RCT_EXPORT_METHOD(clearNotificationsFromNotificationCenter) {
242+
[[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
243+
}
244+
240245
@end

0 commit comments

Comments
 (0)