According to Microsoft Docs you can handle app uri with this code
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
// TODO: Handle URI activation
// The received URI is eventArgs.Uri.AbsoluteUri
}
}
But that was when app is create from default template. My UWP project iscreate with Windows Template Studio and currently, the place that I suppose to put that code in is now
protected override async void OnActivated(IActivatedEventArgs args)
{
await ActivationService.ActivateAsync(args);
}
Which lead to this..
public async Task ActivateAsync(object activationArgs)
{
if (IsInteractive(activationArgs))
{
// Initialize things like registering background task before the app is loaded
await InitializeAsync();
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (Window.Current.Content == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
Window.Current.Content = _shell;
NavigationService.Frame.NavigationFailed += (sender, e) =>
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
};
NavigationService.Frame.Navigated += OnFrameNavigated;
if (SystemNavigationManager.GetForCurrentView() != null)
{
SystemNavigationManager.GetForCurrentView().BackRequested += OnAppViewBackButtonRequested;
}
}
}
var activationHandler = GetActivationHandlers().FirstOrDefault(h => h.CanHandle(activationArgs);
if (activationHandler != null)
{
await activationHandler.HandleAsync(activationArgs);
}
if (IsInteractive(activationArgs))
{
var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
if (defaultHandler.CanHandle(activationArgs))
{
await defaultHandler.HandleAsync(activationArgs);
}
// Ensure the current window is active
Window.Current.Activate();
// Tasks after activation
await StartupAsync();
}
}
Please, if anyone has been using Windows Template Studio before. Please tell me how to handle Uri in this code. I don't know where to put it in. Currently, my app is launch to blank page when launch from Uri