Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clearLocalNotification method #711

Merged
merged 1 commit into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ public void cancelLocalNotifications(ReadableMap userInfo) {
mRNPushNotificationHelper.cancelScheduledNotification(userInfo);
}

@ReactMethod
/**
* Clear notification from the notification centre.
*/
public void clearLocalNotification(int notificationID) {
mRNPushNotificationHelper.clearNotification(notificationID);
}

@ReactMethod
public void registerNotificationActions(ReadableArray actions) {
registerNotificationsReceiveNotificationActions(actions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ public void clearNotifications() {
notificationManager.cancelAll();
}

public void clearNotification(int notificationID) {
Log.i(LOG_TAG, "Clearing notification: " + notificationID);

NotificationManager notificationManager = notificationManager();
notificationManager.cancel(notificationID);
}

public void cancelAllScheduledNotifications() {
Log.i(LOG_TAG, "Cancelling all notifications");

Expand Down
4 changes: 4 additions & 0 deletions component/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ NotificationsComponent.prototype.cancelLocalNotifications = function(details: Ob
RNPushNotification.cancelLocalNotifications(details);
};

NotificationsComponent.prototype.clearLocalNotification = function(details: Object) {
RNPushNotification.clearLocalNotification(details);
};

NotificationsComponent.prototype.cancelAllLocalNotifications = function() {
RNPushNotification.cancelAllLocalNotifications();
};
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ Notifications.cancelLocalNotifications = function() {
return this.callNative('cancelLocalNotifications', arguments);
};

Notifications.clearLocalNotification = function() {
return this.callNative('clearLocalNotification', arguments);
};

Notifications.cancelAllLocalNotifications = function() {
return this.callNative('cancelAllLocalNotifications', arguments);
};
Expand Down