Unity SDK - 메서드 레퍼런스

문서

Unity SDK - 메서드 레퍼런스

이 문서는 Unity 애플리케이션용 Singular SDK에서 사용할 수 있는 모든 메서드에 대한 포괄적인 레퍼런스를 제공합니다. Singular 유니티 SDK는 네이티브 iOS 및 Android SDK를 래핑하여 모바일 어트리뷰션, 딥링킹, 구매 추적 및 분석을 위한 연동 C# 인터페이스를 제공합니다. 각 방법에는 설명, 서명, 실제 사용 예시가 함께 제공됩니다.


AdRevenue

SingularSDK.AdRevenue 메서드

미디에이션 플랫폼의 광고 구매을 추적합니다. 이 메서드를 사용하면 Unity 애플리케이션의 광고 노출에서 발생한 구매을 보고하여 광고 구매화를 위한 어트리뷰션 및 ROI 분석을 지원할 수 있습니다.

서명

public static void AdRevenue(string currency, double amount)

사용 예시

C#
// Track ad revenue from an ad impression
SingularSDK.AdRevenue("USD", 0.05);

ClearGlobalProperties

SingularSDK.ClearGlobalProperties 메서드

이전에 설정된 모든 글로벌 프로퍼티를 제거합니다. 글로벌 프로퍼티는 SDK에서 추적하는 모든 이벤트에 자동으로 포함되는 키-값 쌍입니다.

서명

public static void ClearGlobalProperties()

사용 예시

C#
// Clear all global properties
SingularSDK.ClearGlobalProperties();

사용자 간 어트리뷰션 캠페인을 위한 리퍼러 쇼트 링크를 생성합니다. 이 메서드는 사용자가 공유할 수 있는 짧은 링크를 생성하여 추천을 추적하고 신규 인스톨을 특정 리퍼러에 어트리뷰션합니다.

public static void createReferrerShortLink(string baseLink, string referrerName, 
    string referrerId, Dictionary<string, string> passthroughParams, 
    ShortLinkCallback completionHandler)
C#
// Create a referrer short link
var passthroughParams = new Dictionary<string, string>
{
    { "promo_code", "WELCOME10" },
    { "campaign", "spring_2024" }
};

SingularSDK.createReferrerShortLink(
    "https://yourapp.sng.link/12345",
    "John Doe",
    "user_12345",
    passthroughParams,
    (data, error) =>
    {
        if (error == null)
        {
            Debug.Log("Short link created: " + data);
        }
        else
        {
            Debug.LogError("Error creating short link: " + error);
        }
    }
);

CustomRevenue

SingularSDK.CustomRevenue 메서드

지정된 이벤트 이름으로 커스텀 구매 이벤트를 추적합니다. 이를 통해 인앱 구매 이외의 소스(예: 구독 또는 기타 구매화 방법)에서 발생한 구매을 추적할 수 있습니다.

서명

public static void CustomRevenue(string eventName, string currency, double amount)

public static void CustomRevenue(Dictionary<string, object> args, 
    string eventName, string currency, double amount)

사용 예시

C#
// Track custom revenue event
SingularSDK.CustomRevenue("subscription_renewal", "USD", 9.99);

// Track custom revenue with additional attributes
var attributes = new Dictionary<string, object>
{
    { "subscription_type", "premium" },
    { "billing_period", "monthly" }
};

SingularSDK.CustomRevenue(attributes, "subscription_renewal", "USD", 9.99);

EndSingularSession

SingularSDK.EndSingularSession 메서드

현재 Singular 세션을 수동으로 종료합니다. 세션 관리에 대한 명시적인 제어가 필요한 경우 일반적으로 앱이 백그라운드로 전환될 때 호출됩니다.

서명

public static void EndSingularSession()

사용 예시

C#
// End the current session
SingularSDK.EndSingularSession();

Event

SingularSDK.Event 메서드

Unity 애플리케이션에서 커스텀 이벤트를 추적합니다. 이벤트는 이름만으로 추적하거나 더 자세한 분석을 위해 키-값 쌍으로 추가 속성을 사용하여 추적할 수 있습니다.

서명

public static void Event(string name)

public static void Event(Dictionary<string, object> args, string name)

