딥링크란?

딥링크의 주요 기능

앱이 설치되어 있다면 → 앱의 특정 화면으로 이동

앱이 설치되지 않았다면 → 앱스토어 또는 웹사이트로 연결 가능

웹과 앱을 연결하여 사용자 경험(UX) 개선 가능

마케팅, 푸시 알림, 이메일, QR 코드에서 활용 가능

딥링크의 종류와 차이점

기본 딥링크 (Classic Deep Link) 앱이 설치된 경우 특정 화면으로 이동 앱이 설치되지 않으면 링크가 깨짐 myapp://profile/123
디퍼드 딥링크 (Deferred Deep Link) 앱이 설치되지 않더라도 설치 후 특정 화면으로 이동 가능 설치 후에도 딥링크가 유지됨 Firebase Dynamic Links, Branch.io
유니버설 링크 (Universal Link, iOS) / 앱 링크 (App Link, Android) 웹과 앱을 자동으로 연결하는 링크 앱이 설치되지 않으면 웹 페이지로 이동 https://example.com/profile/123

React Native에서의 딥링크 응용 예제

Android 설정 (AndroidManifest.xml 수정)

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="myapp" android:host="profile"/>
</intent-filter>

iOS 설정 (ios/Info.plist 수정)

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>myapp</string>
        </array>
    </dict>
</array>

<aside> 💡

기본 딥링크에서 스토어 이동 구현 하는 법

</aside>

const openAppOrStore = () => {
  window.location.href = 'myapp://profile/123'; // 기본 딥링크 실행

  setTimeout(() => {
    window.location.href = '<https://play.google.com/store/apps/details?id=com.myapp>';
  }, 2000); // 2초 후 앱스토어로 이동
};

// 버튼 클릭 시 실행
<button onClick={openAppOrStore}>앱에서 열기</button>

import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { Linking } from 'react-native';

// 페이지 컴포넌트
const HomeScreen = ({ navigation }) => (
  <View>
    <Text>홈 화면</Text>
  </View>
);

const ProfileScreen = ({ route }) => (
  <View>
    <Text>사용자 ID: {route.params?.id}</Text>
  </View>
);

const ProductScreen = ({ route }) => (
  <View>
    <Text>상품 ID: {route.params?.id}</Text>
  </View>
);

const Stack = createStackNavigator();

// 📌 딥링크 설정
const linking = {
  prefixes: ['myapp://', '<https://myapp.com>'],
  config: {
    screens: {
      Home: 'home',
      Profile: 'profile/:id', // myapp://profile/123
      Product: 'product/:id', // myapp://product/456
    },
  },
};

export default function App() {
  return (
    <NavigationContainer linking={linking}>
      <Stack.Navigator>
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Profile" component={ProfileScreen} />
        <Stack.Screen name="Product" component={ProductScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}