What is deepLink ??
- 모바일 웹에서 앱을 여는 기능
- 모바일에서 특정 앱 접근 시 흔하게 볼 수 있는 기능
특정 주소 혹은 값을 입력하면 앱이 실행되거나 앱 특정 화면으로 이동시키는 기술을 딥링크라고 한다.
스킴(scheme)은 앱마다 등록할 수 있는 값으로 이 값으로 앱을 구분할 수 있다. 특정 스킴값을 호출하여 특정 앱을 열 수 있다.
사용방법
한계(?)
A common and old technique to solve this problem is using iframe to load the deep link URL and having a delayed JavaScript to redirect to store
URI 스킴 이동과 앱스토어 이동이 모두 일어나지만 시간차를 이용해 한가지만 일어나는것처럼 보이게 하는 일종의 트릭.
setTimeOut(
var visitedAt = (new Date()).getTime(); // 방문시간
function(){
if((new Date()).getTime() - visitedAt < 2000) {
location.href = "{마켓 주소}"
}
}, 500);
var iframe = document.createElement('iframe');
iframe.style.visibility = 'hidden'; // 보이지 않는 iframe으로 스킴을 호출
iframe.src = '{커스텀 스킴 주소}';
document.body.appendChild(iframe);
document.body.removeChild(iframe);
Since Chrome for Android version 25 and later, the above code stopped working according to Chrome documentation Fortunately, Google provides the Intent URL for a better solution
Chrome의 경우 intent URL 방식을 도입하면서부터 iframe방식을 사용할 수 없게되었다. intent URL은 앱의 설치 여부에 따른 처리를 자동으로 해주기 때문에 유용하다.
setTimeout(function() {
location.href =
"intent://커스텀스킴주소#Intent; scheme=스킴; action=..;category=..; package=com.android.xxx; end;";
}, 1000);
Ios에서는 안드로이드에서 iframe 방식과 동일한 트릭을 사용하여 구현 가능
setTimeout(
function() {
if ((new Date()).getTime() - visitedAt < 2000) {
location.href = "{마켓 주소}";
}
}, 500);
setTimeout(function() {
location.href = "{커스텀 스킴 주소}";
}, 0);