public static void Event(string name, params object[] args)

사용 예시

C#
// Track a simple event
SingularSDK.Event("level_completed");

// Track event with dictionary attributes
var attributes = new Dictionary<string, object>
{
    { "level", 5 },
    { "score", 1250 },
    { "time_seconds", 45.3 }
};
SingularSDK.Event(attributes, "level_completed");

// Track event with params array (key-value pairs)
SingularSDK.Event("item_purchased", 
    "item_name", "Golden Sword",
    "item_category", "weapons",
    "price", 4.99);

GetAPID

SingularSDK.GetAPID 메서드

현재 디바이스에 대한 Singular APID(어트리뷰션 플랫폼 ID)를 반환합니다. 이 식별자는 어트리뷰션 및 분석을 위해 내부적으로 Singular에서 사용됩니다. iOS 전용입니다.

서명

public static string GetAPID()

사용 예시

C#
// Get the APID
string apid = SingularSDK.GetAPID();
Debug.Log("APID: " + apid);

GetGlobalProperties

SingularSDK.GetGlobalProperties 메서드

현재 설정된 모든 글로벌 프로퍼티를 JSON 문자열로 가져옵니다. 글로벌 프로퍼티는 추적된 모든 이벤트에 자동으로 포함되는 키-값 쌍입니다.

서명

public static string GetGlobalProperties()

사용 예제

C#
// Get all global properties
string globalProps = SingularSDK.GetGlobalProperties();
Debug.Log("Global Properties: " + globalProps);

GetIDFA

SingularSDK.GetIDFA 메서드

현재 iOS 디바이스의 IDFA(광고주 식별자)를 반환합니다. 이 메서드는 적절한 ATT(앱 추적 투명성) 권한이 필요합니다. iOS 전용입니다.

서명

public static string GetIDFA()

사용 예시

C#
// Get the IDFA (iOS only)
string idfa = SingularSDK.GetIDFA();
Debug.Log("IDFA: " + idfa);

GetLimitDataSharing

SingularSDK.GetLimitDataSharing 메서드

현재 데이터 공유 제한 상태를 반환합니다. 이는 현재 SDK가 개인정보 보호 설정에 따라 데이터 수집 및 공유를 제한하고 있는지 여부를 나타냅니다.

서명

public static bool GetLimitDataSharing()

사용 예시

C#
// Check if data sharing is limited
bool isLimited = SingularSDK.GetLimitDataSharing();
Debug.Log("Data sharing limited: " + isLimited);

핸들 푸시 알림

SingularSDK.HandlePushNotification 메서드

어트리뷰션 및 딥링크 처리를 위해 푸시 알림 페이로드를 처리합니다. 앱이 푸시 알림을 수신할 때 이 메서드를 호출해야 합니다. iOS 전용입니다.

서명

public static void HandlePushNotification(Dictionary<string, string> pushNotificationPayload)

사용 예시

C#
// Handle push notification (iOS only)
var pushPayload = new Dictionary<string, string>
{
    { "aps", "{"alert":"New message"}" },
    { "deep_link", "myapp://promo/spring2024" }
};

SingularSDK.HandlePushNotification(pushPayload);

InAppPurchase

SingularSDK.InAppPurchase 메서드

Unity IAP에서 인앱 구매를 추적합니다. 이 메서드는 Unity IAP 4.x와 5.x를 모두 지원하며 Apple 및 Google에서 구매 영수증의 유효성을 자동으로 검사합니다.

서명

public static void InAppPurchase(Product product, Dictionary<string, object> attributes)

사용 예제

C#
// Track in-app purchase
void OnPurchaseComplete(Product product)
{
    var attributes = new Dictionary<string, object>
    {
        { "category", "consumables" },
        { "location", "main_store" }
    };

    SingularSDK.InAppPurchase(product, attributes);
}

InitializeSingularSDK

SingularSDK.InitializeSingularSDK 메서드

Singular SDK를 수동으로 초기화합니다. 이 메서드는 SDK 구성에서 InitializeOnAwake를 false로 설정한 경우에만 호출해야 합니다. 그렇지 않으면 SDK가 자동으로 초기화됩니다.

서명

public static void InitializeSingularSDK()

사용 예시

