Xamarin과 .NET MAUI 앱은 플랫폼 간에 C# 비즈니스 로직을 공유하지만, 딥 링킹에는 플랫폼별 설정이 필요해요. 검증 파일(AASA, assetlinks.json), 엔타이틀먼트(entitlements), 인텐트 필터는 네이티브 영역이에요. URL 라우팅 로직은 공유할 수 있어요.
Kotlin Multiplatform 딥 링킹은 아래 문서를 참고하세요: Kotlin Multiplatform 딥 링크. 크로스 플랫폼 개요는 다음 글을 참고하세요: 2026년 크로스 플랫폼 딥 링킹 가이드.
.NET MAUI 설정 (권장)
.NET MAUI는 Xamarin.Forms의 후속이에요. 새 프로젝트라면 MAUI를 쓰세요.
iOS 설정
1. Associated Domains 추가
MAUI 프로젝트의 다음 파일에 엔타이틀먼트를 추가하세요: 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. AppDelegate에서 유니버설 링크 처리
수정할 파일: 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 설정
1. 인텐트 필터 추가
수정할 파일: 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>
또는 IntentFilter 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());
}
}
}
공유 라우팅 로직
딥 링크 라우터 (공유 코드)
두 플랫폼에서 모두 동작하는 공유 딥 링크 핸들러를 만드세요:
// DeepLinkHandler.cs (shared project)
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);
// Match routes
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;
}
// Default
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");
}
}
Shell 내비게이션 적용
.NET MAUI Shell에는 라우트 등록 기능이 내장되어 있어요:
// AppShell.xaml.cs
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
// Register routes for deep linking
Routing.RegisterRoute("products", typeof(ProductPage));
Routing.RegisterRoute("offers", typeof(OfferPage));
Routing.RegisterRoute("referral", typeof(ReferralPage));
}
}
쿼리 파라미터 처리
// 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);
// Track attribution
if (!string.IsNullOrEmpty(Source))
{
Analytics.TrackDeepLink(Source, $"/products/{ProductId}");
}
}
}
Xamarin.Forms (레거시)
아직 Xamarin.Forms를 쓰고 있다면 (지원 종료: 2024년 5월, 연장 지원 기간은 다를 수 있어요) 방식은 비슷하지만 Xamarin 전용 API를 써요.
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());
}
}
}
테스트
iOS 시뮬레이터
xcrun simctl openurl booted "https://yourdomain.com/products/abc123"
Android 에뮬레이터
adb shell am start -a android.intent.action.VIEW \
-d "https://yourdomain.com/products/abc123" \
-c android.intent.category.BROWSABLE
라우터 단위 테스트
[Test]
public void HandleUrl_ProductLink_NavigatesToProduct()
{
var url = "https://yourdomain.com/products/abc123?ref=email";
// Test that the routing logic correctly parses the URL
var result = DeepLinkRouter.Parse(url);
Assert.AreEqual("ProductPage", result.Screen);
Assert.AreEqual("abc123", result.Params["productId"]);
Assert.AreEqual("email", result.Query["ref"]);
}
.NET 앱용 Tolinku
Tolinku AASA와 assetlinks.json 파일을 호스팅하고, 디퍼드 딥 링크를 처리하며, 분석 기능을 제공해요. 자세한 내용은 딥 링킹 문서 에서 연동 세부 사항을 확인하세요.
처음부터 직접 구현하려면 다음을 참고하세요: 딥 링크를 처음부터 구현하는 방법. 전체 가이드는 다음 글을 참고하세요: 2026년 크로스 플랫폼 딥 링킹 가이드.
딥 링킹 팁을 메일로 받아 보세요
일주일에 한 번만 보내요. 스팸은 없어요.