딥링크는 웹의 주소와도 같다 특정 주소 혹은 값을 입력하면 앱이 실행되거나 앱 내 특정 화면으로 이동시키는 기능을 수행하는 게 딥링크다 딥링크는 크게 세 가지로 구분된다 1) URI 스키마 방식 : 앱에 호스트 및 스키마를 등록하여 딥링크 사용 2) 앱 링크(App Link) : 도메인 주소를 이용한 딥링크 사용 - Android 3) 유니버셜 링크 (Universal Link) 도메인 주소를 이용한 딥링크 사용 - iOS 오늘은 URI 스키마 방식을 얘기해보겠다 URI 스키마 방식은 가장 일반적으로 사용되는 딥링크다 구성은 Scheme://host 으로 구성되어있다 여기서 Scheme는 앱을 지칭하고 host는 앱 페이지를 지칭한다 설정은 AndroidManifest에서 가능하다
이런 방식으로 구성을 하면 myApp://openapp으로 열면 설정한 Acitivity가 열리게 된다. 다른 Activity를 열고 싶다면 원하는 Activity에 설정을 해두면 된다 만약 딥링크로 어플을 열면서도 데이터를 보내고 싶으면 어떻게 해야 할까? 그것도 뒤에 파라미터만 추가하면 간단하게 보낼 수 있다 위를 예로 들어보자면 myapp://openapp?name=hanix_x 가 되는 셈이다 클릭된 링크나 프로그램의 요청이 웹 URI 인텐트를 호출하면 Android 시스템에서는 요청이 성공할 때까지 다음 각 작업을 순서대로 시도합니다. 아래 단계에 따라 콘텐츠 링크를 만들고 테스트합니다. Android 스튜디오의 App Links Assistant를 사용하여 Android 앱 링크를 추가할 수도 있습니다. 앱 콘텐츠 링크를 만들려면 이러한 요소와 속성값이 포함된 인텐트 필터를 매니페스트에 추가합니다. 속성을 추가하여 활동이 수락하는 URI 유형을 더욱 세분화할 수 있습니다. 예를 들어, 유사한 URI를 수락하지만, 경로 이름에 따라 달라지는 여러 활동이 있을 수 있습니다. 이 경우 다음 XML 스니펫은 매니페스트에서 딥 링크용 인텐트 필터를 지정할 수 있는 방법을 보여줍니다. <activity android:name="com.example.android.GizmosActivity" android:label="@string/title_gizmos" > <intent-filter android:label="@string/filter_view_http_gizmos"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- Accepts URIs that begin with "http://www.example.com/gizmos” --> <data android:scheme="http" android:host="www.example.com" android:pathPrefix="/gizmos" /> <!-- note that the leading "/" is required for pathPrefix--> </intent-filter> <intent-filter android:label="@string/filter_view_example_gizmos"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- Accepts URIs that begin with "example://gizmos” --> <data android:scheme="example" android:host="gizmos" /> </intent-filter> </activity> 두 인텐트 필터는 <intent-filter> ... <data android:scheme="https" android:host="www.example.com" /> <data android:scheme="app" android:host="open.my.app" /> </intent-filter>
활동 콘텐츠의 URI가 포함된 인텐트 필터를 앱 매니페스트에 추가하면 Android는 런타임 시 앱과 일치하는 URI가 있는 모든 인텐트 필터 정의와 관련하여 자세히 알아보려면 다른 앱에서 내 앱의 활동을 시작하도록 허용하기를 참고하세요. 수신되는 인텐트에서 데이터 읽기시스템이 인텐트 필터를 통해 활동을 시작하면 다음은
사용자의 경험을 향상하려면 다음 권장사항을 따르세요.
딥 링크 테스트하기Android 디버그 브리지를 활동 관리자(am) 도구와 함께 사용하여 딥 링크용으로 지정한 인텐트 필터 URI가 올바른 앱 활동으로 확인되는지 테스트할 수 있습니다. 기기나 에뮬레이터에 관해 adb 명령어를 실행할 수 있습니다. adb를 사용해 인텐트 필터 URI를 테스트하는 일반적인 구문은 다음과 같습니다. $ adb shell am start -W -a android.intent.action.VIEW -d <URI> <PACKAGE> 예를 들어, 아래의 명령어는 지정된 URI와 연결된 타겟 앱 활동을 봅니다. $ adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android 위에서 설정한 매니페스트 선언과 인텐트 핸들러는 앱과 웹사이트 간의 연결 및 수신 링크로 해야 할 작업을 정의합니다. 그러나 시스템에서 앱이 URI 집합의 기본 핸들러로 취급되도록 하려면 이 연결을 인증하도록 시스템에 요청해야 합니다. 다음 과정에서는 이러한 인증을 구현하는 방법을 설명합니다. 인텐트와 앱 링크를 자세히 알아보려면 다음 리소스를 참고하세요.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates. Last updated 2022-10-05 UTC. [{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"필요한 정보가 없음" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"너무 복잡함/단계 수가 너무 많음" },{ "type": "thumb-down", "id": "outOfDate", "label":"오래됨" },{ "type": "thumb-down", "id": "translationIssue", "label":"번역 문제" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"샘플/코드 문제" },{ "type": "thumb-down", "id": "otherDown", "label":"기타" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"이해하기 쉬움" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"문제가 해결됨" },{ "type": "thumb-up", "id": "otherUp", "label":"기타" }] |