Skip to content

Commit

Permalink
feat: Pass arguments to LaunchActivatedEventArgs on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Mar 29, 2022
1 parent 9f44c58 commit 21e664b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
12 changes: 11 additions & 1 deletion src/Uno.UI/UI/Xaml/Application.macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,17 @@ public override void DidFinishLaunching(NSNotification notification)
}
if (!handled)
{
OnLaunched(new LaunchActivatedEventArgs());
var argumentsString = "";
if (NSProcessInfo.ProcessInfo?.Arguments is { } processArguments)
{
// First argument is just executable path
if (processArguments.Length > 1)
{
argumentsString = string.Join(" ", processArguments.Skip(1));
}
}

OnLaunched(new LaunchActivatedEventArgs(ActivationKind.Launch, argumentsString));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,23 @@ internal LaunchActivatedEventArgs(ActivationKind kind, string arguments)
#if !__ANDROID__ && !__IOS__
[NotImplemented]
#endif
public ActivationKind Kind
{
get;
}
public ActivationKind Kind { get; } = ActivationKind.Launch;

/// <summary>
/// Defaults to NotRunning, may not be accurate in all cases for all platforms.
/// </summary>
public ApplicationExecutionState PreviousExecutionState { get; }
public ApplicationExecutionState PreviousExecutionState { get; } = ApplicationExecutionState.NotRunning;

[NotImplemented]
public SplashScreen SplashScreen
{
get;
}
public SplashScreen SplashScreen { get; } = new SplashScreen();

[NotImplemented]
public int CurrentlyShownApplicationViewId
{
get;
}
public int CurrentlyShownApplicationViewId { get; }

public string Arguments
{
get;
}
public string Arguments { get; } = "";

[NotImplemented]
public string TileId
{
get;
}
public string TileId { get; } = "App";

public bool PrelaunchActivated => false; // No platform other than UWP supports prelaunch yet.
}
Expand Down

0 comments on commit 21e664b

Please sign in to comment.