Skip to content

Commit

Permalink
Merge pull request #129 from Pushwoosh/feature/PUSH-30011-add-clearno…
Browse files Browse the repository at this point in the history
…tificationcenter-method

[feature][PUSH-30011] Add clearNotificationCenter method
  • Loading branch information
nikolleto authored Nov 15, 2021
2 parents b049dfd + ecf9107 commit 859ecd2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ class PushNotification {
PushwooshModule.clearLocalNotification();
}

//Function: clearNotificationCenter
//Clears all existing and cancels all pending notifications
//
//Example:
//(start code)
// Pushwoosh.clearNotificationCenter();
//(end)
clearNotificationCenter(){
PushwooshModule.clearNotificationCenter();
}

//Function: register
//Call this to register for push notifications and retreive a push Token
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ public void clearLocalNotification(){
LocalNotificationReceiver.cancelAll();
}

@ReactMethod
public void clearNotificationCenter() {
if (AndroidPlatformModule.getManagerProvider() != null) {
if (AndroidPlatformModule.getManagerProvider().getNotificationManager() != null) {
AndroidPlatformModule.getManagerProvider().getNotificationManager().cancelAll();
}
}
}

@ReactMethod
public void setApplicationIconBadgeNumber(int badgeNumber) {
PushwooshBadge.setBadgeNumber(badgeNumber);
Expand Down
5 changes: 5 additions & 0 deletions src/ios/PushwooshPlugin/Pushwoosh.m
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ - (void)sendLocalNotificationWithBody:(NSString *)body delay:(NSUInteger)delay u
}
}

RCT_EXPORT_METHOD(clearLocalNotification){
[PushNotificationManager clearNotificationCenter];
}


RCT_EXPORT_METHOD(enableHuaweiPushNotifications) {
// available in Android only
}
Expand Down

0 comments on commit 859ecd2

Please sign in to comment.