Skip to content

feat(ios): set notification permission on simulators through SpringBoard's settings file - #5046

Closed
imranbarbhuiya wants to merge 9 commits into
callstack:mainfrom
imranbarbhuiya:feat/ios-sim-notification-permission
Closed

imranbarbhuiya wants to merge 9 commits into
callstack:mainfrom
imranbarbhuiya:feat/ios-sim-notification-permission

Conversation

@imranbarbhuiya

@imranbarbhuiya imranbarbhuiya commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #4668. Follow-up to #4667.

simctl privacy refuses notifications, so settings permission … notifications on an iOS simulator always failed and all skipped it.

Now, on a simulator this host runs:

  • It writes the app's BBSectionInfo in data/Library/BulletinBoard/VersionedSectionInfo.plist, the record SpringBoard keeps for a prompt answer, after the old SpringBoard and usernotificationsd processes have exited, then reads it back once SpringBoard is up again.
  • An app that was running comes back to the front, and starts fresh if iOS ended it during the change. Otherwise the simulator stays on the Home Screen. A file already holding the status is left alone, with no restart.
  • grant all, deny all and reset all set notifications last, restarting at most once.
  • A missing file, another layout, or a remote simulator (Limrun) refuses with UNSUPPORTED_OPERATION and a typed reason before any restart; all skips it with a warning.

It uses the bundled plist package; per-key plutil edits were rejected. Wix's applesimutils edits the same file.

Before / after

iPhone 17 Pro simulator, iOS 27.2:

$ settings permission grant notifications --app dev.example.notificationprobe
0.21.42: Error (UNSUPPORTED_OPERATION): iOS simulator does not support setting notifications permission via simctl privacy on this runtime.
head:    Updated setting: permission
         Warning: Restarted SpringBoard to apply the notification permission, so the simulator is back on the Home Screen. Change notifications before open, then open the app.
$ settings permission deny notifications --app dev.example.notificationprobe     # probe in front
head:    Updated setting: permission
         Warning: Restarted SpringBoard to apply the notification permission, and brought dev.example.notificationprobe back to the front because it was running.
         (probe: "before=denied granted=false after=denied")
$ settings permission grant notifications --app dev.example.notificationprobe     # already granted
head:    Updated setting: permission     (1 s, no restart)

Validation

Head 2cae4b38c, check:affected --run --head (exactCommit: true): format, lint, typecheck, layering, fallow, build and vitest-related pass. pnpm gate provider-integration, command-docs, docs-links and docs-prose pass.

Probe app: reset prompts; grant, deny, and grant before first launch read authorized, denied, authorized without a prompt; deny all, reset all, grant all read denied, prompt, authorized. With the probe in front, deny and grant bring it back to the front, and open --foreground still finds it.

@thymikee

Copy link
Copy Markdown
Member

Thanks for the clear change. This PR is ready at c985976 and no code defects were found, and no conflicts are known. The Smoke Tests failure is in the Android smoke checks (an empty Android snapshot), and this diff touches only iOS simulator settings, contract docs and docs, so it looks unrelated. The two cancelled Body rules runs were superseded, not failed. Not verified here: the change was not run on a simulator, so the grant, deny, reset and all results come from the PR body without attached logs, and the launchctl stop/start timing and SpringBoard respawn behavior are untested. Not blocking, and fine to take or leave: grant all, deny all and reset all now restart SpringBoard through setNotificationsUnderAll, so a mid-flow setPermissions: { all: allow } lands on the Home Screen where base kept the app in the foreground; either accept that as documented or keep notifications out of all. Also, launchctl stop in simulator-notification-permission.ts does not wait for exit, so waiting for both services to report no PID, or re-reading the record after the start, would make the write hold. readSettingsFile repeats the plist format sniff from plist.ts, so one reader that returns the format and value could serve both. notificationSettingsPath is host-only but sits in the shared contracts type. A failed rename in writeSettingsFile leaves its temp file in the BulletinBoard directory.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@imranbarbhuiya

