Capacitor 앱은 웹 앱을 네이티브 셸로 감싼 형태예요. Capacitor에서 딥 링킹을 하려면 네이티브 설정(AASA, assetlinks.json, entitlements, Intent filter)과 JavaScript 쪽 URL 처리가 모두 필요해요. 이 가이드에서는 두 부분을 모두 다뤄요.
크로스 플랫폼 딥 링킹 개요는 다음 문서를 참고하세요 2026년 크로스 플랫폼 딥 링킹 가이드. Ionic 전용 설정은 다음 문서를 참고하세요 Ionic 딥 링킹: 전체 설정 가이드.
사전 준비
- Capacitor 5 이상 (현재 LTS)
- 직접 관리하는 HTTPS 도메인
- AASA 파일의 호스팅 위치:
/.well-known/apple-app-site-association - assetlinks.json 호스팅 위치
/.well-known/assetlinks.json
iOS 설정
1. Associated Domains 권한 추가
Xcode에서 프로젝트를 여세요 ( ios/App 디렉터리):
- App 타겟을 선택하세요.
- Signing & Capabilities로 이동하세요.
- "+ Capability"를 클릭하고, "Associated Domains"를 추가하세요.
- 도메인을 추가하세요:
applinks:yourdomain.com
이 작업으로 다음 파일이 생성되거나 업데이트돼요 .entitlements 파일을 제공할 때 지켜야 할 조건:
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:yourdomain.com</string>
</array>
2. AASA 파일
다음 위치에 호스팅하세요: https://yourdomain.com/.well-known/apple-app-site-association:
{
"applinks": {
"details": [
{
"appIDs": ["TEAMID.com.yourcompany.yourapp"],
"components": [
{ "/": "/products/*" },
{ "/": "/offers/*" },
{ "/": "/referral/*" }
]
}
]
}
}
3. AppDelegate에서 URL 처리하기
Capacitor's 기본 템플릿에는 AppDelegate.swift 이미 Universal Links 핸들러가 포함되어 있어요. 있는지 확인하세요:
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
return CAPBridge.handleContinueActivity(userActivity, restorationHandler: restorationHandler)
}
이렇게 하면 Universal Link URL이 Capacitor's 브리지로 전달되고, JavaScript 코드에서 이 URL을 사용할 수 있어요.
Android 설정
1. 인텐트 필터
다음 파일을 수정하세요: android/app/src/main/AndroidManifest.xml:
<activity
android:name="com.yourcompany.yourapp.MainActivity"
android:exported="true">
<!-- Existing intent filters... -->
<!-- App Links -->
<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" />
<data android:scheme="https"
android:host="yourdomain.com"
android:pathPrefix="/referral" />
</intent-filter>
</activity>
2. assetlinks.json
다음 위치에 호스팅하세요: https://yourdomain.com/.well-known/assetlinks.json:
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.yourcompany.yourapp",
"sha256_cert_fingerprints": [
"YOUR_SIGNING_KEY_FINGERPRINT"
]
}
}
]
인증서 지문을 확인하세요:
# Debug key
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android
# Release key (Play App Signing)
# Find in Google Play Console > Setup > App signing
JavaScript 쪽 처리
App Plugin 사용
Capacitor's 내장 @capacitor/app App 플러그인이 제공하는 appUrlOpen 이벤트:
import { App } from '@capacitor/app';
import { Router } from '@angular/router'; // or your framework's router
// Listen for deep link opens
App.addListener('appUrlOpen', (event) => {
console.log('Deep link URL:', event.url);
const url = new URL(event.url);
const path = url.pathname;
const params = Object.fromEntries(url.searchParams);
// Route to the correct page
handleDeepLink(path, params);
});
function handleDeepLink(path: string, params: Record<string, string>) {
// Match routes
const productMatch = path.match(/^\/products\/([^/]+)$/);
if (productMatch) {
router.navigate(['/product', productMatch[1]], { queryParams: params });
return;
}
const offerMatch = path.match(/^\/offers\/([^/]+)$/);
if (offerMatch) {
router.navigate(['/offer', offerMatch[1]], { queryParams: params });
return;
}
const referralMatch = path.match(/^\/referral\/([^/]+)$/);
if (referralMatch) {
router.navigate(['/referral', referralMatch[1]], { queryParams: params });
return;
}
// Default: go home
router.navigate(['/']);
}
콜드 스타트와 웜 스타트 처리
앱이 다음 상태일 때 딥 링크가 도착할 수 있어요:
- 콜드 스타트: 앱이 실행 중이 아니에요. URL은 앱이 초기화될 때 사용할 수 있어요.
- 웜 스타트: 앱이 백그라운드에 있어요. 이때
appUrlOpen이벤트가 발생해요.
앱 초기화 시점에 URL이 있는지 확인해서 콜드 스타트를 처리하세요:
import { App } from '@capacitor/app';
async function initializeApp() {
// Check if the app was launched from a deep link
const launchUrl = await App.getLaunchUrl();
if (launchUrl?.url) {
console.log('App launched from deep link:', launchUrl.url);
handleDeepLink(new URL(launchUrl.url).pathname, {});
}
// Listen for subsequent deep links (warm start)
App.addListener('appUrlOpen', (event) => {
handleDeepLink(new URL(event.url).pathname, {});
});
}
Angular Router 사용 시
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { App } from '@capacitor/app';
@Injectable({ providedIn: 'root' })
export class DeepLinkService {
constructor(private router: Router) {}
initialize() {
// Cold start
App.getLaunchUrl().then(result => {
if (result?.url) this.route(result.url);
});
// Warm start
App.addListener('appUrlOpen', event => {
this.route(event.url);
});
}
private route(urlString: string) {
const url = new URL(urlString);
// Angular router can handle the path directly
this.router.navigateByUrl(url.pathname + url.search);
}
}
React 사용 시 (Capacitor + React)
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { App } from '@capacitor/app';
function useDeepLinks() {
const navigate = useNavigate();
useEffect(() => {
// Cold start
App.getLaunchUrl().then(result => {
if (result?.url) {
const url = new URL(result.url);
navigate(url.pathname + url.search);
}
});
// Warm start
const listener = App.addListener('appUrlOpen', event => {
const url = new URL(event.url);
navigate(url.pathname + url.search);
});
return () => {
listener.then(l => l.remove());
};
}, [navigate]);
}
테스트
iOS
# Test on iOS Simulator
xcrun simctl openurl booted "https://yourdomain.com/products/123"
# If the app opens and navigates to the product page, it works
Android
# Test on connected device/emulator
adb shell am start -a android.intent.action.VIEW \
-d "https://yourdomain.com/products/123" \
-c android.intent.category.BROWSABLE
브라우저에서 (개발 환경)
개발 중에는 브라우저에서 경로로 직접 이동해 라우팅 로직을 테스트할 수 있어요:
http://localhost:8100/products/123
이건 라우팅 로직만 테스트하고, 네이티브 딥 링크 처리는 테스트하지 않아요.
자주 겪는 문제
| 문제 | 원인 | 해결 |
|---|---|---|
appUrlOpen 발생하지 않음 |
Associated Domains entitlement 누락 | Xcode의 Associated Domains에 applinks:yourdomain.com Xcode에서 확인 |
| 앱은 열리지만 홈 화면이 나타남 | 라우트 핸들러가 경로와 매칭되지 않음 | URL 파싱 로직 디버깅 |
| Android 동작, iOS 미동작 | AASA 파일 문제 | AASA 확인은 curl 및 Apple's 검증 도구로 하세요 |
| Notes에서 동작, 이메일에서 미동작 | 이메일 클라이언트가 링크를 감싸는 경우 | 커스텀 추적 도메인 사용 |
Capacitor 앱용 Tolinku
Tolinku 웹 SDK Capacitor 앱에서 스마트 배너와 분석을 지원해요. Tolinku AASA와 assetlinks.json 파일을 자동으로 호스팅해요.
웹에서 앱으로 연결하는 딥 링킹은 웹용 딥 링킹: 브라우저와 앱 경험 잇기을 참고하세요. 크로스 플랫폼 가이드는 2026년 크로스 플랫폼 딥 링킹 가이드.
딥 링킹 팁을 메일로 받아 보세요
일주일에 한 번만 보내요. 스팸은 없어요.