C#
// Manually initialize the SDK (only if InitializeOnAwake = false)
SingularSDK.InitializeSingularSDK();

IsAllTrackingStopped

SingularSDK.IsAllTrackingStopped 메서드

모든 추적이 중지되었는지 여부를 반환합니다. 추적이 중지되면 SDK는 어떠한 이벤트도 전송하거나 데이터를 수집하지 않습니다.

서명

public static bool IsAllTrackingStopped()

사용 예시

C#
// Check if tracking is stopped
bool isTrackingStopped = SingularSDK.IsAllTrackingStopped();
Debug.Log("Tracking stopped: " + isTrackingStopped);

데이터 공유 제한

SingularSDK.LimitDataSharing 메서드

SDK가 데이터 공유를 제한할지 여부를 설정합니다. 활성화하면 SDK는 개인정보 보호 규정을 준수하기 위해 특정 데이터 수집 및 공유 활동을 제한합니다.

서명

public static void LimitDataSharing(bool limitDataSharingValue)

사용 예시

C#
// Enable limited data sharing based on user consent
SingularSDK.LimitDataSharing(true);

RegisterDeviceTokenForUninstall

SingularSDK.RegisterDeviceTokenForUninstall 메서드

제거 추적을 위해 디바이스 토큰을 등록합니다. 이를 통해 Singular는 사용자가 앱을 제거할 때 이를 감지할 수 있습니다. iOS 전용.

서명

public static void RegisterDeviceTokenForUninstall(string APNSToken)

사용 예시

C#
// Register APNS token for uninstall tracking (iOS only)
void OnTokenReceived(string token)
{
    SingularSDK.RegisterDeviceTokenForUninstall(token);
}

RestartSingularSession

SingularSDK.RestartSingularSession 메서드

Singular 세션을 수동으로 다시 시작합니다. 일반적으로 세션 관리를 명시적으로 제어해야 하는 경우 앱이 포그라운드로 돌아올 때 호출됩니다.

시그니처

public static void RestartSingularSession(string key, string secret)

사용 예시

C#
// Restart the session
SingularSDK.RestartSingularSession("SDK KEY", "YOUR_SECRET");

ResumeAllTracking

SingularSDK.ResumeAllTracking 메서드

이전에 중지된 모든 추적을 재개합니다. 이벤트 추적 및 데이터 수집을 다시 활성화합니다.

서명

public static void ResumeAllTracking()

사용 예시

C#
// Resume tracking
SingularSDK.ResumeAllTracking();

Revenue

SingularSDK.Revenue 메서드

구매 이벤트를 추적합니다. 이 메서드는 Unity IAP를 통해 자동으로 추적되지 않는 구매 및 기타 구매화 이벤트를 추적하는 기본 메서드입니다.

Signature

public static void Revenue(string currency, double amount)

public static void Revenue(Dictionary<string, object> args, 
    string currency, double amount)

사용 예시

C#
// Track simple revenue
SingularSDK.Revenue("USD", 9.99);

// Track revenue with attributes
var attributes = new Dictionary<string, object>
{
    { "product_id", "premium_upgrade" },
    { "product_name", "Premium Subscription" },
    { "product_category", "subscriptions" }
};

SingularSDK.Revenue(attributes, "USD", 9.99);

SetAge

SingularSDK.SetAge 메서드

인구통계학적 추적을 위한 사용자의 연령을 설정합니다. 나이는 0에서 100 사이여야 합니다. iOS 전용입니다.

서명

public static void SetAge(int age)

사용 예시

C#
// Set user age (iOS only)
SingularSDK.SetAge(28);

설정전환값업데이트핸들러

SingularSDK.SetConversionValueUpdatedHandler 메서드

SKAdNetwork 전환 값 업데이트를 위한 콜백 핸들러를 설정합니다(iOS 14+). 이 핸들러는 전환 값이 업데이트될 때마다 호출됩니다. iOS 전용입니다.

시그니처

public static void SetConversionValueUpdatedHandler(SingularConversionValueUpdatedHandler handler)

사용 예시

C#
// Set conversion value updated handler (iOS only)
SingularSDK.SetConversionValueUpdatedHandler((conversionValue) =>
{
    Debug.Log("Conversion value updated: " + conversionValue);
});

