Skip to content

Commit 952f310

Browse files
authored
Fix iOS screenshot workflow notification permission popup (#11)
1 parent 74f2b36 commit 952f310

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/ios-simulator-screenshots.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,24 @@ jobs:
336336
337337
xcrun simctl uninstall "$udid" "$BUNDLE_ID" || true
338338
xcrun simctl install "$udid" "$APP_PATH"
339+
340+
ensure_notification_permission() {
341+
local permission_state
342+
permission_state="$(xcrun simctl privacy "$udid" get notifications "$BUNDLE_ID" 2>/dev/null || true)"
343+
if [[ "$permission_state" == *"granted"* ]]; then
344+
return 0
345+
fi
346+
347+
xcrun simctl privacy "$udid" grant notifications "$BUNDLE_ID" || true
348+
}
349+
350+
# Avoid notification permission popups appearing in captured screenshots.
351+
ensure_notification_permission
339352
xcrun simctl launch "$udid" "$BUNDLE_ID"
340353
354+
# Some iOS runtimes only persist the permission after first launch.
355+
ensure_notification_permission
356+
341357
sleep "$STARTUP_WAIT_SECONDS"
342358
xcrun simctl io "$udid" screenshot "$shots_dir/00-launch.png"
343359
printf "00,launch,00-launch.png\n" >> "$shots_dir/manifest.csv"

0 commit comments

Comments
 (0)