Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions ios/mob_nif.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -7295,18 +7295,20 @@ static void mob_deliver_alert_action(const char *action) {
enif_free_env(env);
}

// Returns the root UIViewController for presenting dialogs.
// Returns the topmost presented UIViewController for presenting dialogs.
//
// The window has to be resolved through mob_root_vc, not by hand. Taking
// `scene.windows.firstObject` and reading its rootViewController assumes the
// app's window sorts first in the scene's window set; on iOS 26 it does not,
// the property is nil, and every alert and action sheet is dropped with no
// error anywhere. mob_root_vc tries `keyWindow` first and only then falls back
// — which is why the scanner and camera plugins (scan_root_vc, cam_root_vc,
// both copies of it) present fine while these two did not.
static UIViewController *root_vc(void) {
for (UIWindowScene *scene in [UIApplication sharedApplication].connectedScenes) {
if (scene.activationState == UISceneActivationStateForegroundActive) {
UIWindow *win = scene.windows.firstObject;
UIViewController *vc = win.rootViewController;
while (vc.presentedViewController)
vc = vc.presentedViewController;
return vc;
}
}
return nil;
UIViewController *vc = mob_root_vc();
while (vc.presentedViewController)
vc = vc.presentedViewController;
return vc;
}

// ── NIF: alert_show/3 ────────────────────────────────────────────────────────
Expand Down