Automating iOS 18 Contacts Permissions: A Better Approach

Abhishek Dhoundiyal
3 min readJan 13, 2025

--

Apple’s latest iOS 18 update introduced a new Contacts Limited Access Prompt, requiring automation frameworks like Appium to adapt. If you’re automating iOS apps, you might have encountered a frustrating scenario where the popup disrupts your tests, blocking further execution unless manually handled.

We’re happy to share that we have successfully fixed and improved the handling of this popup using a more streamlined approach. Here’s how we tackled it.

Understanding the Issue

In iOS 18, when an app requests access to Contacts, a Limited Access Prompt appears, controlled by:

📌 com.apple.ContactsUI.LimitedAccessPromptView

The prompt presents multiple options like:

  • “Allow Once”
  • “Allow Full Access”

If not handled correctly, this popup stalls automation, causing tests to fail or remain stuck indefinitely.

What’s New in Our Fix?

We implemented a three-step solution to ensure seamless interaction with the popup without breaking test flow.

🔹 Key Enhancements:

Dynamic App Focus:

  • The defaultActiveApplication setting is now updated dynamically to focus on the prompt when detected.

Automated Button Interaction:

  • Instead of relying on unreliable coordinates or image-based interactions, we use accessibility IDs to precisely click the “Allow Full Access” button.

Restoring Default Behavior:

  • Once the interaction is complete, defaultActiveApplication is reset to "auto", ensuring that the app resumes normal test execution.

🛠️ Steps Implemented in Code

We broke down the solution into three logical steps:

Step 1: Focus the Driver on the Prompt

The first step is to ensure Appium shifts focus to the Limited Access Prompt:

driver.setSetting("defaultActiveApplication", "com.apple.ContactsUI.LimitedAccessPromptView");

OR

driver.executeScript("mobile: activateApp", ImmutableMap.of("bundleId", "com.apple.ContactsUI.LimitedAccessPromptView"));

Step 2: Locate and Click the “Allow Full Access” Button

Once focused, we locate the “Allow Full Access” button using accessibility identifiers and click it:

WebElement allowFullAccessButton = driver.findElement(AppiumBy.accessibilityId("Allow Full Access"));
allowFullAccessButton.click();

Step 3: Reset the Driver Back to Default Mode

After interacting with the dialog, we reset defaultActiveApplication back to "auto", ensuring smooth continuation of tests:

driver.setSetting("defaultActiveApplication", "auto");

OR

driver.executeScript("mobile: activateApp", ImmutableMap.of("bundleId", "auto"));

💻 🚀💡Complete Code:

public void interactWithLimitedAccessPrompt() {
try {
// Step 1: Set defaultActiveApplication to "com.apple.ContactsUI.LimitedAccessPromptView"
driver.setSetting("defaultActiveApplication", "com.apple.ContactsUI.LimitedAccessPromptView");

// Step 2: Interact with the dialog elements
WebElement allowFullAccessButton = driver.findElement(AppiumBy.accessibilityId("Allow Full Access"));
allowFullAccessButton.click();
System.out.println("Clicked on 'Allow Full Access' button.");

// Step 3: Reset defaultActiveApplication to "auto"
driver.setSetting("defaultActiveApplication", "auto");
System.out.println("Reset defaultActiveApplication to 'auto'.");
} catch (Exception e) {
e.printStackTrace();
System.out.println("Failed to interact with the dialog managed by LimitedAccessPromptView.");
}
}

📌 Compatibility & Requirements

To use this fix, ensure you meet the following requirements:

  • Appium XCUITest Driver version: 7.26.4 or higher
  • Devices running: iOS 18+
  • Limited Access Prompt should be applicable to your test scenario

🚀 Why This Matters

This implementation enhances test automation for iOS 18+ by:

✔️ Reducing manual intervention during test runs
✔️ Ensuring reliability when interacting with permission popups
✔️ Improving overall automation efficiency by avoiding test stalls

If you’re automating iOS apps with Appium, this approach ensures seamless execution without interruptions.

🔗 References & Further Troubleshooting

For more details, check out the official Appium documentation:

📌 Troubleshooting Guide
📌 Settings Reference

If you have any questions or need guidance, feel free to reach out to me! 🚀

--

--

No responses yet