본문으로 건너뛰기
엔지니어링 · · 6분 소요

크로스 플랫폼 앱의 플랫폼별 링크 라우팅

작성자 Tolinku 팀
|
크로스플랫폼 앱에서 플랫폼별 링크 라우팅

대부분의 딥 링크 라우트는 iOS와 Android에서 똑같이 동작해요. 같은 URL이 같은 화면으로 연결되죠. 하지만 일부 라우트는 플랫폼마다 다르게 동작해야 해요. iOS는 Android에 없는 기능(Handoff, Spotlight 인덱싱)을 지원할 수 있고, Android는 iOS에 대응하는 게 없는 Intent 기반 내비게이션을 쓸 수 있어요. 이 글에서는 코드베이스를 유지보수하기 쉽게 지키면서 이런 차이를 처리하는 패턴을 다뤄요.

공통 라우팅 패턴은 다음을 참고하세요: 크로스 플랫폼 링크 처리 패턴을 참고하세요. 전체 개요는 2026년 크로스 플랫폼 딥 링킹 가이드.

플랫폼 차이가 나타나는 지점

딥 링크 라우팅은 세 가지 수준에서 플랫폼마다 다르게 동작해요:

1. URL 수신

iOS와 Android는 서로 다른 API로 딥 링크를 받아요:

항목 iOS Android
방식 Universal Links (AASA) App Links (assetlinks.json)
진입점 application(_:continue:restorationHandler:) onCreate() / onNewIntent() Intent로 전달
URL 형식 같은 HTTPS URL 같은 HTTPS URL
검증 AASA 파일 assetlinks.json

2. 내비게이션

플랫폼마다 내비게이션 시스템이 다르게 동작해요:

  • iOS 는 다음을 사용해요: UINavigationController push/pop, UITabBarController, 또는 SwiftUI NavigationStack.
  • Android 는 Activity, Fragment, 그리고 Navigation 컴포넌트를 사용해요.
  • 크로스 플랫폼 프레임워크 (React Native, Flutter, Capacitor)는 이런 차이를 추상화하지만, 가끔 차이가 드러나기도 해요.

3. 기능 지원 여부

일부 기능은 한 플랫폼에만 있어요:

  • iOS 전용: Handoff, Spotlight 인덱싱, Universal Clipboard
  • Android 전용: Instant Apps, Custom Tabs 폴백, 멀티 윈도우 딥 링크
  • 동작 차이: 뒤로 가기 버튼 처리, 태스크 스택 관리, 화면 분할 동작

패턴: 플랫폼을 고려한 라우트 설정

라우트를 정의하고, 필요하면 플랫폼별 설정으로 덮어쓰세요:

interface Route {
  path: string;
  screen: string;
  platforms: ('ios' | 'android' | 'web')[];
  iosConfig?: {
    handoffActivity?: string;
    spotlightTitle?: string;
  };
  androidConfig?: {
    taskAffinity?: string;
    launchMode?: 'singleTop' | 'singleTask';
  };
}

const routes: Route[] = [
  {
    path: '/products/:productId',
    screen: 'ProductDetail',
    platforms: ['ios', 'android', 'web']
  },
  {
    path: '/ar-preview/:productId',
    screen: 'ARPreview',
    platforms: ['ios'], // ARKit only
    iosConfig: {
      spotlightTitle: 'AR Preview'
    }
  },
  {
    path: '/instant/:productId',
    screen: 'InstantPreview',
    platforms: ['android'], // Android Instant Apps
    androidConfig: {
      launchMode: 'singleTask'
    }
  },
  {
    path: '/share/:shareId',
    screen: 'SharedContent',
    platforms: ['ios', 'android', 'web'],
    iosConfig: {
      handoffActivity: 'com.yourapp.viewing'
    }
  }
];

플랫폼별 라우팅 구현

플랫폼 필터가 있는 공용 라우터

function matchRoute(
  url: string,
  platform: 'ios' | 'android' | 'web'
): RouteMatch | null {
  const parsed = new URL(url);
  const path = parsed.pathname;

  for (const route of routes) {
    // Skip routes not available on this platform
    if (!route.platforms.includes(platform)) continue;

    const match = matchPath(path, route.path);
    if (match) {
      return {
        screen: route.screen,
        params: {
          ...match.params,
          ...Object.fromEntries(parsed.searchParams)
        },
        platformConfig: platform === 'ios'
          ? route.iosConfig
          : route.androidConfig
      };
    }
  }

  return null;
}

