Android

DeepLink(1부)

EnvEng10 2022. 3. 11. 11:29
반응형

DeepLink를 사용하는 이유는 검색엔진과 IT회사들에게 ‘모바일 컨텐츠 = 트래픽 = 수익’ 인데, 검색 및 인덱싱이 불가능한 컨텐츠가 많아지면서 모바일 컨텐츠 역전 현상에 대비하기 위한 것이다.

즉, 웹과 앱이 유기적으로 연결이 되어서 해당앱에 오래 머물도록 유도하기 위함이라 할 수 있다.

 

첫번째로 봐야할건 ‘AndroidManifest.xml’ 이다.

<activity android:name=".v2.DeepLinkHandleActivity">
  <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="@string/scheme_exam" />            
  </intent-filter>
</activity>

ACTION_VIEW를 추가하는 것은 Google에서 앱 컨텐츠를 크롤링하고 사용자가 검색 결과에서 앱을 입력할 수 있게 해주는 작업이라 할 수 있다.

<data /> 부분이 커스텀 스키마이며, 사용자가 지정한 스키마의 값을 가지고 특정 액티비티를 호출할 수 있다. 웹이나 앱에서 다 호출이 가능하며 ‘scheme:://host’ 같은 uri 형태로 액티비티를 호출할 수 있다.

 

class DeepLinkHandleActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        DeepLink.start(this)
        finish()
    }
}

 

DeepLink 클래스에 관한 구현하는 부분은 2부에 하도록 하겠다.

반응형