Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues related to parameters passed through URI protocol activation #19161

Open
abenadar opened this issue Jan 7, 2025 · 3 comments
Open

Issues related to parameters passed through URI protocol activation #19161

abenadar opened this issue Jan 7, 2025 · 3 comments
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@abenadar
Copy link

abenadar commented Jan 7, 2025

Current behavior

Given the outdated documentation for UWP, I couldn't get URI activation to work with WinUI as the ActivationKind was never Protocol and the arguments empty:

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    if (e.UWPLaunchActivatedEventArgs.Kind == ActivationKind.Protocol)
    {
      e.UWPLaunchActivatedEventArgs.Arguments...

Instead I settled for searching the parameter in the envrionment arguments:

Environment
    .GetCommandLineArgs()
    .FirstOrDefault(s => s
        .StartsWith("appuri://")))

While URI launch itself works on Windows and iOS (haven't tested Android), the parameter is never present on iOS.
Is there a workaround I can use to have any given parameter to be actually present?

Example URI: appuri://?param=test

PS: I also noticed that URI activation leads to an app freeze immediately after the splashscreen if the app isn't currently running, which requires navigation from and back to the app once to make it work. This might be on my end though; I am still investigating.

Expected behavior

URI activation causes parameters to be present.

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

none

Works on UWP/WinUI

None

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

5.6.0-dev.1235

Affected platforms

iOS

IDE

Visual Studio 2022

IDE version

17.12.3

Relevant plugins

No response

Anything else we need to know?

No response

@abenadar abenadar added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jan 7, 2025
@abenadar
Copy link
Author

abenadar commented Jan 7, 2025

Related

@jeromelaban
Copy link
Member

The URL component is provided to the app through OnActivated, not OnLaunched:

See this part:

if (launchOptions.TryGetValue(UIApplication.LaunchOptionsUrlKey, out var urlObject))
{
_preventSecondaryActivationHandling = true;
var url = (NSUrl)urlObject;
if (TryParseUri(url, out var uri))
{
OnActivated(new ProtocolActivatedEventArgs(uri, ApplicationExecutionState.NotRunning));
handled = true;
}
}
else if (launchOptions.TryGetValue(UIApplication.LaunchOptionsShortcutItemKey, out var shortcutItemObject))

@abenadar
Copy link
Author

abenadar commented Jan 9, 2025

Many thanks, I now have a solution based on overriding FinishedLaunching like so:

    public override bool FinishedLaunching(UIKit.UIApplication application, Foundation.NSDictionary launchOptions)
    {
        var result = string.Join(Environment.NewLine, launchOptions ?? []);
       
        //...

        return base.FinishedLaunching(application, launchOptions);
    }

However, I am still running into these issues:

  1. The 'UIApplicationLaunchOptionsURLKey' key is only set when the app is booted via url and not when it's currently running (FinishedLaunching is called anyhow though).
  2. Perhaps unrelated, but the app just fails to continue after it's launched through URL, somewhere after or during the call to base.FinishedLaunching. This is surely on my end, but I'm wondering whether:
  • This is known behaviour caused by some speicific issues I cna look after;
  • There is a way to keep the Xamarin debugger running after termination or before app startup so I can look into the issue myself.

Any help on this would be welcome as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

2 participants