How to detect system alerts/popups in Appium Java

Hi everybody!

I am currently developing test cases on both iOS and Android using Appium in JAVA. One issue that i am constantly facing is the uncontrolled manner system notifications pop-up (such as alerts for for enabling push notifications, allow the location to be used, etc.).

My question is: is there a way to detect when such an alert is presented on the screen? I am aware about the autoAcceptAlerts capability, but I am interested if there is any delegate method that is fired when an alert is visible on screen?

Thank you in advance!