[Android/iOS] 딥링크(Deep Link) URL Scheme 설정
2024. 8. 6. 14:22ㆍ개발/Android
1. 딥링크(Deep Link)란?
- 정의: 딥링크는 사용자를 앱 내 특정 콘텐츠로 직접 연결하는 링크입니다. 웹 브라우저에서 특정 페이지로 이동하는 것처럼, 앱에서도 딥링크를 사용해 특정 화면이나 기능으로 바로 이동할 수 있습니다.
- 종류:
- 기본 딥링크: 앱이 설치되어 있을 때만 작동.
- 유니버설 링크(Universal Links): iOS에서 앱이 설치되어 있지 않으면 웹 페이지로 이동
- 앱 링크(App Links): 안드로이드에서 앱이 설치되어 있지 않으면 웹 페이지로 이동
2. 안드로이드에서 딥링크 설정 방법
2.1 기본 딥링크 설정
- AndroidManifest.xml 파일에서 인텐트 필터를 설정하여 딥링크를 지원
<activity android:name=".MainActivity">
<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="sodd"
android:host="example"
android:pathPrefix="/path" />
</intent-filter>
</activity>
3. iOS에서 딥링크 설정 방법
3.1 URL 스킴 설정
- Info.plist 파일에서 URL 스킴을 등록
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>sodd</string>
</array>
<key>CFBundleURLName</key>
<string>com.example.sodd</string>
</dict>
</array>
4. 딥링크 처리
딥링크가 아래와 같을 때
sodd://example.com/path?key=value
- 안드로이드: 인텐트(Intent)를 통해 딥링크를 처리.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
handleIntent(intent)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(intent)
}
private fun handleIntent(intent: Intent) {
val data: Uri? = intent.data
data?.let {
val path = it.path
// Handle the deep link
}
}
- iOS: URL 처리 메서드를 통해 딥링크를 처리.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let urlString = url.absoluteString
// Handle the deep link
return true
}
'개발 > Android' 카테고리의 다른 글
Android 개발 중 생성되는 java_pidXXXX.hprof 파일의 비밀과 활용법 (1) | 2024.12.02 |
---|---|
안드로이드 앱 설치 후 실행 불가 및 아이콘 보이지 않는 문제 해결하기 (0) | 2024.08.14 |
악성앱 보이스피싱으로 의심 앱 설치 불가의 건 수정 (0) | 2024.08.06 |
[Android studio] 돌핀(Dolpin) 이전 로그캣 으로 변경 (0) | 2023.07.31 |