Handler of addUIInterruptionMonitor is not called for Alert related to Photos

Bartłomiej Semańczyk picture Bartłomiej Semańczyk · Oct 11, 2016 · Viewed 8.5k times · Source
private func acceptPermissionAlert() {

    _ = addUIInterruptionMonitor(withDescription: "") { alert -> Bool in

        if alert.buttons["Don’t Allow"].exists { //doesnt get here second time

            alert.buttons.element(boundBy: 1).tapWhenExists()

            return true
        }

        return false
    }
}

and this doesnt work for:

enter image description here

In the beginning of the app, it works perfect while acepting permission for notifications, but here... doesnt work.

Do you know why?

Answer

Bartłomiej Semańczyk picture Bartłomiej Semańczyk · Oct 11, 2016

Add:

app.activate()

at the end of the method.

It will bring the app to foreground again (it will be in background because of the system alert)