React Navigation ๊ณต์๋ฌธ์์์ ํด๋น ๋ด์ฉ์ ํ์ธํ์ค ์ ์์ต๋๋ค
https://reactnavigation.org/docs/deep-linking/
์๋๋ก์ด๋
android > app > src > main > AndroidManifest.xml
activity ์์๋ค๊ฐ ํด๋น ์ฝ๋๋ฅผ ๋ฃ์ด์ค๋๋ค
<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="์ค์ ํ ์ฑ ์คํด"/>
</intent-filter>
IOS
ios๋ 2๊ฐ์ง๋ฅผ ์ค์ ํด์ค์ผ ํฉ๋๋ค
1. ios > ํ๋ก์ ํธ ์ด๋ฆ ํด๋ > AppDelegate.mm
ํด๋น ์ฝ๋๋ฅผ ๋ฃ์ด์ค๋๋ค
#import <React/RCTLinkingManager.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [RCTLinkingManager application:application openURL:url options:options];
}
2. xcode > ํ๋ก์ ํธ > infoํญ > ๊ฐ์ฅ ์๋ URL Types
์ํ๋ URL Schemes๋ฅผ ์ค์ ํด์ค๋๋ค
cli๋ฅผ ํตํด ์ค์ ํ url์คํด์ด ์ ๋๋ก ๋์ํ๋์ง ํ์ธํฉ๋๋ค
android: $ npx uri-scheme open ์ค์ ํURL์คํด:// --android
ios: $ npx uri-scheme open ์ค์ ํURL์คํด:// --ios
์ค์ ํ ๋ฅ๋งํฌ๋ฅผ ํตํด ํน์ ํ๋ฉด์ผ๋ก ๋ค๋น๊ฒ์ด์ ์ํค๊ธฐ
liking ๊ฐ์ฒด๋ฅผ ๋ง๋ค์ด์ NavagationContainer์ ๋ฃ์ด์ฃผ๋ฉด ๋ฉ๋๋ค
1. ์ค์ ํ ์คํด์ prefixes์ ๋ฃ์ด์ฃผ์ธ์.
2. ์คํฌ๋ฆฐ์ ์ฐ๊ฒฐํด์ค path๋ฅผ ์ ๋ ฅํฉ๋๋ค.
const linking = {
prefixes: ['daepyo://'],
screens: {
redirect: {
path: '/redirect',
},
},
};
์ ๊ฐ์ ๊ฒฝ์ฐ๋daepyo://redirect?code=~ ๋ฅ๋งํฌ๋ฅผ ๋ฐ์ผ๋ฉด
redirect ํ์ด์ง์์ code์ ํด๋นํ๋ ํ๋ผ๋ฏธํฐ ๊ฐ์ ๋ฐ์ ์์ ์ ๋๋ค
useRoute๋ฅผ ์ฌ์ฉํด์ code ํ๋ผ๋ฏธํฐ๋ฅผ ๋ฐ์์ ๋๊ฒจ์ค๋๋ค
'๐ป ํ๋ก ํธ์๋' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
CSS ์ ๋๋ฉ์ด์ ์ฑ๋ฅ ๊ฐ์ (0) | 2024.01.08 |
---|---|
[React Native] ํฐํธ ์ค์ (0) | 2024.01.05 |
[React Native] Path alias ์ค์ (0) | 2024.01.03 |
Vitest & MSW๋ฅผ ์ฌ์ฉํ ํ ์คํธ ์ฝ๋ ์ ์ฉ (1) | 2023.12.29 |
ํ์ด์ํฐ EJS -> React ๋ง์ด๊ทธ๋ ์ด์ ๊ณผ์ (~ing) (1) | 2023.12.29 |