딥 링크는 웹사이트가 아닌 애플리케이션 내 특정 위치로 사용자를 연결하는 하이퍼링크입니다. 사용자가 딥 링크를 선택하면 Unity 애플리케이션 내 특정 씬과 같이 애플리케이션의 지정된 위치가 열립니다. Unity는 Application.absoluteURL 프로퍼티 및 Application.deepLinkActivated 이벤트를 사용하여 딥 링크를 지원합니다.
딥 링크를 처리하기 전에 애플리케이션이 딥 링크에 반응하도록 설정해야 합니다. 특정 URL에 반응하도록 애플리케이션을 설정하는 프로세스는 플랫폼에 따라 다릅니다. Unity는 다음 플랫폼에 대해 딥 링크를 지원합니다.
애플리케이션의 현재 상태에 따라 딥 링크를 처리하는 두 가지 방법이 있습니다.
두 경우 모두 Application.absoluteURL을 사용하여 애플리케이션에서 열 씬을 선택할 수 있습니다.
다음 코드 샘플은 애플리케이션의 현재 상태에 따라 딥 링크를 처리하는 방법을 보여 줍니다.
using UnityEngine;
using UnityEngine.SceneManagement;
public class ProcessDeepLinkMngr : MonoBehaviour
{
public static ProcessDeepLinkMngr Instance { get; private set; }
public string deeplinkURL;
private void Awake()
{
if (Instance == null)
{
Instance = this;
Application.deepLinkActivated += onDeepLinkActivated;
if (!string.IsNullOrEmpty(Application.absoluteURL))
{
// Cold start and Application.absoluteURL not null so process Deep Link.
onDeepLinkActivated(Application.absoluteURL);
}
// Initialize DeepLink Manager global variable.
else deeplinkURL = "[none]";
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
private void onDeepLinkActivated(string url)
{
// Update DeepLink Manager global variable, so URL can be accessed from anywhere.
deeplinkURL = url;
// Decode the URL to determine action.
// In this example, the application expects a link formatted like this:
// unitydl://mylink?scene1
string sceneName = url.Split('?')[1];
bool validScene;
switch (sceneName)
{
case "scene1":
validScene = true;
break;
case "scene2":
validScene = true;
break;
default:
validScene = false;
break;
}
if (validScene) SceneManager.LoadScene(sceneName);
}
}
딥 링크를 테스트하려면 다음 단계를 따르십시오.
이것은 딥 링크를 테스트하는 데 사용할 수 있는 예제 HTML 파일입니다. 링크를 리디렉트하려면 <a>
요소 중 하나에서 href
속성을 변경합니다.
<html>
<head>
<meta charset="utf-8">
</head>
<body >
<h1>My Deep Link Test page</h1>
<p><a href="unitydl://mylink">Launch</a></p>
<p><a href="unitydl://mylink?parameter">Launch with Parameter</a></p>
</body>
</html>
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.