function matchPath(
  actual: string,
  pattern: string
): { params: Record<string, string> } | null {
  const paramNames: string[] = [];
  const regex = new RegExp(
    '^' + pattern.replace(/:([^/]+)/g, (_, name) => {
      paramNames.push(name);
      return '([^/]+)';
    }) + '$'
  );

  const match = actual.match(regex);
  if (!match) return null;

  const params: Record<string, string> = {};
  paramNames.forEach((name, i) => {
    params[name] = match[i + 1];
  });
  return { params };
}

iOS 구현

func handleDeepLink(_ url: URL) {
    guard let route = DeepLinkRouter.match(
        url: url.absoluteString,
        platform: "ios"
    ) else {
        navigateToHome()
        return
    }

    // Handle iOS-specific config
    if let handoffActivity = route.platformConfig?.handoffActivity {
        setupHandoff(activityType: handoffActivity, url: url)
    }

    navigateTo(screen: route.screen, params: route.params)
}

private func setupHandoff(activityType: String, url: URL) {
    let activity = NSUserActivity(activityType: activityType)
    activity.webpageURL = url
    activity.isEligibleForHandoff = true
    UIApplication.shared.userActivity = activity
}

Android 구현

fun handleDeepLink(intent: Intent) {
    val uri = intent.data ?: return
    val route = DeepLinkRouter.match(
        url = uri.toString(),
        platform = "android"
    ) ?: run {
        navigateToHome()
        return
    }

    // Handle Android-specific config
    route.platformConfig?.launchMode?.let { mode ->
        when (mode) {
            "singleTask" -> {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or
                    Intent.FLAG_ACTIVITY_CLEAR_TOP)
            }
            "singleTop" -> {
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
            }
        }
    }

    navigateTo(screen = route.screen, params = route.params)
}

플랫폼 간 폴백 처리

딥 링크가 플랫폼 전용 기능을 가리킨다면, 다른 플랫폼에서의 폴백 동작을 정의해 두세요:

interface Route {
  path: string;
  screen: string;
  platforms: ('ios' | 'android' | 'web')[];
  fallback?: {
    screen: string;
    message?: string;
  };
}

const routes: Route[] = [
  {
    path: '/ar-preview/:productId',
    screen: 'ARPreview',
    platforms: ['ios'],
    fallback: {
      screen: 'ProductDetail',
      message: 'AR preview is only available on iOS'
    }
  }
];

function resolveRoute(url: string, platform: string): RouteMatch {
  const route = findMatchingRoute(url);

  if (!route) {
    return { screen: 'Home', params: {} };
  }

  if (!route.platforms.includes(platform)) {
    // Platform not supported, use fallback
    if (route.fallback) {
      return {
        screen: route.fallback.screen,
        params: extractParams(url, route.path),
        message: route.fallback.message
      };
    }
    return { screen: 'Home', params: {} };
  }

  return {
    screen: route.screen,
    params: extractParams(url, route.path)
  };
}

플랫폼별 라우트는 검증 파일에도 영향을 줘요. 각 경로는 그 경로를 지원하는 플랫폼의 검증 파일에만 넣으면 돼요.

AASA (iOS)

iOS 라우트와 공통 라우트만 넣으세요:

{
  "applinks": {
    "details": [{
      "appIDs": ["TEAMID.com.yourcompany.yourapp"],
      "components": [
        { "/": "/products/*" },
        { "/": "/offers/*" },
        { "/": "/ar-preview/*" },
        { "/": "/share/*" }
      ]
    }]
  }
}

AndroidManifest.xml

Android 라우트와 공통 라우트만 넣으세요:

<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="/instant" />
    <data android:scheme="https"
          android:host="yourdomain.com"
          android:pathPrefix="/share" />
</intent-filter>

뒤로 가기 동작의 차이

딥 링크로 앱이 열린 뒤의 뒤로 가기 동작은 플랫폼마다 꽤 달라요:

iOS

  • 시스템이 상태 표시줄에 "[원래 앱]으로 돌아가기" 링크를 보여줘요.
  • 앱의 내비게이션 스택은 새로 시작돼요(앱이 이미 실행 중이었다면 예외예요).
  • 사용자는 뒤로 스와이프하면 원래 앱이 아니라 상위 화면으로 갈 거라고 기대해요.
