问题
I use Onesignal to push notification and need to cancel all notification of onPause and onResume,
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager!=null)
notificationManager.cancelAll();
but it's not work correctly. When app restarted I get all old notifications. I restard my app and these old notifications need to not showing. Please help to fix this!!
回答1:
You need to use this method from OneSignal SDK clearOneSignalNotifications
or for only one notifcation cancelNotification
.
Check here
来源:https://stackoverflow.com/questions/49111279/cancel-notification