Xamarin- und .NET-MAUI-Apps teilen sich die C#-Geschäftslogik über alle Plattformen hinweg, brauchen aber für Deep Linking eine plattformspezifische Konfiguration. Die Verifizierungsdateien (AASA, assetlinks.json), Entitlements und Intent-Filter sind native Themen. Die URL-Routing-Logik lässt sich dagegen teilen.
Deep Linking mit Kotlin Multiplatform findest du unter Deep Links mit Kotlin Multiplatform. Einen plattformübergreifenden Überblick gibt der Leitfaden zu Cross-Platform Deep Linking für 2026.
.NET-MAUI-Setup (empfohlen)
.NET MAUI ist der Nachfolger von Xamarin.Forms. Wenn du ein neues Projekt startest, nimm MAUI.
iOS-Konfiguration
1. Associated Domains hinzufügen
Trage in deinem MAUI-Projekt das Entitlement in Platforms/iOS/Entitlements.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:yourdomain.com</string>
</array>
</dict>
</plist>
2. Universal Links in der AppDelegate verarbeiten
In Platforms/iOS/AppDelegate.cs:
[Export("application:continueUserActivity:restorationHandler:")]
public bool ContinueUserActivity(
UIApplication application,
NSUserActivity userActivity,
UIApplicationRestorationHandler completionHandler)
{
if (userActivity.ActivityType == NSUserActivityType.BrowsingWeb
&& userActivity.WebPageUrl != null)
{
var url = userActivity.WebPageUrl.ToString();
DeepLinkHandler.HandleUrl(url);
return true;
}
return false;
}
Android-Konfiguration
1. Intent-Filter hinzufügen
In Platforms/Android/AndroidManifest.xml:
<activity android:name=".MainActivity" android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="yourdomain.com"
android:pathPrefix="/products" />
<data android:scheme="https"
android:host="yourdomain.com"
android:pathPrefix="/offers" />
</intent-filter>
</activity>
Oder nutze den IntentFilter Attribut an deiner MainActivity:
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, Exported = true)]
[IntentFilter(
new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "https",
DataHost = "yourdomain.com",
DataPathPrefix = "/products",
AutoVerify = true)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
if (intent?.Data != null)
{
DeepLinkHandler.HandleUrl(intent.Data.ToString());
}
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (Intent?.Data != null)
{
DeepLinkHandler.HandleUrl(Intent.Data.ToString());
}
}
}
Gemeinsame Routing-Logik
Deep-Link-Router (gemeinsamer Code)
Erstelle einen gemeinsamen Deep-Link-Handler, der auf beiden Plattformen funktioniert:
// DeepLinkHandler.cs (gemeinsames Projekt)
public static class DeepLinkHandler
{
public static void HandleUrl(string urlString)
{
if (!Uri.TryCreate(urlString, UriKind.Absolute, out var uri))
return;
var path = uri.AbsolutePath;
var query = System.Web.HttpUtility.ParseQueryString(uri.Query);
// Routen abgleichen
if (TryMatch(path, "/products/{0}", out var productId))
{
NavigateToProduct(productId, query);
return;
}
if (TryMatch(path, "/offers/{0}", out var offerId))
{
NavigateToOffer(offerId, query);
return;
}
if (TryMatch(path, "/referral/{0}", out var referrerId))
{
NavigateToReferral(referrerId, query);
return;
}
// Standard
NavigateToHome();
}
private static bool TryMatch(string path, string pattern, out string param)
{
param = null;
var prefix = pattern.Replace("{0}", "");
if (!path.StartsWith(prefix)) return false;
param = path.Substring(prefix.Length).TrimEnd('/');
return !string.IsNullOrEmpty(param);
}
private static async void NavigateToProduct(string productId, NameValueCollection query)
{
await Shell.Current.GoToAsync($"//products/{productId}");
}
private static async void NavigateToOffer(string offerId, NameValueCollection query)
{
await Shell.Current.GoToAsync($"//offers/{offerId}");
}
private static async void NavigateToReferral(string referrerId, NameValueCollection query)
{
await Shell.Current.GoToAsync($"//referral/{referrerId}");
}
private static async void NavigateToHome()
{
await Shell.Current.GoToAsync("//home");
}
}
Mit Shell-Navigation
.NET MAUI Shell bringt eine eingebaute Routen-Registrierung mit:
// AppShell.xaml.cs
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
// Routen für Deep Links registrieren
Routing.RegisterRoute("products", typeof(ProductPage));
Routing.RegisterRoute("offers", typeof(OfferPage));
Routing.RegisterRoute("referral", typeof(ReferralPage));
}
}
Umgang mit Query-Parametern
// ProductPage.xaml.cs
[QueryProperty(nameof(ProductId), "productId")]
[QueryProperty(nameof(Source), "source")]
public partial class ProductPage : ContentPage
{
public string ProductId { get; set; }
public string Source { get; set; }
protected override void OnAppearing()
{
base.OnAppearing();
LoadProduct(ProductId);
// Attribution erfassen
if (!string.IsNullOrEmpty(Source))
{
Analytics.TrackDeepLink(Source, $"/products/{ProductId}");
}
}
}
Xamarin.Forms (veraltet)
Wenn du noch Xamarin.Forms verwendest (Ende des Supports: Mai 2024, der erweiterte Support variiert), ist der Ansatz ähnlich, nutzt aber Xamarin-spezifische APIs.
iOS (Xamarin.iOS)
// AppDelegate.cs
public override bool ContinueUserActivity(
UIApplication application,
NSUserActivity userActivity,
UIApplicationRestorationHandler completionHandler)
{
if (userActivity.WebPageUrl != null)
{
DeepLinkHandler.HandleUrl(userActivity.WebPageUrl.ToString());
return true;
}
return false;
}
Android (Xamarin.Android)
[Activity(MainLauncher = true)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "https",
DataHost = "yourdomain.com",
AutoVerify = true)]
public class MainActivity : FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
if (Intent?.Data != null)
{
DeepLinkHandler.HandleUrl(Intent.Data.ToString());
}
}
}
Testen
iOS-Simulator
xcrun simctl openurl booted "https://yourdomain.com/products/abc123"
Android Emulator
adb shell am start -a android.intent.action.VIEW \
-d "https://yourdomain.com/products/abc123" \
-c android.intent.category.BROWSABLE
Unit-Tests für den Router
[Test]
public void HandleUrl_ProductLink_NavigatesToProduct()
{
var url = "https://yourdomain.com/products/abc123?ref=email";
// Testen, ob die Routing-Logik die URL korrekt parst
var result = DeepLinkRouter.Parse(url);
Assert.AreEqual("ProductPage", result.Screen);
Assert.AreEqual("abc123", result.Params["productId"]);
Assert.AreEqual("email", result.Query["ref"]);
}
Tolinku für .NET-Apps
Tolinku hostet AASA- und assetlinks.json-Dateien, verarbeitet Deferred Deep Links und liefert Analysen. Siehe die Deep-Linking-Dokumentation für Details zur Integration.
Für eine Implementierung von Grund auf siehe Deep Links von Grund auf implementieren. Die vollständige Anleitung findest du unter Leitfaden zu Cross-Platform Deep Linking für 2026.
Deep-Linking-Tipps direkt in Ihr Postfach
Eine E-Mail pro Woche. Kein Spam.