Alert appears twice on application startup

Appium 2.0. IOS 15.4, 15.5.

At the start of each test, the IOS app is reinstalled, and, consequently, an alert about allowing notifications to be sent appears. To skip the alert, we used the switchTo().alert().accept() methods and by pressing to accept the alert directly as a web element. Once in about 100-150 tests the alert is skipped, literally 1 driver action occurs, and the alert appears a second time. What could be the reason for the alert appearing twice? Is it the appium or maybe it’s the application?

why you need to start ALL tests with reinstall?

The problem here is not with the installation of the application. (the installation is caused by the feature of the simulator)

I mean if it possible to reduce reinstall count the problem will be solved itself.
Regarding problem: if you see on video that you tap successfully Allow and same dialog appears again → nothing can be done from appium side. The only you can add double check that dialog missing but it slows most other tests.

that’s why I want to understand the problem, rather than add additional validation on the second potential alert