func navigateFromDeepLink(to screen: String, params: [String: String]) {
    // Build a navigation stack so the user can navigate back
    let homeVC = HomeViewController()
    let detailVC = makeViewController(screen: screen, params: params)

    navigationController?.setViewControllers([homeVC, detailVC], animated: false)
}

Android

  • 뒤로 가기 버튼은 앱의 태스크 스택.
  • 가능하면 TaskStackBuilder 을 따라야 해요. 제대로 된 백 스택은 이렇게 만들어요:
fun navigateFromDeepLink(screen: String, params: Map<String, String>) {
    val detailIntent = makeIntent(screen, params)

    TaskStackBuilder.create(this)
        .addNextIntentWithParentStack(detailIntent)
        .startActivities()
}

크로스 플랫폼 프레임워크에서 고려할 점

React Native

React Native의 Linking API 는 플랫폼별 진입점을 추상화해 주지만, 특정 동작에는 여전히 플랫폼 확인이 필요할 수 있어요:

import { Platform, Linking } from 'react-native';

function handleDeepLink(url: string) {
  const route = matchRoute(url, Platform.OS);

  if (!route) {
    navigation.navigate('Home');
    return;
  }

  // Platform-specific handling
  if (Platform.OS === 'ios' && route.iosConfig?.spotlightTitle) {
    // Index in Spotlight
    indexInSpotlight(route);
  }

  navigation.navigate(route.screen, route.params);
}

Flutter

Flutter의 라우트 처리는 플랫폼에 상관없이 동작하지만, 플랫폼 전용 기능은 플랫폼 채널로 쓸 수 있어요:

void handleDeepLink(Uri uri) {
  final route = matchRoute(uri.toString());

  if (route == null) {
    Navigator.of(context).pushReplacementNamed('/');
    return;
  }

  // Platform-specific features via method channel
  if (Platform.isIOS && route.handoffActivity != null) {
    _methodChannel.invokeMethod('setupHandoff', {
      'activityType': route.handoffActivity,
      'url': uri.toString(),
    });
  }

  Navigator.of(context).pushNamed(
    route.screen,
    arguments: route.params,
  );
}

플랫폼별 라우트 테스트

플랫폼마다 따로 테스트하세요:

# iOS: test an iOS-only route
xcrun simctl openurl booted "https://yourdomain.com/ar-preview/product123"

# Android: test an Android-only route
adb shell am start -a android.intent.action.VIEW \
  -d "https://yourdomain.com/instant/product123" \
  -c android.intent.category.BROWSABLE

# Test shared route on both
xcrun simctl openurl booted "https://yourdomain.com/products/abc123"
adb shell am start -a android.intent.action.VIEW \
  -d "https://yourdomain.com/products/abc123" \
  -c android.intent.category.BROWSABLE

플랫폼 전용 URL을 다른 플랫폼에 보내서 폴백 동작을 테스트해 보세요:

# iOS 전용 라우트를 Android로 보내기 (폴백되어야 함)
adb shell am start -a android.intent.action.VIEW \
  -d "https://yourdomain.com/ar-preview/product123" \
  -c android.intent.category.BROWSABLE

멀티 플랫폼 라우팅을 위한 Tolinku

Tolinku 는 AASA와 assetlinks.json 검증 파일을 둘 다 호스팅해요. iOS와 Android 앱 정보를 Appspace 설정에서 설정하면 Tolinku가 플랫폼별로 맞는 검증 파일을 만들어 줘요. 라우트 에는 동적 파라미터 도 넣을 수 있고, 플랫폼에 상관없이 똑같이 동작해요.

라우팅 기본 개념은 다음 글을 참고하세요: 딥 링크 라우팅: 사용자를 올바른 화면으로 보내는 방법. 공통 라우팅 로직은 다음 글을 참고하세요: 크로스 플랫폼 링크 처리 패턴.

딥 링킹 팁을 메일로 받아 보세요

일주일에 한 번만 보내요. 스팸은 없어요.

앱에 딥 링킹을 추가해 볼까요?

유니버설 링크, 앱 링크, 디퍼드 딥 링킹, 분석을 몇 분 만에 설정할 수 있어요. 무료로 시작하세요.