1

I have attempted to call "addUIInterruptionMonitor" for App Tracking Transparency notification but it doesn't register and fails for my next step. Any help on what the description for this dialog is would be helpful, "System dialog" doesn't work.

"Allow ... to track your activity across other companies' apps and websites" "Ask app not to track" "Allow"

addUIInterruptionMonitor(withDescription: "System dialog") {
        (alert) -> Bool in
        if alert.buttons["Cancel"].exists {
            alert.buttons["Cancel"].tap()
            self.app.activate()
            return true
        }
        
        return false
    }

Allow ... to track your activity across other companies' apps and websites

user5462477
  • 111
  • 1
  • 6

2 Answers2

2

Found the solution, description I used is "Tracking Usage Permission Alert"

Was also an issue in the test itself waiting for a button to appear which only appears once this dialog is answered

addUIInterruptionMonitor(withDescription: "Tracking Usage Permission Alert") {
        (alert) -> Bool in
        if alert.buttons["Allow"].exists {
            alert.buttons["Allow"].tap()
            self.app.activate()
            return true
        }
        return false    
    }
user5462477
  • 111
  • 1
  • 6
  • 1
    How do you find out that the description was "Tracking Usage Permission Alert" ? This does not work for me somehow – Dinsen Jun 14 '21 at 13:28
  • 1
    I'm interested to know how to find the set of `withDescription` for various system dialogs. These must be documented somewhere!! – vk.4884 Sep 23 '21 at 15:59
0

You can try finding the alert via springboard.

The following Code Worked for me.

let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
// Alert Query
let permissionAlert = springboard.alerts["Allow “Your App Display Name” to track your activity across other companies’ apps and websites?"].firstMatch
// Check for existence
XCTAssertTrue(permissionAlert.waitForExistence(timeout: 1.0))
// Alert button query
let dialogButton = permissionAlert.buttons["Ask App Not to Track"].firstMatch
// Check for existance
XCTAssertTrue(dialogButton.waitForExistence(timeout: 1.0))
// Tap the button
dialogButton.tap()

Hope this helps.

Malav Soni
  • 2,739
  • 1
  • 23
  • 52