딥 링크는 사용자를 애플리케이션의 위치로 안내하는 애플리케이션 외부의 URL 링크입니다. 사용자가 애플리케이션에 대한 딥 링크를 클릭하면 운영체제는 지정된 위치(예: 특정 씬)에서 Unity 애플리케이션을 엽니다. Unity는 Application.absoluteURL 프로퍼티와 Application.deepLinkActivated 이벤트를 사용하여 다음 플랫폼에서 딥 링크를 지원합니다.
딥 링크를 처리하기 전에 애플리케이션이 딥 링크에 반응하도록 설정해야 합니다. 특정 URL에 반응하도록 애플리케이션을 설정하는 프로세스는 플랫폼에 따라 다릅니다. Unity는 다음 플랫폼에 대해 딥 링크를 지원합니다.
딥 링크를 처리하려면 다음 중 하나를 수행하십시오.
다음 코드 샘플은 URL에 따라 씬을 로드하고 딥 URL을 처리하는 방법을 보여줍니다.
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 app 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 http-equiv=Content-Type content="text/html; charset=windows-1252">
</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.