How to handle push notification?

Code Snippet: //Here we have Initialized driver as AppiumDriver driver.findElement(By.id(“doc.saulmm.notification:id/simple_notification”)).click(); ((AndroidDriver) driver).openNotifications(); ListnotificationTitles = driver.findElements(By.id(“android:id/title”)); for (WebElement title: notificationTitles) { String extractTitle = title.getText(); if (extractTitle.contains(“I’m a simple notification”)) { …