본문 바로가기

Android

[안드로이드] 딥링크에 대하여..

반응형

Manifest 설정부터 푸시 연동까지 한 번에 이해하기  

 

1. 딥링크란?

딥링크(Deep Link)는 외부에서 앱의 특정 화면으로 직접 진입할 수 있는 링크이다
예를 들어, 웹에서 myapp://login을 클릭하면 앱이 실행되고 로그인 화면이 바로 열리는 방식을 말한다.

 

2. 기본 딥링크 설정 방법(AndroidManifest.xml 설정)

<activity
    android:name=".activity.MainActivity"
    android:exported="true">
    
    <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="example" />
    </intent-filter>
</activity>

 

 

3. 테스트 방법

여러가지 방법이 있겠지만, 내가 테스트한 방법은 "myapp://example" 이라는 문구를 QR코드로 만들어 카메라로 촬영하는 방법이다.

 

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Uri uri = getIntent().getData();
    if (uri != null) {
        String host = uri.getHost();      // example
        String path = uri.getPath();      // /login 등
        String param = uri.getQueryParameter("id"); // 쿼리 파라미터
    }
}

 

myapp://example 로 시작한 문구뒤에 값을 추가하는 방법은 ?key=value 형태이다

예를 들면 "myapp://example/login?id=123" 형식이다.

 

 

 

반응형