Unity SDK
자세한 기록을 보려면 릴리스 노트를 참조하십시오.
Tenjin 유니티 플러그인
- 유니티 개발자가 Tenjin의 설치 API와 신속히 통합할 수 있게 합니다
- iOS 및 Android 설명서를 검토하고 빌드에 적절한 플랫폼 설정을 적용하십시오. 가장 중요한 것은:
- iOS: 적절한 빌드 설정이 있고 필요한 iOS 프레임워크를 포함해야합니다.
- Android: 이미 Google Play 서비스가 설치되어 있거나 PlayServicesResolver를 사용하는 다른 SDK가 설치되어있는 경우, 다음 파일을 삭제해야 할 수 있습니다:
/Assets/Plugins/Android/play-services-basement-11.0.4.aar
API_KEY
는 organizations 탭에 있습니다.
Tenjin 설치/세션 통합:
- Unity 프로젝트에 Assets 폴더 포함하기
- 프로젝트의 첫번째
start()
메소드에서 다음BaseTenjin instance=Tenjin.getInstance (“API_KEY”)
와instance.Connect()
작성하기
다음은 코드 예제입니다:
using UnityEngine;
using System.Collections;
public class TenjinExampleScript : MonoBehaviour {
// Use this for initialization
void Start () {
BaseTenjin instance = Tenjin.getInstance("API_KEY");
instance.Connect();
}
// Update is called once per frame
void Update () {
}
void OnApplicationPause(bool pauseStatus){
if(pauseStatus){
//do nothing
}
else
{
BaseTenjin instance = Tenjin.getInstance("API_KEY");
instance.Connect();
}
}
}
Live Test Device Data Tool을 통해 통합이 작동하는지 확인할 수 있습니다. 테스트 장치 목록에 advertising_id 또는 IDFA/GAID를 추가하십시오. Support(지원) -> Test Devices 에서서 찾을 수 있습니다. SDK 라이브 페이지로 이동하여 앱에서 테스트 이벤트를 보냅니다. 실시간 이벤트가 나타나는 것을 확인할 수 있습니다:
Tenjin and GDPR:
GDPR 준수의 일환으로 Tenjin의 SDK를 사용하면 장치/사용자를 opt-in하거나 opt-out하거나, 특정 장치 관련 매개 변수를 선택하여 opt-in 또는 opt-out 할 수 있습니다. OptOut()
는 Tenjin에 API 요청을 보내지 않으며 이벤트를 처리하지 않습니다.
Opt-in/Opt-out 진행시:
void Start () {
BaseTenjin instance = Tenjin.getInstance("API_KEY");
boolean userOptIn = CheckOptInValue();
if (userOptIn) {
instance.OptIn();
}
else {
instance.OptOut();
}
instance.Connect();
}
boolean CheckOptInValue(){
// check opt-in value
// return true; // if user opted-in
return false;
}
특정 장치 관련 매개 변수를 opt-in/opt-out 하려면 OptInParams()
또는 OptOutParams()
를 사용할 수 있습니다.
OptInParams()
는 지정된 장치 관련 매개 변수만을 보냅니다. OptOutParams()
는 지정된 것 이외의 모든 장치 관련 매개 변수를 보냅니다.
Tenjin의 시스템에서 장치를 올바르게 추적하려면 최소한 ip_address
, advertising_id
, developer_device_id
, limit_ad_tracking
, referrer
(Android) 및 iad
(iOS)가 필요합니다.
Google을 사용하려는 경우 다음을 추가해야합니다: platform
, os_version
, locale
, device_model
, build_id
특정 장치 관련 매개 변수만 가져오려면 OptInParams()
를 사용하십시오. 아래의 예에서는 이러한 장치 관련 매개 변수만 사용합니다:
void Start () {
BaseTenjin instance = Tenjin.getInstance("API_KEY");
List<string> optInParams = new List<string> {"advertising_id", "developer_device_id", "limit_ad_tracking", "referrer", "device_all", "iad"};
instance.OptInParams(optInParams);
instance.Connect();
}
특정 장치 관련 매개 변수를 제외한 모든 매개 변수를 보내려면 OptOutParams()
를 사용하십시오. 아래 예를 제외하고는 모든 장치 관련 매개 변수를 전송합니다:
locale
, timezone
, build_id
매개 변수.
void Start () {
BaseTenjin instance = Tenjin.getInstance("API_KEY");
List<string> optOutParams = new List<string> {"country", "timezone", "language"};
instance.OptOutParams(optOutParams);
instance.Connect();
}
장치 관련 매개 변수들
매개변수 | 설명 | 플랫폼 | 参照 |
---|---|---|---|
advertising_id | advertising_id | Android) | |
developer_device_id | Vendor ID | iOS | |
limit_ad_tracking | limit ad tracking enabled | Android) | |
platform | platform | All | |
os_version | OS version | Android | |
device | device name | Android | |
device_manufacturer | device manufatucturer | Android | |
device_model | device model | Android | |
device_brand | device brand | Android | |
device_product | device product | Android | |
carrier | carrier | Android) | |
connection_type | celluar or wifi | All | Android) |
screen_width | device width | All | Android |
screen_height | device height | All | Android |
os_version_release | release OS version | All | Android |
build_id | build ID | All | Android |
locale | device locale | All | Android) |
Tenjin 구매 이벤트 통합 지침:
iOS IAP 확인
iOS receipt를 확인하려면transactionId
와 receipt
(signature
은 null로 설정됨)이 필요합니다. Receipt을 받으려면, receipt Payload (Base64 인코딩 된 ASN.1 receipt)를 Unity에서 보내야합니다.
중요: 구독 IAP가 있는 경우 Tenjin 대시보드에 앱의 공유 비밀을 추가해야 합니다. iTunes Connect Console> Select your app> Features> In-App Purchases> App-Specific Shared Secret에서 iOS 응용 프로그램별 공유 비밀을 검색할 수 있습니다.
Android IAP 확인
Android receipt 확인은 receipt
와 signature
가 요구된다 (transactionId는 null로 설정됨)
중요: 앱의 public key를 Tenjin 대시보드에 추가해야합니다. Google Play Developer Console> Select your app> Development Tools> Services & APIs를 통해 Base64-인코딩된 RSA public key를 검색할 수 있습니다.
iOS와 Android 예제:
public static void OnProcessPurchase(PurchaseEventArgs purchaseEventArgs) {
var price = purchaseEventArgs.purchasedProduct.metadata.localizedPrice;
double lPrice = decimal.ToDouble(price);
var currencyCode = purchaseEventArgs.purchasedProduct.metadata.isoCurrencyCode;
var wrapper = Json.Deserialize(purchaseEventArgs.purchasedProduct.receipt) as Dictionary<string, object>; // https://gist.github.com/darktable/1411710
if (null == wrapper) {
return;
}
var payload = (string)wrapper["Payload"]; // For Apple this will be the base64 encoded ASN.1 receipt
var productId = purchaseEventArgs.purchasedProduct.definition.id;
#if UNITY_ANDROID
var gpDetails = Json.Deserialize(payload) as Dictionary<string, object>;
var gpJson = (string)gpDetails["json"];
var gpSig = (string)gpDetails["signature"];
CompletedAndroidPurchase(productId, currencyCode, 1, lPrice, gpJson, gpSig);
#elif UNITY_IOS
var transactionId = purchaseEventArgs.purchasedProduct.transactionID;
CompletedIosPurchase(productId, currencyCode, 1, lPrice , transactionId, payload);
#endif
}
private static void CompletedAndroidPurchase(string ProductId, string CurrencyCode, int Quantity, double UnitPrice, string Receipt, string Signature)
{
BaseTenjin instance = Tenjin.getInstance("API_KEY");
instance.Transaction(ProductId, CurrencyCode, Quantity, UnitPrice, null, Receipt, Signature);
}
private static void CompletedIosPurchase(string ProductId, string CurrencyCode, int Quantity, double UnitPrice, string TransactionId, string Receipt)
{
BaseTenjin instance = Tenjin.getInstance("API_KEY");
instance.Transaction(ProductId, CurrencyCode, Quantity, UnitPrice, TransactionId, Receipt, null);
}
구독 IAP
중요: 구독 IAP가 있다면, 앱의 public key를 Tenjin 대시보드에 추가해야합니다. iTunes Connect Console > Select your app > Features > In-App Purchases > App-Specific Shared Secret를 통해 iOS 응용 프로그램별 공유 비밀을 검색할 수 있습니다.
구독 기간마다 구독 거래를 한번씩 보내셔야 한다는 점을 참고해주세요 (예를 들면, 월 단위 구독의 경우 한달에 한번 거래를 보내야함).
아래 예제의 타임라인에서 거래 이벤트는 “First Charge”와 “Renewal” 이벤트에서만 보내야합니다. 시험 기간 중에는 Tenjin에 거래 이벤트를 보내지 마십시오. Tenjin은 중복 거래를 중복 제거하지 않습니다.
구독과 관련하여 더 자세한 정보를 알고싶다면, 다음을 확인해주세요: Apple documentation on Working with Subscriptions
Tenjin 커스텀 이벤트 통합:
- Unity 프로젝트에 Assets 폴더 포함하기
- 프로젝트 메소드의 커스텀 이벤트에서, 명명된 이벤트에 대해 다음을 작성하십시오:
Tenjin.getInstance("<API_KEY>").SendEvent("name")
및 정수 값을 갖는 명명된 이벤트에 대해서는 다음과 같
Tenjin.getInstance("<API_KEY>").SendEvent("nameWithValue","value")
전달된 값이 정수인지 확인하십시오. value가 정수가 아니면 이벤트가 전달되지 않습니다.
코드의 예제입니다:
void MethodWithCustomEvent(){
//event with name
BaseTenjin instance = Tenjin.getInstance ("API_KEY");
instance.SendEvent("name");
//event with name and integer value
instance.SendEvent("nameWithValue", "value");
}
.SendEvent("name")
는 정적 표시 또는 중요한 단계 이벤트에 사용됩니다. 여기에는 tutorial_complete
, registration
또는 level_1
등이 포함됩니다.
.SendEvent("name","value")
는 해당 이벤트의 속성에서 연산을 수행할 이벤트를 나타냅니다. 예를 들어 ("coins_purchased","100")
해당 이벤트에 대해 구입한 동정의 합 또는 평균을 분석할 수 있습니다.
Tenjin 지연된 딥링크 통합 지침:
Tenjin은 Tenjin의 캠페인 추적 URL들을 통해 새로운 속성 설치 후 사용자를 앱의 특정 부분으로 안내할 수 있는 기능을 지원합니다. GetDeeplink 핸들러를 사용하여 지연된 딥링크에 액세스할 수 있습니다. 테스트하려면 이곳에서 안내사항을 따르십시오.
public class TenjinExampleScript : MonoBehaviour {
// Use this for initialization
void Start () {
BaseTenjin instance = Tenjin.getInstance("API_KEY");
instance.Connect();
instance.GetDeeplink(DeferredDeeplinkCallback);
}
public void DeferredDeeplinkCallback(Dictionary<string, string> data) {
bool clicked_tenjin_link = false;
bool is_first_session = false;
if (data.ContainsKey("clicked_tenjin_link")) {
//clicked_tenjin_link is a BOOL to handle if a user clicked on a tenjin link
clicked_tenjin_link = (data["clicked_tenjin_link"] == "true");
Debug.Log("===> DeferredDeeplinkCallback ---> clicked_tenjin_link: " + data["clicked_tenjin_link"]);
}
if (data.ContainsKey("is_first_session")) {
//is_first_session is a BOOL to handle if this session for this user is the first session
is_first_session = (data["is_first_session"] == "true");
Debug.Log("===> DeferredDeeplinkCallback ---> is_first_session: " + data["is_first_session"]);
}
if (data.ContainsKey("ad_network")) {
//ad_network is a STRING that returns the name of the ad network
Debug.Log("===> DeferredDeeplinkCallback ---> adNetwork: " + data["ad_network"]);
}
if (data.ContainsKey("campaign_id")) {
//campaign_id is a STRING that returns the tenjin campaign id
Debug.Log("===> DeferredDeeplinkCallback ---> campaignId: " + data["campaign_id"]);
}
if (data.ContainsKey("advertising_id")) {
//advertising_id is a STRING that returns the advertising_id of the user
Debug.Log("===> DeferredDeeplinkCallback ---> advertisingId: " + data["advertising_id"]);
}
if (data.ContainsKey("deferred_deeplink_url")) {
//deferred_deeplink_url is a STRING that returns the deferred_deeplink of the campaign
Debug.Log("===> DeferredDeeplinkCallback ---> deferredDeeplink: " + data["deferred_deeplink_url"]);
}
if (clicked_tenjin_link && is_first_session) {
//use the deferred_deeplink_url to direct the user to a specific part of your app
if (String.IsNullOrEmpty(data["deferred_deeplink_url"]) == false) {
}
}
}
}
iOS 프레임워크 요구사항
AdSupport.framework
iAd.framework
StoreKit.framework