diff --git a/index.js b/index.js index 572bfde..2d3c0cd 100644 --- a/index.js +++ b/index.js @@ -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 // diff --git a/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java b/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java index 8217ab4..575841e 100644 --- a/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java +++ b/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java @@ -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); diff --git a/src/ios/PushwooshPlugin/Pushwoosh.m b/src/ios/PushwooshPlugin/Pushwoosh.m index f89955a..a47fed7 100644 --- a/src/ios/PushwooshPlugin/Pushwoosh.m +++ b/src/ios/PushwooshPlugin/Pushwoosh.m @@ -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 }