Это мой Mauiprogram.cs:
Код: Выделить всё
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp()
.UseMauiCommunityToolkit()
.UseViewServices()
.UseMicrocharts()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.ConfigureLifecycleEvents(lifecycle =>
{
#if IOS || MACCATALYST
#elif ANDROID
lifecycle.AddAndroid(android => {
android.OnCreate((activity, bundle) =>
{
var action = activity.Intent?.Action;
var data = activity.Intent?.Data?.ToString();
if (action == Intent.ActionView && data is not null)
{
HandleAppLink(data);
}
});
});
#endif
});
//...
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
static void HandleAppLink(string url)
{
if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out var uri))
App.Current?.SendOnAppLinkRequestReceived(uri);
}
}
Код: Выделить всё
protected override async void OnAppLinkRequestReceived(Uri uri)
{
base.OnAppLinkRequestReceived(uri);
// Überprüft, ob die Anforderung von der Passwort-App stammt
if (uri.Host == "engelberth-developing" && uri.Segments != null)
{
// Behandelt den App-Link für das Teilen von Elementen
if (uri.Segments.Length == 5 && uri.Segments[2] == "share/")
{
Global.Transfer = uri.Segments[3].Replace("/", "|") + uri.Segments[4].Replace("/", "").Replace('*', '/');
// Setzt die nächste Seite auf die Seite zum Freigeben von Elementen
await AssignService.SetNextPage();
}
// Behandelt den App-Link für die Synchronisierung von Geräten
else if (uri.Segments.Length == 4 && uri.Segments[2] == "sync/")
{
Global.Transfer = uri.Segments[3].Replace("/", "").Replace('*', '/');
// Setzt die nächste Seite auf die Seite für die Gerätesynchronisierung
await AssignService.SetNextPage();
}
}
}
Код: Выделить всё
public static async Task SetNextPage(string paramValue = null)
{
var implementationType = services
.Where(service => service.ServiceType == typeof(TService))
.Select(service => service.ImplementationType)
.FirstOrDefault();
if (implementationType != null)
{
var route = paramValue != null ? $"/{implementationType.Name}?{paramValue}" : $"/{implementationType.Name}";
await Shell.Current.GoToAsync(route);
}
}
Подробнее здесь: https://stackoverflow.com/questions/782 ... dy-created