SetConversionValuesUpdatedHandler

SingularSDK.SetConversionValuesUpdatedHandler 메서드

SKAdNetwork 4.0 이상 전환 값 업데이트에 대한 콜백 핸들러를 설정합니다. 이 핸들러는 전환 값, 대략적인 전환 값, 잠금 상태를 제공합니다. iOS 전용입니다.

서명

public static void SetConversionValuesUpdatedHandler(SingularConversionValuesUpdatedHandler handler)

사용 예시

C#
// Set conversion values updated handler (iOS only)
SingularSDK.SetConversionValuesUpdatedHandler((conversionValue, coarse, lockWindow) =>
{
    Debug.Log($"CV: {conversionValue}, Coarse: {coarse}, Lock: {lockWindow}");
});

SetCustomUserId

SingularSDK.SetCustomUserId 메서드

추적된 모든 이벤트와 연결할 사용자 정의 사용자 ID를 설정합니다. 이를 통해 Singular 데이터를 자체 사용자 식별 시스템에 연결할 수 있습니다.

서명

public static void SetCustomUserId(string customUserId)

사용 예시

C#
// Set custom user ID
SingularSDK.SetCustomUserId("user_123456");

SetDeviceCustomUserId

SingularSDK.SetDeviceCustomUserId 메서드

장치 수준의 사용자 지정 사용자 ID를 설정합니다. 이는 일반 사용자 지정 사용자 ID와는 다르며 기기 수준에서 앱 세션 전반에 걸쳐 유지됩니다.

서명

public static void SetDeviceCustomUserId(string customUserId)

사용 예제

C#
// Set device-level custom user ID
SingularSDK.SetDeviceCustomUserId("device_user_789");

SetFCMDeviceToken

SingularSDK.SetFCMDeviceToken 메서드

푸시 알림 추적 및 제거 감지를 위한 FCM(파이어베이스 클라우드 메시징) 디바이스 토큰을 설정합니다. 안드로이드 전용.

서명

public static void SetFCMDeviceToken(string fcmDeviceToken)

사용 예시

C#
// Set FCM token (Android only)
void OnFCMTokenReceived(string token)
{
    SingularSDK.SetFCMDeviceToken(token);
}

SetGender

SingularSDK.SetGender 메서드

인구통계학적 추적을 위해 사용자의 성별을 설정합니다. 남성의 경우 "m", 여성의 경우 "f"를 허용합니다. iOS 전용입니다.

서명

public static void SetGender(string gender)

사용 예시

C#
// Set user gender (iOS only)
SingularSDK.SetGender("f");

SetGlobalProperty

SingularSDK.SetGlobalProperty 메서드

모든 이벤트와 함께 전송할 글로벌 프로퍼티를 설정합니다. 글로벌 프로퍼티는 지워지거나 변경될 때까지 여러 이벤트에 걸쳐 지속되는 키-값 쌍입니다.

서명

public static bool SetGlobalProperty(string key, string value, bool overrideExisting)

사용 예제

C#
// Set a global property
bool success = SingularSDK.SetGlobalProperty("user_level", "premium", true);

// Set multiple global properties
SingularSDK.SetGlobalProperty("app_version", "2.1.0", true);
SingularSDK.SetGlobalProperty("platform", "unity", true);

SetIMEI

SingularSDK.SetIMEI 메서드

추적할 디바이스 IMEI를 설정합니다. 이 메서드는 IMEI 추적이 허용되고 선호되는 지역에서 유용합니다. 안드로이드 전용.

서명

public static void SetIMEI(string imei)

사용 예시

C#
// Set device IMEI (Android only)
SingularSDK.SetIMEI("123456789012345");

SetLimitAdvertisingIdentifiers

SingularSDK.SetLimitAdvertisingIdentifiers 메서드

제한된 광고 식별자 모드를 활성화합니다. 이는 SDK가 추적을 위해 디바이스 식별자를 수집하고 사용하는 방식에 영향을 미치며, 혼합 오디언스 앱에 적합합니다.

서명

public static void SetLimitAdvertisingIdentifiers(bool isEnabled)

사용 예시

C#
// Enable limited advertising identifiers mode
SingularSDK.SetLimitAdvertisingIdentifiers(true);

