Android 앱 스킴(App Scheme) 호출하는 방법 (App to App 호출 및 Web To App 호출)
✨ 개요
앱을 개발하다 보면 앱 → 앱 또는 웹 → 앱으로 사용자를 자연스럽게 이동시켜야 할 때가 많습니다.
예를 들어,
- 결제 완료 후 결제 앱으로 이동
- 웹 페이지에서 앱이 설치되어 있다면 앱 실행
- 타 앱에서 특정 화면(예: 게시글 상세)으로 바로 진입
이때 사용하는 것이 바로 앱 스킴(App Scheme, URL Scheme) 또는 딥링크(Deeplink)입니다.
1. ✅ 앱 스킴이란?
앱 스킴은 URI 형식을 통해 앱을 직접 실행하거나 특정 화면으로 이동시키는 방식입니다.
예시 URI:
- myapp://post/1234
- mybankapp://transfer
2. ✅ 앱 스킴 설정 방법
2.1 AndroidManifest.xml 설정
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="post"
android:scheme="myapp" />
</intent-filter>
</activity>
- View 선언이 안되어있으면 외부 URI -> 앱 진입이 되지 않음
- Default 선언은 Activity 가 기본적으로 받을 수 있는 인텐트로 인식되게끔 설정
- Browsable 선언 브라우저와 같은 외부 앱에서 URI 를 통해 앱을 열 수 있게 해줌
- 이 선언이 없는 경우 웹에서 탐색할 수 없음* 또는 **탐색이 차단되어 있음 현상 발생
2.2 호출되는 App 코드
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
handleDeeplink(intent)
}
private fun handleDeeplink(intent: Intent) {
Log.e(TAG, "handleDeeplink ${intent.data}")
val uri = intent.data ?: return
// "myapp://post/detail?id=1234&author=kim"
val id = uri.getQueryParameter("id") // "1234"
val author = uri.getQueryParameter("author") // "kim"
val path = uri.path // "/detail"
val host = uri.host // "post"
Log.e(TAG, "deepLinkData host=$host path=$path")
Log.e(TAG, "deepLinkData id=$id author=$author")
}
3. ✅ App 호출하는 방법
3.1 App to App 스킴 호출 방법
private fun appToAppScheme() {
val uri = Uri.parse("myapp://post/detail?id=1234&author=kim")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
3.2 Web to App 스킴 호출 방법
location.href = "myapp://post/detail?id=1234&author=kim";
setTimeout(function () {
// 설치 페이지로 이동시키고 싶은 경우
location.href = "https://play.google.com/store/apps/details?id=com.example.myapp";
}, 1500);
4.🧠 결론
앱 스킴(App Scheme)을 활용하면 앱 간의 연결성은 물론, 웹과 앱을 유연하게 연결할 수 있어 사용자 경험을 향상시킬 수 있습니다.
- Intent 기반으로 앱을 실행하고 특정 화면까지 이동
- 웹 링크에서도 앱이 설치되어 있다면 자동으로 연결
- Play Store fallback을 적용하면 사용자 이탈도 줄일 수 있습니다
📱 앱 설치 유도부터 특정 화면 진입까지, 앱 스킴을 활용해보세요!