android onelink 연동

김토끼·2021년 12월 13일
0

android에서 appsflyer onelink를 연동할 때는 URI scheme과 앱링크를 둘 다 적용해야 한다.

내 경우엔 아래처럼 URI Scheme과 앱링크를 한 인텐트 필터에 같이 넣는 방식으로 구현했었다.
AndroidManifest.xml

<Application ...>
    <activity ...>
    	...
        <intent-filter 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="https" android:host="[service_name].onelink.me" />
                
            <data android:scheme="[service_scheme]" host="[service_host]" />
        </intent-filter>
    </activity>
</application>

그런데 위처럼 구현을 했더니 앱이 설치 되어 있는데도 불구하고 앱이 열리는게 아니라 웹브라우저로 열었을 때 플레이스토어로만 이동하는 문제가 있었다.

아래처럼 앱링크에 scheme을 삭제하면 다시 정상적으로 동작을 하지만 대신 앱과 전혀 관게없는 다른 링크를 눌렀을 때도 앱이 같이 표시가 되는 문제가 있었다. 실제로도 앱이 열리고 해당 URL을 앱 내의 웹뷰로 띄우는 문제도 있었고..

<data android:scheme="https" />

문제 해결방법은 생각보다 더 간단하다. 앱링크와 URI scheme을 각각의 intent-filter로 분리해서 구현하면 된다.

AndroidManifest.xml

<Application ...>
    <activity ...>
    	...
        <!-- 앱링크의 경우 autoVerify가 필요 -->
        <intent-filter 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="https" android:host="[service_name].onelink.me" />
        </intent-filter>
        
        <!-- URI scheme은 autoVerify가 필요 없음 -->
        <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="[service_scheme]" host="[service_host]" />
        </intent-filter>
    </activity>
</application>
profile
방구석 김토끼🐰

0개의 댓글