설정Singular 디바이스 어트리뷰션 콜백 핸들러

SingularSDK.SetSingularDeviceAttributionCallbackHandler 메서드

디바이스 어트리뷰션 데이터를 수신할 콜백 핸들러를 설정합니다. 이 핸들러는 어트리뷰션 데이터를 사용할 수 있게 되면 호출되어 캠페인 및 소스 정보에 액세스할 수 있도록 합니다.

  1. 아래 핸들러 코드를 사용하여 C# Script AttributionCallback 를 생성합니다.

  2. 계층 구조에서 Emtpy 객체를 생성하고 SingularSDKObject 아래에 배치합니다.

  3. 빈 객체에 AttributionCallback 핸들러 Script를 연결하는 Script 컴포넌트를 추가합니다.

서명

public static void SetSingularDeviceAttributionCallbackHandler(
    SingularDeviceAttributionCallbackHandler handler)

사용 예시

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Singular;

public class AttributionCallback : MonoBehaviour, SingularDeviceAttributionCallbackHandler 
{
    void Awake()
    {
        Debug.Log("Registering SingularDeviceAttributionCallbackHandler");
        SingularSDK.SetSingularDeviceAttributionCallbackHandler(this);
    }

    public void OnSingularDeviceAttributionCallback(Dictionary attributionInfo) {
		foreach(var kvp in attributionInfo)
		{
			Debug.Log($"OnSingularDeviceAttributionCallback Key: {kvp.Key}, Value: {kvp.Value}");
		}
	}
}

SetSingularLinkHandler

SingularSDK.SetSingularLinkHandler 메서드

Singular 링크(딥링크)에 대한 콜백 핸들러를 설정합니다. 이 핸들러는 딥링크가 확인될 때 호출되어 링크 파라미터와 패스스루 데이터를 제공합니다.

  1. 아래 핸들러 코드를 사용하여 C# Script DeepLinkManager 를 만듭니다.

  2. 계층 구조에서 Emtpy 객체를 생성하고 SingularSDKObject 아래에 배치합니다.

  3. 빈 객체에 DeepLinkManager 핸들러 Script를 연결하는 Script 컴포넌트를 추가합니다.

서명

public static void SetSingularLinkHandler(SingularLinkHandler linkHandler)

사용 예제

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Singular;

public class DeepLinkManager : MonoBehaviour, SingularLinkHandler
{
    void Awake()
    {
        Debug.Log("Registering SingularLink Handler");
        SingularSDK.SetSingularLinkHandler(this);
    }

    public void OnSingularLinkResolved(SingularLinkParams linkParams)
    {
        Debug.Log("SingularLink Resolved");

        // Extract parameters from the tracking link
        string deeplink = linkParams.Deeplink;
        string passthrough = linkParams.Passthrough;
        bool isDeferred = linkParams.IsDeferred;

        // Log the parameters
        Debug.Log($"SingularLink Deeplink: {deeplink ?? "null"}");
        Debug.Log($"SingularLink Passthrough: {passthrough ?? "null"}");
        Debug.Log($"SingularLink is Deferred: {isDeferred}");

        // Handle deep link routing
        if (!string.IsNullOrEmpty(deeplink))
        {
            HandleDeepLink(deeplink, isDeferred);
        }
    }

    private void HandleDeepLink(string url, bool isDeferred)
    {
        // Your deep link routing logic here
        Debug.Log($"SingularLink Routing to: {url} (Deferred: {isDeferred})");

        // Example: Parse the URL and navigate to the appropriate screen
        // if (url.Contains("product"))
        // {
        //     NavigateToProduct(url);
        // }
    }
}

설정Singular에스디아이디액세서핸들러

SingularSDK.SetSingularSdidAccessorHandler 메서드

Singular 장치 ID(SDID)를 수신할 콜백 핸들러를 설정합니다. 이 핸들러는 SDK 초기화 후 SDID를 사용할 수 있게 되면 호출됩니다.

  1. 아래 핸들러 코드를 사용하여 C# Script SDIDManager 를 만듭니다.

  2. 계층 구조에서 Emtpy 객체를 생성하고 SingularSDKObject 아래에 배치합니다.

  3. 빈 오브젝트에 SDIDManager 핸들러 Script를 연결하는 Script 컴포넌트를 추가합니다.

