fix(iOS): drain UISceneConnectionOptions on cold launch (#21362) by koblavi · Pull Request #21394 · AvaloniaUI/Avalonia (original) (raw)

@koblavi

…1362)

When the iOS app uses scene-based lifecycle (iOS 13+), Apple delivers cold-launch user activities and URL contexts via UISceneConnectionOptions on scene:willConnectToSession:options: — NOT via the warm-path selectors scene:continueUserActivity: or scene:openURLContexts:. AvaloniaSceneDelegate ignored connectionOptions entirely, so cold-launching the app from a Universal Link or custom-scheme URL dropped the URL on the floor.

The user's subscriber to IActivatableLifetime.Activated then only saw the base ActivatedEventArgs raised by the foreground transition (OnLeavingBackground), never a ProtocolActivatedEventArgs with the URL.

Fix: in WillConnect, after the window is created and made key, drain both connectionOptions.UserActivities and connectionOptions.UrlContexts through the existing IAvaloniaAppInternalDelegate paths. Also add a scene:openURLContexts: handler so warm custom-scheme URLs work under scene lifecycle (previously these were silently dropped too — application:openURL: on the AppDelegate is not called when scenes are in use).

Closes AvaloniaUI#21362 (cold path of AvaloniaUI#17600 / AvaloniaUI#18005).

The IAvaloniaAppInternalDelegate interface gains an OpenUrl(NSUrl) method so the scene delegate can route URL contexts through the same code path the existing application:openURL:options: AppDelegate handler uses.

No new tests — the Avalonia.iOS UnitTests and IntegrationTests projects don't currently exist in the repo. Manual verification steps in the issue: build any Avalonia.iOS app with Associated Domains entitlement

@koblavi mentioned this pull request

May 19, 2026

MrJul

MrJul pushed a commit to MrJul/Avalonia that referenced this pull request

May 28, 2026

@koblavi @MrJul

…1362) (AvaloniaUI#21394)

When the iOS app uses scene-based lifecycle (iOS 13+), Apple delivers cold-launch user activities and URL contexts via UISceneConnectionOptions on scene:willConnectToSession:options: — NOT via the warm-path selectors scene:continueUserActivity: or scene:openURLContexts:. AvaloniaSceneDelegate ignored connectionOptions entirely, so cold-launching the app from a Universal Link or custom-scheme URL dropped the URL on the floor.

The user's subscriber to IActivatableLifetime.Activated then only saw the base ActivatedEventArgs raised by the foreground transition (OnLeavingBackground), never a ProtocolActivatedEventArgs with the URL.

Fix: in WillConnect, after the window is created and made key, drain both connectionOptions.UserActivities and connectionOptions.UrlContexts through the existing IAvaloniaAppInternalDelegate paths. Also add a scene:openURLContexts: handler so warm custom-scheme URLs work under scene lifecycle (previously these were silently dropped too — application:openURL: on the AppDelegate is not called when scenes are in use).

Closes AvaloniaUI#21362 (cold path of AvaloniaUI#17600 / AvaloniaUI#18005).

The IAvaloniaAppInternalDelegate interface gains an OpenUrl(NSUrl) method so the scene delegate can route URL contexts through the same code path the existing application:openURL:options: AppDelegate handler uses.

No new tests — the Avalonia.iOS UnitTests and IntegrationTests projects don't currently exist in the repo. Manual verification steps in the issue: build any Avalonia.iOS app with Associated Domains entitlement

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})