Copy link
Copy Markdown
Contributor Author
  • Done in 84bca59, 165784f and eec04ce: a restart now brings the app back to the front when it was running, fresh when iOS ended it, which it does on a deny or reset. For all, base 0.21.42 already lands on the Home Screen mid-flow, because the simctl privacy changes end the app before notifications run, so all behaves as before.
  • Done in 84bca59 and 165784f: it waits up to 10 s for each service's process to change (launchd starts SpringBoard again at once on iOS 27.2, so "no PID" never shows), then reads the record again after SpringBoard is back, with ios-notification-restart-timeout and ios-notification-settings-not-applied as typed failures.
  • Done in 84bca59: readApplePlist in plist.ts returns the format and the value, and both readers use it.
  • Done in 84bca59: the path moved to AppleSimctlSettingRequest in platform-apple; the contracts type is unchanged from main.
  • Done in 84bca59: a failed write or rename removes the temporary file before rethrowing, with a test.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 24, 2026
@thymikee

Copy link
Copy Markdown
Member

Thanks for the quick follow-up. At eec04ce, each note from the earlier review (c985976) is addressed, and the code is ready to merge. The Coverage job (the Run coverage step) failed with a truncated log that names no failing test, so it needs a re-run to green before merge. The same workflow failed intermittently on other branches the same night, and the new platform-apple unit tests use fake timers for the 10 s waits. Not blocking, and can be taken or left: jobProcesses and the UIKitApplication:<id>[ match in simulator-notification-permission.ts are a third launchctl list row parser beside readApplicationJob and listRunningIosSimulatorBundleIds, so one shared parser in platform-apple core could be a follow-up. Not verified here: a simulator run, the claim that simctl privacy ... all ends a running app on the base, and whether the respawned SpringBoard reads the edited file; that last point rests on the pasted probe output in the PR body.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 24, 2026
@imranbarbhuiya

Copy link
Copy Markdown
Contributor Author
  • Done in a1c6017: readLaunchctlJobs and uiKitApplicationBundleId in core/launchctl-jobs.ts now parse the rows for all three callers. Both other callers return what they did before, with new tests pinning each; app-resolution loads the parser on demand so its facades' eager closure stays the same. On the simulator, snapshot found the running probe and open --foreground --platform ios opened it.
  • Done in e1abaa0: the Coverage failure was ours. Two of the new restart-timeout tests hit vitest's 5 s timeout under coverage, because they stepped fake timers between real file reads. The tests now mock sleep to move a faked clock, so the 10 s bounds take no real time; the file runs in under 1 s, with coverage too.
  • Also in 2cae4b3: the docs no longer say iOS always ends the app on a deny or reset. In this run a deny kept the probe's process, so they now say the app comes back to the front, fresh if iOS ended it during the change.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 24, 2026
@thymikee

Copy link
Copy Markdown
Member

Thanks for the follow-up. The code at 2cae4b3 looks good, and the coverage failure seen at eec04ce is gone after e1abaa0. Every check passes except Body rules, which was cancelled rather than failed. It reads only the PR body, so it does not relate to the diff. There are no conflicts. Please re-run Body rules until it is green before merge. Not verified here: no simulator was run, so the snapshot, open --foreground and deny-keeps-the-process results rest on the author's comment, and the unit tests were not re-run locally.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 24, 2026
@thymikee

Copy link
Copy Markdown
Member

Thanks for the careful work and the follow-ups. After looking at where this runs, core will not take it. The change works only on a simulator whose files are on the daemon's host. Limrun, other hosted providers and physical devices still refuse. It also adds the first host-side write into a simulator's private files, a SpringBoard restart, and an app relaunch outside the open path. That is a lot of surface for one prompt that alert accept (or alert dismiss) already answers on local simulators, physical devices and Limrun. The plan is to keep notifications refused on iOS simulators, point that refusal at alert accept|dismiss, and document it. If remote demand shows up, a provider-side or in-guest mechanism that also works on remote simulators would be a better fit. Please open an issue with a runnable demo first. Closing for now.

@thymikee thymikee closed this Nov 24, 2026
@imranbarbhuiya
imranbarbhuiya deleted the feat/ios-sim-notification-permission branch November 24, 2026 15:39
@imranbarbhuiya
imranbarbhuiya restored the feat/ios-sim-notification-permission branch November 24, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS simulator: set notification permission, which simctl privacy refuses

2 participants