서명

public static void SetSingularSdidAccessorHandler(SingularSdidAccessorHandler handler)

사용 예제

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Singular;

public class SDIDManager : MonoBehaviour, SingularSdidAccessorHandler
{
    void Awake()
    {
        Debug.Log("Registering SingularSdidAccessorHandler");
        SingularSDK.SetSingularSdidAccessorHandler(this);
    }

    public void DidSetSdid(string sdid)
    {
        Debug.Log($"SDID Set: {sdid}");
    }

    public void SdidReceived(string sdid)
    {
        Debug.Log($"SDID Set: {sdid}");
        // Store or use the SDID as needed
    }   
}

SkanRegisterAppForAdNetworkAttribution

SingularSDK.SkanRegisterAppForAdNetworkAttribution 메소드

SKAdNetwork 어트리뷰션을 위해 앱을 등록합니다. 이 메서드는 iOS 14.5 이상 SKAdNetwork 지원을 위해 앱 라이프사이클 초기에 호출해야 합니다. iOS 전용입니다.

서명

public static void SkanRegisterAppForAdNetworkAttribution()

사용 예시

C#
// Register for SKAdNetwork attribution (iOS only)
SingularSDK.SkanRegisterAppForAdNetworkAttribution();

SkanUpdateConversionValue

SingularSDK.SkanUpdateConversionValue 메서드

SKAdNetwork 전환 값을 수동으로 업데이트합니다. 이 메서드는 수동 전환 값 관리가 활성화된 경우에 사용됩니다. iOS 전용입니다.

서명

public static bool SkanUpdateConversionValue(int conversionValue)

public static bool SkanUpdateConversionValue(int conversionValue, int coarse, bool lockWindow)

사용 예시

C#
// Update conversion value (iOS only)
bool success = SingularSDK.SkanUpdateConversionValue(5);

// Update with coarse value and lock (SKAdNetwork 4.0+)
bool success2 = SingularSDK.SkanUpdateConversionValue(10, 2, false);

StopAllTracking

SingularSDK.StopAllTracking 메서드

모든 추적 및 데이터 수집을 중지합니다. 추적이 중지되면 추적이 재개될 때까지 SDK는 어떠한 이벤트도 전송하거나 데이터를 수집하지 않습니다.

서명

public static void StopAllTracking()

사용 예시

C#
// Stop all tracking
SingularSDK.StopAllTracking();

TrackingOptIn

SingularSDK.TrackingOptIn 메서드

사용자가 추적에 동의했음을 나타냅니다. 이 메서드는 사용자가 데이터 수집 및 추적에 명시적으로 동의할 때 호출해야 합니다.

서명

public static void TrackingOptIn()

사용 예시

C#
// User opted in to tracking
SingularSDK.TrackingOptIn();

TrackingUnder13

SingularSDK.TrackingUnder13 메서드

사용자가 13세 미만임을 나타내며, 이는 COPPA(아동 온라인 개인정보 보호법) 규정을 준수하기 위한 데이터 수집에 영향을 줍니다.

서명

public static void TrackingUnder13()

사용 예시

C#
// User is under 13 years old
SingularSDK.TrackingUnder13();

UnsetCustomUserId

SingularSDK.UnsetCustomUserId 메서드

이전에 설정된 사용자 정의 사용자 ID를 제거합니다. 이 메서드를 호출하면 새 사용자 아이디가 설정될 때까지 이벤트가 더 이상 사용자 지정 사용자 아이디에 연결되지 않습니다.

서명

public static void UnsetCustomUserId()

사용 예시

C#
// Remove custom user ID (e.g., on logout)
SingularSDK.UnsetCustomUserId();

UnsetGlobalProperty

SingularSDK.UnsetGlobalProperty 메서드

특정 글로벌 프로퍼티를 키별로 제거합니다. 이렇게 하면 해당 프로퍼티가 후속 이벤트와 함께 전송되지 않습니다.

서명

public static void UnsetGlobalProperty(string key)

사용 예시

C#
// Remove a specific global property
SingularSDK.UnsetGlobalProperty("user_level");