Repository navigation
feat!: Add WinAppSDK-style protocol and argument activation via AppInstance (backport #20027) - #25324
mergify[bot] wants to merge 43 commits into
Conversation
(cherry picked from commit a1fa7f0) # Conflicts: # src/Uno.WinRT/Generated/3.0.0.0/Microsoft.Windows.AppLifecycle/AppActivationArguments.cs # src/Uno.WinRT/Generated/3.0.0.0/Microsoft.Windows.AppLifecycle/AppInstance.cs # src/Uno.WinRT/Generated/3.0.0.0/Microsoft.Windows.AppLifecycle/ExtendedActivationKind.cs
(cherry picked from commit 9550bf0) # Conflicts: # src/Uno.UI/UI/Xaml/Application.cs
(cherry picked from commit 96c73e3) # Conflicts: # src/Uno.UI.Runtime.AppleUIKit/UnoUIApplicationDelegate.cs
(cherry picked from commit aaf067e) # Conflicts: # src/Uno.UI.Runtime.WebAssembly.Browser/Hosting/WebAssemblyBrowserHost.cs # src/Uno.UI.Runtime.WebAssembly.Browser/ts/Runtime/WebAssemblyWindowWrapper.ts
(cherry picked from commit d20d572) # Conflicts: # src/Uno.UI/UI/Xaml/Application.cs
(cherry picked from commit 50cd5be) # Conflicts: # src/Uno.UI/Hosting/SecondaryApplicationLauncher.cs # src/Uno.UI/UI/Xaml/NativeApplication.cs
(cherry picked from commit 24ce24f) # Conflicts: # src/Uno.UI/UI/Xaml/Application.cs
(cherry picked from commit b2e0cae) # Conflicts: # src/SamplesApp/SamplesApp.Shared/App.xaml.cs
… yet (cherry picked from commit cf76c2f) # Conflicts: # src/Uno.UI.RuntimeTests/Tests/Windows_ApplicationModel/Given_ActivationKind.cs
(cherry picked from commit ef9c956)
(cherry picked from commit ce79f0b)
(cherry picked from commit 82adc3f)
Co-authored-by: Copilot <[email protected]> (cherry picked from commit e289a0d)
(cherry picked from commit 753cb90) # Conflicts: # src/Uno.UWP/ApplicationModel/Core/CoreApplication.cs
The PR introduced an #if __SKIA__ / #else pair in Application.InvokeOnActivated. src/Uno.UI now builds from a single Skia-only csproj (net10.0;net11.0, UnoRuntimeIdentifier=Skia), so __SKIA__ is always defined there and the #else arm is unreachable. Only the arm this PR itself introduces is removed. (cherry picked from commit 79becd6)
Aligns protocol/argument/activation handling with the WinAppSDK Microsoft.Windows.AppLifecycle model across every non-desktop target. Every platform host now funnels activations through the single AppInstance.SetOrRaiseActivation entry point, which stores the activation that started the process and raises Activated for later ones. OnLaunched always receives plain Launch arguments, matching WinUI, which synthesizes them regardless of how the process was activated; the real payload is read from AppInstance.GetActivatedEventArgs(). BREAKING CHANGE: Application.OnActivated is removed. It is not part of the shipping WinUI 3 surface (microsoft.ui.xaml.coretypes2.idl gates it behind Feature_UwpSupportApi), and WinAppSDK apps discover their activation through AppInstance instead. Overrides now fail to compile rather than silently never being invoked. OnLaunched also drops its Uno-only `protected internal` accessibility for WinUI's `protected`. - GetActivatedEventArgs no longer throws when nothing was set, falling back to a Launch activation over the process command line as WinAppSDK does (AppInstance.cpp:554-559). - Implements ProcessId, FindOrRegisterForKey, UnregisterKey and RedirectActivationToAsync with correct single-instance semantics; the cross-process half stays NotImplemented. - Drops the new public CoreApplication.WasLaunched, which had no WinRT counterpart, in favour of per-instance state. - iOS/tvOS: moves activation onto the scene lifecycle, where UIKit actually delivers it for apps declaring a scene manifest, and restores PerformActionForShortcutItem so a home-screen shortcut tap is handled while the app is running. - Android: a jump-list shortcut tapped while the app runs now raises an activation instead of being dropped, and the launch-arguments override is consumed once so it cannot leak into a later plain launch. - WebAssembly: strips the unoprotocolactivation key from the arguments the app sees, and stops double-decoding the activation URI. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit c82677c) # Conflicts: # src/SamplesApp/SamplesApp.Shared/App.xaml.cs # src/Uno.UI.Runtime.AppleUIKit/UnoUISceneDelegate.cs # src/Uno.UI/UI/Xaml/NativeApplication.cs # src/Uno.UWP/ApplicationModel/Core/CoreApplication.cs # src/Uno.UWP/Helpers/ProtocolActivation.wasm.cs
The parameterless LaunchActivatedEventArgs constructor and its SecondaryApplicationLauncher wrapper lost their only caller when the launch path moved to InvokeOnLaunched. The constructor taking an already-built UWP LaunchActivatedEventArgs was never wired up and left the public Arguments property null, so it was a trap rather than a feature. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 660c25f)
BREAKING CHANGE: Application.Suspending, Application.Resuming,
Application.EnteredBackground and Application.LeavingBackground are removed.
Use the CoreApplication events of the same names, which Uno Platform already
raised in lockstep with these, including the SuspendingOperation deferral.
- Application.Current.Suspending += OnSuspending;
+ CoreApplication.Suspending += OnSuspending;
All four sit in the same Feature_UwpSupportApi block as the OnActivated
removed earlier, and the public WinAppSDK Application surface exposes only
ResourceManagerRequested and UnhandledException. CoreApplication is the more
portable home as well as the more accurate one: it is Windows Runtime API
that also compiles against the Windows App SDK, which Application.Suspending
does not. The SuspendingEventHandler, EnteredBackgroundEventHandler and
LeavingBackgroundEventHandler delegates remain, being real WinAppSDK types.
Skia Win32 no longer reports suspension when a window closes. Windows App SDK
never raises Suspending on desktop, the mapping skipped the UWP-mandated
EnteredBackground that precedes it, and macOS and X11 never had it, so desktop
was inconsistent with itself. Save state from Window.Closed instead.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev
(cherry picked from commit 896ed75)
# Conflicts:
# build/PackageDiffIgnore.xml
# src/Uno.UI.Runtime.Win32/UI/Xaml/Window/Win32WindowWrapper.cs
# src/Uno.UI/UI/Xaml/Application.cs
# src/Uno.UI/UI/Xaml/Controls/AnimatedVisualPlayer/AnimatedVisualPlayer.mux.cs
LoadItems converted every dynamic shortcut, but ToJumpListItem throws for a shortcut without the Uno marker extra, so a static manifest shortcut or one registered through ShortcutManager directly made JumpList.LoadCurrentAsync throw. The iOS implementation and this file's own InternalSaveAsync already filter on IsUnoShortcut. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit a493150) # Conflicts: # src/Uno.UWP/UI/StartScreen/JumpList.Android.cs
A jump-list or home-screen shortcut tap arrives as a Launch activation whose arguments are the item's own. Android plumbed those to OnLaunched through Application.SetArguments while iOS did not, so the same shortcut produced different LaunchActivatedEventArgs.Arguments per platform. OnLaunched now derives its arguments from the reported activation when there is one, falling back to the command line otherwise, which makes every host consistent without each plumbing the value separately. Reading the fallback from AppInstance is not enough on its own: the Launch arguments it synthesizes are the whole command line including the executable, so only an activation a host actually reported may override. Also reports activation kind and payload in the SamplesApp, showing a dialog only for an activation delivered into the running app - reporting at launch would interrupt the CI runs that are themselves driven by launch arguments. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 6ed4986) # Conflicts: # src/SamplesApp/SamplesApp.Shared/App.xaml.cs
Windows.ApplicationModel has an AppInstance of its own, generated as a NotImplemented stub on every target, so the unqualified name became ambiguous once Microsoft.Windows.AppLifecycle was imported. CoreApplication.Suspending is an EventHandler<SuspendingEventArgs>, whose sender is nullable. Neither showed up in a project build: SamplesApp.Shared compiles into each head, not into a library of its own. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 9e6252b)
Given_AppInstance covers what GetActivatedEventArgs guarantees: never null, Launch kind with a LaunchActivatedEventArgs payload whose Arguments is the whole command line as WinAppSDK reports it, recomputed per call, and unchanged by a later activation. Also covers SetOrRaiseActivation raising Activated exactly once after launch, and the instancing members that are implemented. The command-line assertion is the one that would have failed before this branch, which reported the executable-stripped form instead. GetActivatedEventArgs throwing was only reachable before Application was constructed, which a test inside a running app cannot exercise. Given_ProtocolActivation covers the WebAssembly query parsing: the activation key is extracted and stripped while other arguments survive, and an activation URI carrying encoded characters is not decoded twice. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit cb5f4ea) # Conflicts: # src/Uno.UI.RuntimeTests/Tests/Windows_ApplicationModel/Given_AppInstance.cs # src/Uno.UI.RuntimeTests/Tests/Windows_ApplicationModel/Given_ProtocolActivation.cs
Rewrites the handling half of the protocol-activation guide around AppInstance.GetActivatedEventArgs and AppInstance.Activated, with a complete App.xaml.cs covering both the cold-start and already-running paths. Notes that on WebAssembly a protocol activation is always a cold start, since registerProtocolHandler navigates the browser, and states plainly that Skia Desktop has no protocol activation yet. The per-platform registration sections are unchanged, being still accurate. Corrects the jump list page: an item's Arguments now arrive as a Launch activation readable from the same two entry points. Adds the 7.0 migration entries for the removed Application.OnActivated, the narrowed OnLaunched accessibility, the lifecycle events moving to CoreApplication, and the stripped WebAssembly activation query key. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 141532f) # Conflicts: # doc/articles/features/protocol-activation.md # doc/articles/migrating-to-uno-7.md
Specifies the follow-up that brings protocol activation, OS scheme registration and cross-process redirection to Skia Desktop, none of which ships here. Grounded in the Windows App SDK implementation: the verbatim ----ms-protocol:<uri> command-line contract, per-target URL ingestion for Win32, macOS and X11, ActivationRegistrationManager mapped onto each OS mechanism, and the named-object redirection design reduced to the three semantics apps actually depend on. Records that making FindOrRegisterForKey nullable is itself source-breaking for nullable-enabled callers, so it has to land with the transport rather than ahead of it, and ends with a phased plan ordered cheapest and safest first. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 09f4105)
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit e1d0500)
UIKit starts the app from didFinishLaunchingWithOptions and only then connects the first scene, so under the scene lifecycle - the default, and what a scene manifest selects - a cold protocol or shortcut activation always arrived after OnLaunched had run. SetOrRaiseActivation therefore raised Activated instead of storing, and GetActivatedEventArgs reported the synthesized fallback, so the documented "read it from OnLaunched" pattern missed every cold activation on iOS. AppInstance.ReportStartupActivation stores such an activation anyway and still raises Activated, so both entry points see it. Application.Current is likewise never a valid proxy for NotRunning there, since UIKit creates the app before the first scene connects; the execution state now follows whether the startup activation has been consumed. Also: - Wraps the UIKit and Android callbacks that invoke app activation handlers, so a throwing handler cannot unwind into a native frame and abort the process, and answers UIKit's completion handler from a finally. - Stops a secondary-ALC application from reading the process-wide activation: Uno framework assemblies load from the default context, so the host's shortcut arguments were reaching every secondary app's OnLaunched. - Stops consuming the launch-argument override, so every application in the process sees the same already-stripped arguments rather than falling back to re-reading the raw page query with the activation key still in it. - Logs what became of each reported activation, the one question the funnel was unable to answer, and reports only a URI's scheme, since a deep link is the usual OAuth redirect channel. - Makes Application.RequiresPointerMode internal: not public Windows App SDK surface either, and its only reader is the ported SharedHelpers. BREAKING CHANGE: Application.RequiresPointerMode is no longer public. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 056d7d7) # Conflicts: # src/Uno.UI/UI/Xaml/NativeApplication.cs
LaunchActivatedEventArgs already had Arguments and TileId but did not declare the live ILaunchActivatedEventArgs, so the cast Microsoft's own AppLifecycle sample uses to read a Launch payload returned null. ProtocolActivatedEventArgs already implemented its counterpart. Moves TryParseActivationUri out of the .wasm.cs file: only registerProtocolHandler is platform-bound, and keeping the parser WebAssembly-only meant its tests had to reach it by reflection and could never execute. Drops the overload the host stopped calling. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 5df408b) # Conflicts: # src/Uno.UWP/Helpers/ProtocolActivation.wasm.cs # src/Uno.UWP/Helpers/ProtocolActivationParser.cs
They reached the parser by reflection and were gated to WebAssembly, so they executed nowhere; now that the parser is platform-neutral they assert it directly and run on Skia Desktop too. Replaces the command-line assertion in Given_AppInstance, which pinned the synthesized fallback and would have failed as soon as any host reported a startup Launch activation, with the payload contract that actually matters. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit fb2cd47)
ReportActivation is async void, reached from the AppInstance.Activated handler, so a second dialog opening while one is already shown would throw on a fire-and-forget path and take the CI harness with it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 9794b03) # Conflicts: # src/SamplesApp/SamplesApp.Shared/App.xaml.cs
- Types the protocol sample against IProtocolActivatedEventArgs and ILaunchActivatedEventArgs so one App.xaml.cs serves the Windows head, and validates the scheme before acting on a URI, since an activation payload is untrusted input. - Records that single-instancing is not implemented, and that an activation is not attributed to a window. - Softens the WebAssembly cold-start claim: that is a property of registerProtocolHandler and of what Uno Platform reads today, not of the browser, which can deliver into a running client through the Launch Handler API. - Rewrites the Application lifecycle page, which still taught the removed Application.Suspending, around CoreApplication and states which targets report suspension at all. - Amends the secondary-application launcher contract in spec 000: CreateDefaultLaunchActivatedEventArgs is removed, and the reason it can be is that LaunchSecondary takes no arguments parameter, so the value it produced had nowhere to go. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit ebafa2e) # Conflicts: # specs/000-alc-secondary-app-support.md
…ision An AppInstance handler outlives any one application object, so a host loading applications into collectible contexts has to detach it or keep that context alive. Records why FindOrRegisterForKey keeps its non-nullable signature: the Windows App SDK ships no nullable metadata for this surface, so matching it means staying oblivious, and returning null later is not a source break. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 6b2c72f)
…Kind Flagged repeatedly by automated review since the first round and never picked up: the mismatch message was missing its closing parenthesis, and four using directives were unreferenced. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit b7a9cce)
…activity Android's default standard launch mode creates a new activity instance for every incoming intent, so a deep link arriving while the app runs stacked a second MainActivity on top of the first. The app's window belongs to the first instance, so the second presented nothing and the app went black with no error, while the activation itself was still reported correctly. SingleTask delivers the intent to the existing instance through OnNewIntent, which ApplicationActivity already forwards to NativeApplication.TryHandleIntent. Verified on a Pixel 7 API 35 emulator: a protocol re-activation went from an all-black 15,580-byte screencap with two stacked activities to a rendered 179,525-byte one with a single activity, with the activation still reported. The same failure reproduces on master, so this is not caused by the activation rework - but that rework is what makes the path reachable in practice. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit ecc1c6f)
The Android registration steps described the intent filter but not the launch mode, so an app following them stacks a second activity on every deep link and appears to go black. No app head or solution template in the repo declared one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LqnbdM1SGr7ZJpxme1ZUev (cherry picked from commit 92a9cd6)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjDSLp2v55C43EVtaGqb5K (cherry picked from commit 58c3b93) # Conflicts: # src/Uno.UI/UI/Xaml/Application.cs
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjDSLp2v55C43EVtaGqb5K (cherry picked from commit 59bd866)
The accessors were listed but the property itself was not, so the package diff still reported it as a removal. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjDSLp2v55C43EVtaGqb5K (cherry picked from commit 466ad56)
The read-side AppInstance contract stays shared so the WinUI run checks parity; activation injection, key registration, redirection and the WebAssembly query parser are Uno internals. The Launch payload is read through ILaunchActivatedEventArgs, as WinAppSDK uses its own class. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjDSLp2v55C43EVtaGqb5K (cherry picked from commit daf028e)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjDSLp2v55C43EVtaGqb5K (cherry picked from commit 9cea7c9)
(cherry picked from commit eaee8d0)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DrgtLA3UC9ZuJ2LjeeS7PZ (cherry picked from commit 29e5662)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DrgtLA3UC9ZuJ2LjeeS7PZ (cherry picked from commit 67e184c) # Conflicts: # src/Uno.UI/UI/Xaml/NativeApplication.cs
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 5d0ff0d)
|
Cherry-pick of a1fa7f0 has failed: Cherry-pick of 9550bf0 has failed: Cherry-pick of 96c73e3 has failed: Cherry-pick of aaf067e has failed: Cherry-pick of d20d572 has failed: Cherry-pick of 50cd5be has failed: Cherry-pick of 24ce24f has failed: Cherry-pick of b2e0cae has failed: Cherry-pick of cf76c2f has failed: Cherry-pick of 753cb90 has failed: Cherry-pick of c82677c has failed: Cherry-pick of 896ed75 has failed: Cherry-pick of a493150 has failed: Cherry-pick of 6ed4986 has failed: Cherry-pick of cb5f4ea has failed: Cherry-pick of 141532f has failed: Cherry-pick of 056d7d7 has failed: Cherry-pick of 5df408b has failed: Cherry-pick of 9794b03 has failed: Cherry-pick of ebafa2e has failed: Cherry-pick of 58c3b93 has failed: Cherry-pick of 67e184c has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
|
|
|
|
GitHub Issue: closes #10915, closes unoplatform/uno-private#1183
PR Type:
✨ Feature — ❗ breaking change for 7.0 (see Breaking changes below)
What changed? 🚀
Current behavior
Protocol and argument activation is UWP-shaped and incomplete:
Application.OnActivated, which is not part of the shipping WinUI 3 surface —microsoft.ui.xaml.coretypes2.idldeclares it only behind the UWP-support feature gate, and the public Windows App SDKApplicationexposes justExit,LoadComponent,OnLaunchedandStart.Microsoft.Windows.AppLifecycle.AppInstanceandAppActivationArgumentsexist only as[Uno.NotImplemented]stubs, so the pattern a Windows App SDK app is written against does not work.PerformActionForShortcutItemhaving been lost in the Skia port.Application.Suspending/Resuming/EnteredBackground/LeavingBackgroundare onApplication, where the Windows App SDK does not have them, and Skia Win32 reports suspension when a window closes — which no other desktop target does, and which skips theEnteredBackgroundthat should precede it.New behavior
Activation follows the Windows App SDK model, ported from the
AppLifecyclesources in microsoft/WindowsAppSDK.One pipeline. Every platform host reports its activation through a single internal entry point on
AppInstance, which stores the activation the process started with and raisesActivatedfor any that arrive later.OnLaunchedalways receives plainLauncharguments, matching WinUI'sFrameworkApplication, which synthesizes them regardless of how the process was activated; the real payload comes fromAppInstance.GetActivatedEventArgs().AppInstance/AppActivationArguments/ExtendedActivationKindare implemented against the IDL, value-for-value including the gap at 1008.GetActivatedEventArgs()never returnsnulland never throws — with no payload it reportsLaunchover the process command line, exactly asAppInstance.cppdoes — so it is safe to call beforeApplication.Start.Per target
specs/059-desktop-activation-redirectionFixes found while building this
didFinishLaunchingWithOptionsand only then connects the first scene, so under the scene lifecycle a cold activation always arrived afterOnLaunched. It is now stored anyway, keepingGetActivatedEventArgs()truthful, and still raised.PerformActionForShortcutItem, and addsscene:openURLContexts:/scene:continueUserActivity:/windowScene:performActionForShortcutItem:.JumpList.LoadCurrentAsyncno longer throws when the app has any non-Uno dynamic shortcut (the iOS implementation already filtered).unoprotocolactivationkey is stripped from the arguments the app sees, and the activation URI is no longer decoded twice. The query parser lives inUno.WinRTas the internalProtocolActivationParser, so it is unit-testable on every target; the publicUno.Helpers.ProtocolActivation.RegisterCustomSchemestays in the browser runtime where master moved it.Windows.ApplicationModel.Activation.LaunchActivatedEventArgsnow implementsILaunchActivatedEventArgs, so the cast the Windows App SDK samples use to read aLaunchpayload works.Out of scope, specified for follow-up. Skia Desktop activation,
ActivationRegistrationManager, and cross-process single-instance redirection are deferred and specified inspecs/059-desktop-activation-redirection/spec.md, grounded in the Windows App SDK implementation (the----ms-protocol:<uri>command-line contract, per-target URL ingestion, the named-object redirection design, and a phased delivery plan).AppInstance.FindOrRegisterForKeytherefore always claims the key for the current instance andRedirectActivationToAsyncis a no-op — correct on Android, iOS and WebAssembly, and documented as not yet single-instancing on desktop.PR Checklist ✅
Screenshots Compare Test Runresults.Breaking changes — impact and migration path
Targeted at 7.0. All are documented in
doc/articles/migrating-to-uno-7.md(sections Activation is read fromAppInstanceand App lifecycle events move toCoreApplication, checklist steps 18–19), with before/after code.Application.OnActivatedremovedAppInstance.GetCurrent().GetActivatedEventArgs()inOnLaunched; subscribe toAppInstance.GetCurrent().Activatedfor activations while runningApplication.OnLaunchedisprotected(was Uno-onlyprotected internal)protected internal override)protected override— what current templates generateApplication.Suspending/Resuming/EnteredBackground/LeavingBackgroundremovedthis.Suspending +=(very common in older templates and samples)CoreApplicationevents; handler bodies unchanged, sender becomesobject?SuspendingWindow.ClosedApplication.RequiresPointerModeisinternalLaunchActivatedEventArgs.Argumentsno longer carriesunoprotocolactivationArgumentsGetActivatedEventArgs()Items 1, 2, 3 and 5 fail loudly at compile time, which is deliberate. Items 4 and 6 are silent, so the migration guide calls each out explicitly. Apps that override neither
OnActivatednor the lifecycle events see no change:OnLaunchedalready receivedLauncharguments before this PR.build/PackageDiffIgnore.xmlcarries an entry with a reason for each removal.specs/000-alc-secondary-app-support.mdis amended for the one removed member of the secondary-application launcher's frozen contract,CreateDefaultLaunchActivatedEventArgs, which no consumer could use:LaunchSecondarytakes no arguments parameter, so the value it produced had nowhere to go.LaunchSecondary(Application)itself is unchanged.First-party repositories
The default branch of each first-party repo was surveyed for every affected API:
OnLaunchedis alreadyprotected override; shutdown already usesCoreApplication.Exiting/Window.Closed; no protocol activation or single-instance use (auth is a loopback listener). TheSecondaryApplicationLauncher.LaunchSecondary(Application)reflection contract inAppBinaryLoaderis preserved. Worth a WASM smoke test of itsmode=rtquery-argument detection, which should be unaffected by #6.WinUIEx_WebAuthenticatoralready usesAppInstanceunder#if WINDOWSonlyApp.xaml.cs:this.Suspending +=→CoreApplication.Suspending +=App.xaml.csApp.xaml.csfiles, same one-line editNobody in first-party code overrides
OnActivatedor readsRequiresPointerMode.Other information
Rebased on
master(≈1,900 commits). Notable reconciliations:src/Uno.UI.RuntimeTests/Windows/ApplicationModel/.ProtocolActivationinto the browser runtime (public, soRegisterCustomSchemecompiles for browser heads). To avoid a second publicUno.Helpers.ProtocolActivation, the shared parser is now the internalProtocolActivationParserinUno.WinRT.WM_CLOSEpath gainedStopRenderThread(); it is kept, and only the suspension raise is dropped.CI fixes since the last run: the Uno-only activation tests (
SetOrRaiseActivation, key registration and redirection, and the WebAssembly query parser) are behindHAS_UNO, so the WinAppSDK leg compiles. The read-sideAppInstancecontract stays shared, so the WinUI run checks parity. TheRequiresPointerModeproperty now has its own API-diff ignore entry.Validation after the rebase (all builds strict: analyzers and code style on):
SamplesAppnet10.0-desktop(Uno.UI, Win32/X11/macOS runtimes, runtime tests)Uno.UI.Runtime.Skia.WebAssembly.Browser(net10.0)Uno.UI.Runtime.Skia.Android(net10.0-android)Uno.UI.Runtime.Skia.AppleUIKit(net10.0-ios and net10.0-tvos; tvOS was previously only checked by inspection)Uno.WinRTAndroid / Wasm / Reference variantsGiven_AppInstance,Given_ProtocolActivation,Given_ActivationKindThe WinAppSDK leg, the Android/iOS runtime-test shards and the API diff are verified by this PR's CI run.
Android was validated on an emulator (Pixel 7, API 35) before the rebase, with all four paths reporting through
AppInstance:Kind - Protocol, Uri - uno-samples-test://cold/hello?x=1, PreviousState - NotRunningKind - Protocol, Uri - uno-samples-test://warm/second?y=2, PreviousState - Running— same process id, so delivered into the live appKind - Launch, Arguments - sample=Buttons/ButtonKind - Launch, Arguments - sample=Warm/Faithful— same process idThe cold-start rows are read from
AppInstance.GetActivatedEventArgs()insideOnLaunched; the running-app rows arrive onAppInstance.Activated. The two running-app cases are the ones this PR repairs — previously the jump-list one was dropped outright.Still to verify: no iOS device run has been done. The iOS scene-lifecycle change is the one most worth a device check, since that is the path it repairs.
Docs updated:
doc/articles/features/protocol-activation.md(rewritten aroundAppInstance, with a per-target support table and a note that activation payloads are untrusted input),doc/articles/features/windows-ui-startscreen.md,doc/articles/features/windows-ui-xaml-application.md, anddoc/articles/migrating-to-uno-7.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01UjDSLp2v55C43EVtaGqb5K
This is an automatic backport of pull request #20027 done by [Mergify](https://mergify.com).