본문 바로가기
개발/Unity

Unity) 모바일 딥 링크 설정 - Mobile Deep Link(Android, iOS, UWP)

by 테샤르 2023. 5. 4.

모바일 딥 링크 설정 - Mobile Deep Link(Android, iOS, UWP)

본질적으로 딥 링크를 사용하면 단일 링크를 통해 애플리케이션을 실행하고 매개변수를 전달할 수 있다.

그런 다음 웹 페이지나 SMS 문자 메시지와 같은 다양한 소스에서 애플리케이션의 특정 영역으로 사용자를 웹 페이지로 이동 시킬수 있다.

 

<딥 링크 사용 방법>

 이 시나리오에서 딥 링크를 처리하려면 다음을 수행할 수 있습니다.
시작하기 위해 Unity는 애플리케이션이 딥 링크 URL에서 활성화될 때 Application.deepLinkActivated 이벤트를 호출합니다.

애플리케이션이 시작될 때 Application.absoluteURL을 확인하십시오 .
애플리케이션이 실행되는 동안 Application.deepLinkActivated 이벤트를 구독하십시오 .

 

 

<예시코드>

<예시 코드- 딥 링크 메니져>

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("?"[0])[1];
    	bool validScene;
    	switch (sceneName)
    	{
        	case "scene1":
            	validScene = true;
            	break;
        	case "scene2":
            	validScene = true;
            	break;
        	default:
            	validScene = false;
            	break;
    	}
    	if (validScene) SceneManager.LoadScene(sceneName);
	}
}

<예시 코드- 딥 링크 확인용 코드>

using System;
using System.Text;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[RequireComponent(typeof(Text))]
public class UpdateDeepLink : MonoBehaviour
{
    private void Update()
    {
        //Get Deep link value from global deeplink manager
        var label = GetComponent<Text>();
        label.text = ProcessDeepLinkMngr.Instance.deeplinkURL;
    }
}

<테스트 html>

 

반응형

 

<플랫폼 별 구성>

  • iOS : 지원되는 URL 체계 섹션의 플레이어 설정 창에서 URL 체계를 구성합니다. 
  • Android : 활동에 대한 특정 인텐트 필터 섹션을 포함하도록 표준 앱 매니페스트를 재정의하는 인텐트 필터를 설정합니다.
  • UWP(Universal Windows Platform) : 프로토콜 섹션의 플레이어 설정 창에서 사용자 지정 URI 체계를 구성합니다.

 

샘플 코드를 확인해봤는데 실제 Android 에서도 동작을 잘하는것을 확인했다.

간단하게 특정 링크를 통해서 보상같은걸 처리하기에는 쓸만하다.

예전에는 딥링크를 다른여러가지 방식으로 생성했는데 유니티에서 지원해주고 있어서 편리해졌다.

 

 

Unity Enabling deep Linking : [링크]

 

Unity - Manual: Enabling deep linking

Using Unity as a Library in other applications Enabling deep linking Deep links are links that point directly to content within your application. Unity uses the Application.absoluteURL property and Application.deepLinkActivated event to support deep links

docs.unity3d.com

Unity Blog(Add deep links to your Unity mobile apps for better user experience) : [링크]

 

Add deep links to your Unity mobile apps for better user experience | Unity Blog

Adding deep links within your Unity project is a simple way to drive users directly to specific content in a mobile app – no navigation required. That content becomes easily shareable and more interactive, bringing new users, guiding existing users to ne

blog.unity.com

 

 

★☆☆☆☆

 

반응형

댓글