If you want to just clear Notifications according to id's do it this way,
while notifiy notification from NotificationManager set a tag to your nofification's and save id's of notification's in a Arraylist like this
static ArrayList<String>notifIds=new ArrayList<>();
//your code
notificationManager.notify("myappnotif",NOTIFICATION_COUNT, builder.build());
notifIds.add(data);
now to remove Notifications call notificationManager.cancel(String tag, int id) wherever you want like this
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
for(int i=0;i<MainActivity.notifIds.size();i++){
notificationManager.cancel("myappnotif", i);
}
and to remove all Notification's when application start's call notificationManager.cancelAll(); in onCreate of Launcher Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}