[SDK]TalkingData移动至打包流程 测试
parent
8b4040841b
commit
16e45ee28d
|
|
@ -2,6 +2,9 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 用于辅助TalkingData初始化
|
||||
/// </summary>
|
||||
public partial class TalkingDataInitTool
|
||||
{
|
||||
#if DEVELOPMENT_BUILD || DEBUG
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 67de34aafaa71b07a70a1489ebe0dc549389223e
|
||||
Subproject commit f08c1123df8befd29d6a278b3a69d3f71ea03456
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fb5ecaf122efe6940a9af343df1fadaf, type: 3}
|
||||
m_Name: TalkingDataSettings
|
||||
m_EditorClassIdentifier:
|
||||
appId: 75029605700B4544950D77C9FF506D0D
|
||||
channel: test
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4cc3473a73a16c8409a924c59aec6a3b
|
||||
NativeFormatImporter:
|
||||
guid: 21d1d86bd844da14487a7bbc78bb686b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,393 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class TDDemoScript : MonoBehaviour
|
||||
{
|
||||
private const int top = 100;
|
||||
private const int left = 80;
|
||||
private const int height = 60;
|
||||
private const int spacing = 20;
|
||||
private readonly int width = (Screen.width - (left * 2) - spacing) / 2;
|
||||
private const int step = 80;
|
||||
private string tdid;
|
||||
private string oaid;
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
int i = 0;
|
||||
GUI.Box(new Rect(10, 10, Screen.width - 20, Screen.height - 20), "Demo Menu");
|
||||
|
||||
GUI.Label(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), tdid);
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "getTDID"))
|
||||
{
|
||||
tdid = TalkingDataSDK.GetDeviceId();
|
||||
}
|
||||
|
||||
#if UNITY_ANDROID
|
||||
GUI.Label(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), oaid);
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "getOAID"))
|
||||
{
|
||||
oaid = TalkingDataSDK.GetOAID();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnPageBegin"))
|
||||
{
|
||||
TalkingDataSDK.OnPageBegin("home_page");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnPageEnd"))
|
||||
{
|
||||
TalkingDataSDK.OnPageEnd("home_page");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnReceiveDeepLink"))
|
||||
{
|
||||
TalkingDataSDK.OnReceiveDeepLink("https://www.talkingdata.com");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnRegister"))
|
||||
{
|
||||
TalkingDataProfile profile = TalkingDataProfile.CreateProfile();
|
||||
profile.SetName("name01");
|
||||
profile.SetType(TalkingDataProfileType.WEIXIN);
|
||||
profile.SetGender(TalkingDataGender.MALE);
|
||||
profile.SetAge(18);
|
||||
profile.SetProperty1("property1");
|
||||
profile.SetProperty2(2);
|
||||
profile.SetProperty3(3.14);
|
||||
profile.SetProperty4("property4");
|
||||
profile.SetProperty5("property5");
|
||||
profile.SetProperty6(0.618);
|
||||
profile.SetProperty7("property7");
|
||||
profile.SetProperty8("property8");
|
||||
profile.SetProperty9(9.8);
|
||||
profile.SetProperty10("property10");
|
||||
Dictionary<string, object> eventValue = new Dictionary<string, object>
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
TalkingDataSDK.OnRegister("user01", profile, "123456", eventValue);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnLogin"))
|
||||
{
|
||||
TalkingDataProfile profile = TalkingDataProfile.CreateProfile();
|
||||
profile.SetName("name01");
|
||||
profile.SetType(TalkingDataProfileType.WEIXIN);
|
||||
profile.SetGender(TalkingDataGender.MALE);
|
||||
profile.SetAge(18);
|
||||
profile.SetProperty1("property1");
|
||||
profile.SetProperty2(2);
|
||||
profile.SetProperty3(3.14);
|
||||
profile.SetProperty4("property4");
|
||||
profile.SetProperty5("property5");
|
||||
profile.SetProperty6(0.618);
|
||||
profile.SetProperty7("property7");
|
||||
profile.SetProperty8("property8");
|
||||
profile.SetProperty9(9.8);
|
||||
profile.SetProperty10("property10");
|
||||
Dictionary<string, object> eventValue = new Dictionary<string, object>
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
TalkingDataSDK.OnLogin("user01", profile, eventValue);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnProfileUpdate"))
|
||||
{
|
||||
TalkingDataProfile profile = TalkingDataProfile.CreateProfile();
|
||||
profile.SetName("name01");
|
||||
profile.SetType(TalkingDataProfileType.WEIXIN);
|
||||
profile.SetGender(TalkingDataGender.MALE);
|
||||
profile.SetAge(18);
|
||||
profile.SetProperty1("property1");
|
||||
profile.SetProperty2(2);
|
||||
profile.SetProperty3(3.14);
|
||||
profile.SetProperty4("property4");
|
||||
profile.SetProperty5("property5");
|
||||
profile.SetProperty6(0.618);
|
||||
profile.SetProperty7("property7");
|
||||
profile.SetProperty8("property8");
|
||||
profile.SetProperty9(9.8);
|
||||
profile.SetProperty10("property10");
|
||||
TalkingDataSDK.OnProfileUpdate(profile);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnCreateCard"))
|
||||
{
|
||||
TalkingDataSDK.OnCreateCard("user01", "支付宝", "支付宝账号123456789");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnFavorite"))
|
||||
{
|
||||
Dictionary<string, object> eventValue = new Dictionary<string, object>
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
TalkingDataSDK.OnFavorite("服装", "2019新款", eventValue);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnShare"))
|
||||
{
|
||||
Dictionary<string, object> eventValue = new Dictionary<string, object>
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
TalkingDataSDK.OnShare("user01", "课程", eventValue);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnPunch"))
|
||||
{
|
||||
TalkingDataSDK.OnPunch("user01", "签到0023");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnSearch"))
|
||||
{
|
||||
TalkingDataSearch search = TalkingDataSearch.CreateSearch();
|
||||
search.SetCategory("类型");
|
||||
search.SetContent("内容");
|
||||
#if TD_RETAIL
|
||||
search.SetItemId("商品ID");
|
||||
search.SetItemLocationId("location12314");
|
||||
#endif
|
||||
#if TD_TOUR
|
||||
search.SetDestination("目的地");
|
||||
search.SetOrigin("出发地");
|
||||
search.SetStartDate(1565176907309);
|
||||
search.SetEndDate(1565176908309);
|
||||
#endif
|
||||
TalkingDataSDK.OnSearch(search);
|
||||
}
|
||||
|
||||
#if TD_RETAIL || TD_FINANCE || TD_TOUR || TD_ONLINEEDU
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnContact"))
|
||||
{
|
||||
TalkingDataSDK.OnContact("user01", "联系平台内容");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_GAME || TD_TOUR || TD_ONLINEEDU || TD_READING || TD_OTHER
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnPay"))
|
||||
{
|
||||
TalkingDataSDK.OnPay("user01", "order01", 1077600, "CNY", "Apple Pay", "item01", 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_RETAIL || TD_FINANCE || TD_TOUR || TD_ONLINEEDU
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnChargeBack"))
|
||||
{
|
||||
TalkingDataSDK.OnChargeBack("user01", "order01", "7天无理由退货", "仅退款");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_FINANCE || TD_ONLINEEDU
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnReservation"))
|
||||
{
|
||||
TalkingDataSDK.OnReservation("user01", "AdTracking_123456", "借贷类", 12, "商品信息");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_RETAIL || TD_TOUR
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnBooking"))
|
||||
{
|
||||
TalkingDataSDK.OnBooking("user01", "002391", "电子", 123, "商品信息");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_RETAIL
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnViewItem"))
|
||||
{
|
||||
Dictionary<string, object> eventValue = new Dictionary<string, object>
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
TalkingDataSDK.OnViewItem("A1660", "手机", "iPhone 7", 538800, eventValue);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnAddItemToShoppingCart"))
|
||||
{
|
||||
Dictionary<string, object> eventValue = new Dictionary<string, object>
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
TalkingDataSDK.OnAddItemToShoppingCart("MLH12CH", "电脑", "MacBook Pro", 1388800, 1, eventValue);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnViewShoppingCart"))
|
||||
{
|
||||
TalkingDataShoppingCart shoppingCart = TalkingDataShoppingCart.CreateShoppingCart();
|
||||
if (shoppingCart != null)
|
||||
{
|
||||
shoppingCart.AddItem("A1660", "手机", "iPhone 7", 538800, 2);
|
||||
shoppingCart.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1);
|
||||
TalkingDataSDK.OnViewShoppingCart(shoppingCart);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnPlaceOrder"))
|
||||
{
|
||||
TalkingDataOrder order = TalkingDataOrder.CreateOrder("order01", 2466400, "CNY");
|
||||
order.AddItem("A1660", "手机", "iPhone 7", 538800, 2);
|
||||
order.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1);
|
||||
Dictionary<string, object> eventValue = new Dictionary<string, object>
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
TalkingDataSDK.OnPlaceOrder(order, "user01", eventValue);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnOrderPaySucc"))
|
||||
{
|
||||
TalkingDataOrder order = TalkingDataOrder.CreateOrder("order01", 2466400, "CNY");
|
||||
order.AddItem("A1660", "手机", "iPhone 7", 538800, 2);
|
||||
order.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1);
|
||||
TalkingDataSDK.OnOrderPaySucc(order, "AliPay", "user01");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnCancelOrder"))
|
||||
{
|
||||
TalkingDataOrder order = TalkingDataOrder.CreateOrder("order01", 2466400, "CNY");
|
||||
order.AddItem("A1660", "手机", "iPhone 7", 538800, 2);
|
||||
order.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1);
|
||||
TalkingDataSDK.OnCancelOrder(order);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_FINANCE
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnCredit"))
|
||||
{
|
||||
TalkingDataSDK.OnCredit("user01", 123456, "授信详情为......");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnTransaction"))
|
||||
{
|
||||
TalkingDataTransaction transaction = TalkingDataTransaction.CreateTransaction();
|
||||
transaction.SetTransactionId("AdTracking_123456");
|
||||
transaction.SetCategory("定期");
|
||||
transaction.SetAmount(3222);
|
||||
transaction.SetPersonA("张三");
|
||||
transaction.SetPersonB("金融平台");
|
||||
transaction.SetStartDate(1565176907309);
|
||||
transaction.SetEndDate(1565176908309);
|
||||
transaction.SetCurrencyType("CNY");
|
||||
transaction.SetContent("交易详情为......");
|
||||
TalkingDataSDK.OnTransaction("user01", transaction);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_GAME
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnCreateRole"))
|
||||
{
|
||||
TalkingDataSDK.OnCreateRole("role01");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnLevelPass"))
|
||||
{
|
||||
TalkingDataSDK.OnLevelPass("user01", "AdTracking_123456");
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnGuideFinished"))
|
||||
{
|
||||
TalkingDataSDK.OnGuideFinished("user01", "新手教程顺利通过");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_ONLINEEDU
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnLearn"))
|
||||
{
|
||||
TalkingDataSDK.OnLearn("user01", "成人教育第一节", 1501234567890, 20);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnPreviewFinished"))
|
||||
{
|
||||
TalkingDataSDK.OnPreviewFinished("user01", "基础课程试听结束");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_READING
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnRead"))
|
||||
{
|
||||
TalkingDataSDK.OnRead("user01", "西游记第一章", 1501234567890, 20);
|
||||
}
|
||||
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnFreeFinished"))
|
||||
{
|
||||
TalkingDataSDK.OnFreeFinished("user01", "免费章节阅读结束");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_GAME || TD_ONLINEEDU
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnAchievementUnlock"))
|
||||
{
|
||||
TalkingDataSDK.OnAchievementUnlock("user01", "AdTracking_123456");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_FINANCE || TD_TOUR || TD_OTHER
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnBrowse"))
|
||||
{
|
||||
TalkingDataSDK.OnBrowse("user01", "详情页page1", 1501234567890, 20);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_RETAIL || TD_FINANCE || TD_TOUR || TD_OTHER
|
||||
if (GUI.Button(new Rect(left + i % 2 * (width + spacing), top + step * (i++ / 2), width, height), "OnTrialFinished"))
|
||||
{
|
||||
TalkingDataSDK.OnTrialFinished("user01", "试用体验结束");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (GUI.Button(new Rect(left, top + (step * i++), width, height), "OnEvent"))
|
||||
{
|
||||
Dictionary<string, object> dic = new Dictionary<string, object>
|
||||
{
|
||||
{ "StringValue", "Pi" },
|
||||
{ "NumberValue", 3.14 }
|
||||
};
|
||||
Dictionary<string, object> eventValue = new Dictionary<string, object>
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
TalkingDataSDK.OnEvent("action_id", dic, eventValue);
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Debug.Log("Start");
|
||||
// TalkingDataSDK.SetVerboseLogDisable();
|
||||
TalkingDataSDK.BackgroundSessionEnabled();
|
||||
TalkingDataSDK.InitSDK("your_app_id", "your_channel_id", "your_custom_parameter");
|
||||
TalkingDataSDK.StartA();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Escape))
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
Debug.Log("onDestroy");
|
||||
TalkingDataSDK.OnPause();
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Debug.Log("Awake");
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
Debug.Log("OnEnable");
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
Debug.Log("OnDisable");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c5fc6f5d33259f441b91a2c78d802c55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
using UnityEngine;
|
||||
|
||||
|
||||
#if TD_RETAIL
|
||||
public class TalkingDataOrder
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
public AndroidJavaObject javaObj;
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE
|
||||
private string orderId;
|
||||
private int total;
|
||||
private string currencyType;
|
||||
private string items = "";
|
||||
#endif
|
||||
|
||||
public static TalkingDataOrder CreateOrder(string orderId, int total, string currencyType)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
TalkingDataOrder order = new TalkingDataOrder();
|
||||
#if UNITY_ANDROID
|
||||
AndroidJavaClass javaClass = new AndroidJavaClass("com.tendcloud.tenddata.TalkingDataOrder");
|
||||
order.javaObj = javaClass.CallStatic<AndroidJavaObject>("createOrder", orderId, total, currencyType);
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
order.orderId = orderId;
|
||||
order.total = total;
|
||||
order.currencyType = currencyType;
|
||||
#endif
|
||||
return order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TalkingDataOrder AddItem(string itemId, string category, string name, int unitPrice, int amount)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("addItem", itemId, category, name, unitPrice, amount);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
string item = "{\"itemId\":\"" + itemId + "\",\"category\":\"" + category + "\",\"name\":\"" + name + "\",\"unitPrice\":" + unitPrice + ",\"amount\":" + amount + "}";
|
||||
if (items.Length > 0)
|
||||
{
|
||||
items += ",";
|
||||
}
|
||||
items += item;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
#if UNITY_IPHONE
|
||||
public override string ToString()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
string orderStr = "{\"orderId\":\"" + orderId + "\",\"total\":" + total + ",\"currencyType\":\"" + currencyType + "\",\"items\":[" + items + "]}";
|
||||
return orderStr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d570000096a0f1b4cbbe3c8c9279e7ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,468 @@
|
|||
using UnityEngine;
|
||||
|
||||
|
||||
public enum TalkingDataProfileType
|
||||
{
|
||||
ANONYMOUS = 0,
|
||||
REGISTERED = 1,
|
||||
SINA_WEIBO = 2,
|
||||
QQ = 3,
|
||||
QQ_WEIBO = 4,
|
||||
ND91 = 5,
|
||||
WEIXIN = 6,
|
||||
TYPE1 = 11,
|
||||
TYPE2 = 12,
|
||||
TYPE3 = 13,
|
||||
TYPE4 = 14,
|
||||
TYPE5 = 15,
|
||||
TYPE6 = 16,
|
||||
TYPE7 = 17,
|
||||
TYPE8 = 18,
|
||||
TYPE9 = 19,
|
||||
TYPE10 = 20
|
||||
}
|
||||
|
||||
|
||||
public enum TalkingDataGender
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
MALE = 1,
|
||||
FEMALE = 2
|
||||
}
|
||||
|
||||
|
||||
public class TalkingDataProfile
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
public AndroidJavaObject javaObj;
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE
|
||||
private string name;
|
||||
private TalkingDataProfileType type;
|
||||
private TalkingDataGender gender;
|
||||
private int age;
|
||||
private object property1;
|
||||
private object property2;
|
||||
private object property3;
|
||||
private object property4;
|
||||
private object property5;
|
||||
private object property6;
|
||||
private object property7;
|
||||
private object property8;
|
||||
private object property9;
|
||||
private object property10;
|
||||
#endif
|
||||
|
||||
public static TalkingDataProfile CreateProfile()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
TalkingDataProfile profile = new TalkingDataProfile();
|
||||
#if UNITY_ANDROID
|
||||
AndroidJavaClass javaClass = new AndroidJavaClass("com.tendcloud.tenddata.TalkingDataProfile");
|
||||
profile.javaObj = javaClass.CallStatic<AndroidJavaObject>("createProfile");
|
||||
#endif
|
||||
return profile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 账户名称
|
||||
public TalkingDataProfile SetName(string name)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setName", name);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.name = name;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 账户类型
|
||||
public TalkingDataProfile SetType(TalkingDataProfileType type)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaClass enumClass = new AndroidJavaClass("com.tendcloud.tenddata.TalkingDataProfileType");
|
||||
AndroidJavaObject typeObj = enumClass.CallStatic<AndroidJavaObject>("valueOf", type.ToString());
|
||||
javaObj.Call<AndroidJavaObject>("setType", typeObj);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.type = type;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 性别
|
||||
public TalkingDataProfile SetGender(TalkingDataGender gender)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaClass enumClass = new AndroidJavaClass("com.tendcloud.tenddata.TalkingDataGender");
|
||||
AndroidJavaObject genderObj = enumClass.CallStatic<AndroidJavaObject>("valueOf", gender.ToString());
|
||||
javaObj.Call<AndroidJavaObject>("setGender", genderObj);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.gender = gender;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 年龄
|
||||
public TalkingDataProfile SetAge(int age)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setAge", age);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.age = age;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性1
|
||||
public TalkingDataProfile SetProperty1(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty1", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property1 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性2
|
||||
public TalkingDataProfile SetProperty2(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty2", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property2 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性3
|
||||
public TalkingDataProfile SetProperty3(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty3", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property3 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性4
|
||||
public TalkingDataProfile SetProperty4(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty4", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property4 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性5
|
||||
public TalkingDataProfile SetProperty5(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty5", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property5 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性6
|
||||
public TalkingDataProfile SetProperty6(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty6", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property6 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性7
|
||||
public TalkingDataProfile SetProperty7(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty7", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property7 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性8
|
||||
public TalkingDataProfile SetProperty8(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty8", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property8 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性9
|
||||
public TalkingDataProfile SetProperty9(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty9", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property9 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 用户属性10
|
||||
public TalkingDataProfile SetProperty10(object property)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
AndroidJavaObject androidObject = AndroidJavaObjectFromObject(property);
|
||||
javaObj.Call<AndroidJavaObject>("setProperty10", androidObject);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.property10 = property;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
#if UNITY_ANDROID
|
||||
private AndroidJavaObject AndroidJavaObjectFromObject(object parameter)
|
||||
{
|
||||
AndroidJavaObject androidObject = null;
|
||||
if (parameter is string)
|
||||
{
|
||||
androidObject = new AndroidJavaObject("java.lang.String", parameter);
|
||||
}
|
||||
else if (parameter is byte || parameter is sbyte)
|
||||
{
|
||||
androidObject = new AndroidJavaObject("java.lang.Byte", parameter);
|
||||
}
|
||||
else if (parameter is short || parameter is ushort)
|
||||
{
|
||||
androidObject = new AndroidJavaObject("java.lang.Short", parameter);
|
||||
}
|
||||
else if (parameter is int || parameter is uint)
|
||||
{
|
||||
androidObject = new AndroidJavaObject("java.lang.Integer", parameter);
|
||||
}
|
||||
else if (parameter is long || parameter is ulong)
|
||||
{
|
||||
androidObject = new AndroidJavaObject("java.lang.Long", parameter);
|
||||
}
|
||||
else if (parameter is float)
|
||||
{
|
||||
androidObject = new AndroidJavaObject("java.lang.Float", parameter);
|
||||
}
|
||||
else if (parameter is double)
|
||||
{
|
||||
androidObject = new AndroidJavaObject("java.lang.Double", parameter);
|
||||
}
|
||||
return androidObject;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE
|
||||
public override string ToString()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
string profileStr = "{\"name\":\"" + name + "\""
|
||||
+ ",\"type\":" + (int)type
|
||||
+ ",\"gender\":" + (int)gender
|
||||
+ ",\"age\":" + age;
|
||||
if (property1 is string)
|
||||
{
|
||||
profileStr += ",\"property1\":\"" + property1 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property1\":" + property1;
|
||||
}
|
||||
if (property2 is string)
|
||||
{
|
||||
profileStr += ",\"property2\":\"" + property2 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property2\":" + property2;
|
||||
}
|
||||
if (property3 is string)
|
||||
{
|
||||
profileStr += ",\"property3\":\"" + property3 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property3\":" + property3;
|
||||
}
|
||||
if (property4 is string)
|
||||
{
|
||||
profileStr += ",\"property4\":\"" + property4 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property4\":" + property4;
|
||||
}
|
||||
if (property5 is string)
|
||||
{
|
||||
profileStr += ",\"property5\":\"" + property5 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property5\":" + property5;
|
||||
}
|
||||
if (property6 is string)
|
||||
{
|
||||
profileStr += ",\"property6\":\"" + property6 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property6\":" + property6;
|
||||
}
|
||||
if (property7 is string)
|
||||
{
|
||||
profileStr += ",\"property7\":\"" + property7 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property7\":" + property7;
|
||||
}
|
||||
if (property8 is string)
|
||||
{
|
||||
profileStr += ",\"property8\":\"" + property8 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property8\":" + property8;
|
||||
}
|
||||
if (property9 is string)
|
||||
{
|
||||
profileStr += ",\"property9\":\"" + property9 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property9\":" + property9;
|
||||
}
|
||||
if (property10 is string)
|
||||
{
|
||||
profileStr += ",\"property10\":\"" + property10 + "\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
profileStr += ",\"property10\":" + property10;
|
||||
}
|
||||
profileStr += "}";
|
||||
return profileStr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8f405a03062ac254eb62d761adbabb3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f0b8d345f0a7ad145b663cc5f6575322
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
using UnityEngine;
|
||||
|
||||
|
||||
public class TalkingDataSearch
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
public AndroidJavaObject javaObj;
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE
|
||||
private string category;
|
||||
private string content;
|
||||
#if TD_RETAIL
|
||||
private string itemId;
|
||||
private string itemLocationId;
|
||||
#endif
|
||||
#if TD_TOUR
|
||||
private string destination;
|
||||
private string origin;
|
||||
private long startDate;
|
||||
private long endDate;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public static TalkingDataSearch CreateSearch()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
TalkingDataSearch search = new TalkingDataSearch();
|
||||
#if UNITY_ANDROID
|
||||
AndroidJavaClass javaClass = new AndroidJavaClass("com.tendcloud.tenddata.TalkingDataSearch");
|
||||
search.javaObj = javaClass.CallStatic<AndroidJavaObject>("createSearch");
|
||||
#endif
|
||||
return search;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 搜索分类
|
||||
public TalkingDataSearch SetCategory(string category)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setCategory", category);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.category = category;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 搜索内容
|
||||
public TalkingDataSearch SetContent(string content)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setContent", content);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.content = content;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
#if TD_RETAIL
|
||||
// 商品 ID(eg.酒店/汽车);至多64字符,支持数字+字母
|
||||
public TalkingDataSearch SetItemId(string itemId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setItemId", itemId);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.itemId = itemId;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 商品位置 ID(eg.求职招聘/教育行业);至多64字符,支持数字+字母
|
||||
public TalkingDataSearch SetItemLocationId(string itemLocationId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setItemLocationId", itemLocationId);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.itemLocationId = itemLocationId;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TD_TOUR
|
||||
// 目的地城市 ID;至多64字符,支持数字+字母
|
||||
public TalkingDataSearch SetDestination(string destination)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setDestination", destination);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.destination = destination;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 出发地城市 ID;至多64字符,支持数字+字母
|
||||
public TalkingDataSearch SetOrigin(string origin)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setOrigin", origin);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.origin = origin;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 业务事件起始日期(eg.航班出发日期)
|
||||
public TalkingDataSearch SetStartDate(long startDate)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setStartDate", startDate);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.startDate = startDate;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 业务事件截止日期(eg.航班返程日期)
|
||||
public TalkingDataSearch SetEndDate(long endDate)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setEndDate", endDate);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.endDate = endDate;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE
|
||||
public override string ToString()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
string searchStr = "{\"category\":\"" + category + "\""
|
||||
+ ",\"content\":\"" + content + "\""
|
||||
#if TD_RETAIL
|
||||
+ ",\"itemId\":\"" + itemId + "\""
|
||||
+ ",\"itemLocationId\":\"" + itemLocationId + "\""
|
||||
#endif
|
||||
#if TD_TOUR
|
||||
+ ",\"destination\":\"" + destination + "\""
|
||||
+ ",\"origin\":\"" + origin + "\""
|
||||
+ ",\"startDate\":" + startDate
|
||||
+ ",\"endDate\":" + endDate
|
||||
#endif
|
||||
+ "}";
|
||||
return searchStr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 17e052589da770648ad94c32e8aad082
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
using UnityEngine;
|
||||
|
||||
|
||||
#if TD_RETAIL
|
||||
public class TalkingDataShoppingCart
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
public AndroidJavaObject javaObj;
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE
|
||||
private string items = "";
|
||||
#endif
|
||||
|
||||
public static TalkingDataShoppingCart CreateShoppingCart()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
TalkingDataShoppingCart shoppingCart = new TalkingDataShoppingCart();
|
||||
#if UNITY_ANDROID
|
||||
AndroidJavaClass javaClass = new AndroidJavaClass("com.tendcloud.tenddata.TalkingDataShoppingCart");
|
||||
shoppingCart.javaObj = javaClass.CallStatic<AndroidJavaObject>("createShoppingCart");
|
||||
#endif
|
||||
return shoppingCart;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TalkingDataShoppingCart AddItem(string itemId, string category, string name, int unitPrice, int amount)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("addItem", itemId, category, name, unitPrice, amount);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
string item = "{\"itemId\":\"" + itemId + "\",\"category\":\"" + category + "\",\"name\":\"" + name + "\",\"unitPrice\":" + unitPrice + ",\"amount\":" + amount + "}";
|
||||
if (items.Length > 0)
|
||||
{
|
||||
items += ",";
|
||||
}
|
||||
items += item;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
#if UNITY_IPHONE
|
||||
public override string ToString()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
string orderStr = "{\"items\":[" + items + "]}";
|
||||
return orderStr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5dd91e2a34d9e0e4c8cbc920a4cb662b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
using UnityEngine;
|
||||
|
||||
|
||||
#if TD_FINANCE
|
||||
public class TalkingDataTransaction
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
public AndroidJavaObject javaObj;
|
||||
#endif
|
||||
|
||||
#if UNITY_IPHONE
|
||||
private string transactionId;
|
||||
private string category;
|
||||
private int amount;
|
||||
private string personA;
|
||||
private string personB;
|
||||
private long startDate;
|
||||
private long endDate;
|
||||
private string currencyType;
|
||||
private string content;
|
||||
#endif
|
||||
|
||||
public static TalkingDataTransaction CreateTransaction()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
TalkingDataTransaction transaction = new TalkingDataTransaction();
|
||||
#if UNITY_ANDROID
|
||||
AndroidJavaClass javaClass = new AndroidJavaClass("com.tendcloud.tenddata.TalkingDataTransaction");
|
||||
transaction.javaObj = javaClass.CallStatic<AndroidJavaObject>("createTransaction");
|
||||
#endif
|
||||
return transaction;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 交易ID
|
||||
public TalkingDataTransaction SetTransactionId(string transactionId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setTransactionId", transactionId);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.transactionId = transactionId;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 交易分类
|
||||
public TalkingDataTransaction SetCategory(string category)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setCategory", category);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.category = category;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 交易额
|
||||
public TalkingDataTransaction SetAmount(int amount)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setAmount", amount);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.amount = amount;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 交易甲方
|
||||
public TalkingDataTransaction SetPersonA(string personA)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setPersonA", personA);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.personA = personA;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 交易乙方
|
||||
public TalkingDataTransaction SetPersonB(string personB)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setPersonB", personB);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.personB = personB;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 交易起始Unix时间戳。单位:毫秒
|
||||
public TalkingDataTransaction SetStartDate(long startDate)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setStartDate", startDate);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.startDate = startDate;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 交易终止Unix时间戳。单位:毫秒
|
||||
public TalkingDataTransaction SetEndDate(long endDate)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setEndDate", endDate);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.endDate = endDate;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 货币类型
|
||||
public TalkingDataTransaction SetCurrencyType(string currencyType)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setCurrencyType", currencyType);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.currencyType = currencyType;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// 交易详情
|
||||
public TalkingDataTransaction SetContent(string content)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (javaObj != null)
|
||||
{
|
||||
javaObj.Call<AndroidJavaObject>("setContent", content);
|
||||
}
|
||||
#endif
|
||||
#if UNITY_IPHONE
|
||||
this.content = content;
|
||||
#endif
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
#if UNITY_IPHONE
|
||||
public override string ToString()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
string transactionStr = "{\"transactionId\":\"" + transactionId + "\""
|
||||
+ ",\"category\":\"" + category + "\""
|
||||
+ ",\"amount\":" + amount
|
||||
+ ",\"personA\":\"" + personA + "\""
|
||||
+ ",\"personB\":\"" + personB + "\""
|
||||
+ ",\"startDate\":" + startDate
|
||||
+ ",\"endDate\":" + endDate
|
||||
+ ",\"currencyType\":\"" + currencyType + "\""
|
||||
+ ",\"content\":\"" + content + "\""
|
||||
+ "}";
|
||||
return transactionStr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e1813c990270a1e4899a5b78daa665c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,372 @@
|
|||
#if SDK_TALKINGDATA
|
||||
using PhxhSDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
#region 常量名称
|
||||
/// <summary>
|
||||
/// 专属事件名
|
||||
/// </summary>
|
||||
public class TalkingDataEventName
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户注册
|
||||
/// </summary>
|
||||
public const string Register = "Register";
|
||||
/// <summary>
|
||||
/// 用户登录
|
||||
/// </summary>
|
||||
public const string Login = "Login";
|
||||
/// <summary>
|
||||
/// 创建角色
|
||||
/// </summary>
|
||||
public const string CreateRole = "CreateRole";
|
||||
/// <summary>
|
||||
/// 完成关卡
|
||||
/// </summary>
|
||||
public const string LevelPass = "LevelPass";
|
||||
/// <summary>
|
||||
/// 完成教程
|
||||
/// </summary>
|
||||
public const string GuideFinish = "GuideFinish";
|
||||
/// <summary>
|
||||
/// 获得成就
|
||||
/// </summary>
|
||||
public const string Achievement = "Achievement";
|
||||
}
|
||||
public class TalkingDataProfileParamName
|
||||
{
|
||||
public const string Name = "name";
|
||||
public const string Type = "type";
|
||||
public const string Gender = "gender";
|
||||
public const string Age = "age";
|
||||
public const string Param1 = "param1";
|
||||
public const string Param2 = "param2";
|
||||
public const string Param3 = "param3";
|
||||
public const string Param4 = "param4";
|
||||
public const string Param5 = "param5";
|
||||
public const string Param6 = "param6";
|
||||
public const string Param7 = "param7";
|
||||
public const string Param8 = "param8";
|
||||
public const string Param9 = "param9";
|
||||
public const string Param10 = "param10";
|
||||
}
|
||||
#endregion
|
||||
|
||||
public partial class TalkingDataSdkHelper : IBIService
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户账户属性
|
||||
/// </summary>
|
||||
static TalkingDataProfile profile;
|
||||
|
||||
/// <summary>
|
||||
/// 专属事件上报映射表
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, Action<Dictionary<string, object>>> ReportEventMap = new Dictionary<string, Action<Dictionary<string, object>>>()
|
||||
{
|
||||
{ TalkingDataEventName.Register, OnRegister },
|
||||
{ TalkingDataEventName.Login, OnLogin },
|
||||
{ TalkingDataEventName.CreateRole, OnCreateRole },
|
||||
{ TalkingDataEventName.LevelPass, OnLevelPass },
|
||||
{ TalkingDataEventName.GuideFinish, OnGuideFinish },
|
||||
{ TalkingDataEventName.Achievement, OnAchievement },
|
||||
};
|
||||
#region ReportAction
|
||||
static void OnSignin(Dictionary<string, object> param)//need "Ad Tracking" Service
|
||||
{
|
||||
param.TryGetValue("profileID", out object profileID);//账号ID,非必选
|
||||
param.TryGetValue("punchID", out object punchID);//签到ID,非必选
|
||||
TalkingDataSDK.OnPunch(profileID as string, punchID as string);
|
||||
}
|
||||
static void OnPay(Dictionary<string, object> param)//need "Ad Tracking" Service
|
||||
{
|
||||
param.TryGetValue("profileID", out object profileID);//账号ID,非必选
|
||||
|
||||
//订单ID,必选!!!
|
||||
//全局唯一,由开发者提供并维护(此ID很重要,如果不清楚可咨询客服)
|
||||
//用于唯一标识一次交易,以及后期系统之间对账使用。
|
||||
//如果多次充值成功的orderId重复,将只计算首次成功的数据,其他数据会认为重复数据丢弃
|
||||
if (!param.TryGetValue("orderID", out object orderID))
|
||||
{
|
||||
DebugUtil.LogError("TalkingDataSdkHelper OnPay orderID not found");
|
||||
return;
|
||||
}
|
||||
|
||||
//订单金额(int),必选!!!
|
||||
//单位为所选货币的最小单位
|
||||
//例如:600分或100美分,币种以currencyType为标准
|
||||
if (!param.TryGetValue("amount", out object amount))
|
||||
{
|
||||
DebugUtil.LogError("TalkingDataSdkHelper OnPay amount not found");
|
||||
return;
|
||||
}
|
||||
|
||||
//货币类型,必选!!!
|
||||
//请使用国际标准组织ISO 4217中规范的3位字母代码标记货币类型
|
||||
//支持类型:CNY, HKD, TWD, USD, EUR, GBP, JPY
|
||||
if (!param.TryGetValue("currencyType", out object currencyType))
|
||||
{
|
||||
DebugUtil.LogError("TalkingDataSdkHelper OnPay currencyType not found");
|
||||
return;
|
||||
}
|
||||
|
||||
//支付类型,非必选
|
||||
//支付类型,支持中文、英文、数字、符号
|
||||
//例如:ApplePay、支付宝、Alipay、微信等
|
||||
param.TryGetValue("paymentType", out object paymentType);
|
||||
|
||||
param.TryGetValue("itemId", out object itemId);//商品ID,非必选
|
||||
|
||||
param.TryGetValue("itemCount", out object itemCount);//商品数量(int),非必选
|
||||
|
||||
try
|
||||
{
|
||||
TalkingDataSDK.OnPay(profileID as string, (string)orderID, (int)amount, (string)currencyType, paymentType as string, itemId as string, (int)itemCount);
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugUtil.LogError("TalkingDataSdkHelper OnPay param error!!!");
|
||||
}
|
||||
}
|
||||
static void OnRegister(Dictionary<string, object> param)
|
||||
{
|
||||
//账号ID,必选
|
||||
string profileID = SDKManager.Instance.ApplicationUserID;
|
||||
if (profile == null)
|
||||
profile = TalkingDataProfile.CreateProfile();
|
||||
try
|
||||
{
|
||||
TalkingDataSDK.OnRegister((string)profileID, profile, null, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugUtil.LogError("TalkingDataSdkHelper OnRegister param error!!!");
|
||||
}
|
||||
}
|
||||
static void OnLogin(Dictionary<string, object> param)
|
||||
{
|
||||
string profileID = SDKManager.Instance.ApplicationUserID;
|
||||
if (profile == null)
|
||||
profile = TalkingDataProfile.CreateProfile();
|
||||
try
|
||||
{
|
||||
TalkingDataSDK.OnLogin(profileID, profile, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugUtil.LogError("TalkingDataSdkHelper OnLogin param error!!!");
|
||||
}
|
||||
}
|
||||
|
||||
static void OnCreateRole(Dictionary<string, object> param)
|
||||
{
|
||||
param.TryGetValue("param1", out object name);//角色名称,非必选
|
||||
|
||||
TalkingDataSDK.OnCreateRole(name as string);
|
||||
}
|
||||
static void OnLevelPass(Dictionary<string, object> param)
|
||||
{
|
||||
//账号ID,非必选
|
||||
string profileID = SDKManager.Instance.ApplicationUserID;
|
||||
|
||||
param.TryGetValue("param1", out object levelID);//关卡ID,非必选
|
||||
|
||||
TalkingDataSDK.OnLevelPass(profileID as string, levelID as string);
|
||||
}
|
||||
static void OnGuideFinish(Dictionary<string, object> param)
|
||||
{
|
||||
//账号ID,非必选
|
||||
string profileID = SDKManager.Instance.ApplicationUserID;
|
||||
|
||||
param.TryGetValue("param1", out object content);//教程内容,非必选
|
||||
|
||||
TalkingDataSDK.OnGuideFinished(profileID as string, content as string);
|
||||
}
|
||||
static void OnAchievement(Dictionary<string, object> param)
|
||||
{
|
||||
//账号ID,非必选
|
||||
string profileID = SDKManager.Instance.ApplicationUserID;
|
||||
|
||||
param.TryGetValue("param1", out object achievementID);//成就ID,非必选
|
||||
|
||||
TalkingDataSDK.OnAchievementUnlock(profileID as string, achievementID as string);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public void ClearUser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ReportEvent(string eventName, Dictionary<string, object> param = null)
|
||||
{
|
||||
if (ReportEventMap.ContainsKey(eventName))//专属事件
|
||||
{
|
||||
DebugUtil.Log("TalkingDataSdkHelper send report event: {0}", eventName);
|
||||
ReportEventMap[eventName]?.Invoke(param);
|
||||
}
|
||||
else
|
||||
{
|
||||
string paramStr = string.Empty;
|
||||
if (param != null)
|
||||
{
|
||||
foreach (var item in param)
|
||||
{
|
||||
paramStr += "\n" + item.Key + ":" + item.Value + ";";
|
||||
}
|
||||
}
|
||||
if (paramStr.Length == 0)
|
||||
{
|
||||
paramStr = " NULL ";
|
||||
}
|
||||
DebugUtil.Log("自定义事件打点:" + eventName + "\n参数内容详情:" + paramStr);
|
||||
if(param == null)
|
||||
{
|
||||
param = new Dictionary<string, object>();
|
||||
}
|
||||
var now = DateTime.Now;
|
||||
var nextHour = now.AddHours(1);
|
||||
|
||||
var keys = param.Keys.ToList();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
if (!_IsLegalType(param[key]))
|
||||
{
|
||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(param[key]);
|
||||
param[key] = json;
|
||||
}
|
||||
}
|
||||
|
||||
if (param.ContainsKey("timePeriod"))
|
||||
{
|
||||
param["timePeriod"] = $"{now.Hour}-{nextHour.Hour}";
|
||||
}
|
||||
else
|
||||
{
|
||||
param.Add("timePeriod", $"{now.Hour}-{nextHour.Hour}");
|
||||
}
|
||||
TalkingDataSDK.OnEvent(eventName, param, null);
|
||||
}
|
||||
//传入自定义事件,
|
||||
//参数仅支持string和number类型,每个事件下最多自动识别50个参数key(Android v2.2.15及以下、iOS v2.2.27及以下版本仅同时支持10对参数)。
|
||||
//如果同一代码事件因不同版本等原因上传了不同key,报表最多可以显示100个key。
|
||||
//每个key最多支持1000个以内的不同value。超过1000个value,将不在做计次运算,如果需要获取value明细值,可以前往日志导出获取。
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否是支持的参数类型
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private bool _IsLegalType(object value)
|
||||
{
|
||||
bool ret = false;
|
||||
switch (Type.GetTypeCode(value.GetType()))
|
||||
{
|
||||
case TypeCode.String:
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.SByte:
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.UInt16:
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt64:
|
||||
case TypeCode.Single:
|
||||
case TypeCode.Double:
|
||||
case TypeCode.Decimal:
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void SetUser(string userId)
|
||||
{
|
||||
if (userId == null)
|
||||
{
|
||||
DebugUtil.Log("TalkingDataSdkHelper SetUser userId is null");
|
||||
return;
|
||||
}
|
||||
if (profile == null)
|
||||
profile = TalkingDataProfile.CreateProfile();
|
||||
profile?.SetName(userId);
|
||||
TalkingDataSDK.OnLogin(userId, profile, null);
|
||||
DebugUtil.Log("TalkingDataSdkHelper SetUser userId = {0}", userId);
|
||||
}
|
||||
|
||||
public void SetUserProperty(string name, string value)
|
||||
{
|
||||
DebugUtil.Log("TalkingDataSdkHelper SetUserProperty name = {0}, value = {1}", name, value);
|
||||
if (profile == null)
|
||||
profile = TalkingDataProfile.CreateProfile();
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case TalkingDataProfileParamName.Name:
|
||||
profile?.SetName(value);
|
||||
break;
|
||||
//case TalkingDataProfileParamName.Type:
|
||||
// profile?.SetType(TalkingDataProfileType.);
|
||||
// break;
|
||||
case TalkingDataProfileParamName.Age:
|
||||
profile?.SetAge(int.Parse(value));
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param1://string or int
|
||||
profile?.SetProperty1(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param2://string or int
|
||||
profile?.SetProperty2(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param3://string or int
|
||||
profile?.SetProperty3(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param4://string or int
|
||||
profile?.SetProperty4(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param5://string or int
|
||||
profile?.SetProperty5(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param6://string or int
|
||||
profile?.SetProperty6(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param7://string or int
|
||||
profile?.SetProperty7(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param8://string or int
|
||||
profile?.SetProperty8(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param9://string or int
|
||||
profile?.SetProperty9(value);
|
||||
break;
|
||||
case TalkingDataProfileParamName.Param10://string or int
|
||||
profile?.SetProperty10(value);
|
||||
break;
|
||||
default:
|
||||
DebugUtil.Log("无法修改这一项用户属性:{0},这个操作已被忽略", name);
|
||||
return;
|
||||
}
|
||||
TalkingDataSDK.OnProfileUpdate(profile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 必须与OnPageClose成对调用,用于记录页面访问次数以及停留时长
|
||||
/// </summary>
|
||||
/// <param name="pageName"></param>
|
||||
public void OnPageOpen(string pageName)
|
||||
{
|
||||
TalkingDataSDK.OnPageBegin(string.IsNullOrEmpty(pageName) ? "default" : pageName);
|
||||
}
|
||||
/// <summary>
|
||||
/// 必须与OnPageOpen成对调用,用于记录页面访问次数以及停留时长
|
||||
/// </summary>
|
||||
/// <param name="pageName"></param>
|
||||
public void OnPageClose(string pageName)
|
||||
{
|
||||
TalkingDataSDK.OnPageEnd(string.IsNullOrEmpty(pageName) ? "default" : pageName);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 472530e61ac2dd24fa8e8943b85ff025
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
#if SDK_TALKINGDATA
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using PhxhSDK;
|
||||
using Assets.PhxhSDK.AOT.BI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
|
||||
public partial class TalkingDataSdkHelper : SdkHelper
|
||||
{
|
||||
bool isInit = false;
|
||||
|
||||
public override void AfterLoginInit()
|
||||
{
|
||||
}
|
||||
|
||||
public override void EarlyInit()
|
||||
{
|
||||
//TD 初始化已移动到AOT部分
|
||||
//TalkingDataSDK.BackgroundSessionEnabled();
|
||||
//#if UNITY_IPHONE
|
||||
// platform = "AppStore";
|
||||
//#else
|
||||
// platform = channel;
|
||||
//#endif
|
||||
// TalkingDataSDK.Init(appId, platform, "your_custom_parameter");
|
||||
#if !UNITY_EDITOR
|
||||
if (!BIToolinAOT.Instance.IsInit)
|
||||
{
|
||||
DebugUtil.LogError("TalkingDataSdkHelper NOT INIT!!!");
|
||||
//TalkingDataSDK.BackgroundSessionEnabled();
|
||||
//TalkingDataSDK.Init(talkingdat)
|
||||
//TalkingDataSDK.Init(TalkingDataInitTool.appID, TalkingDataInitTool.channel, "your_custom_parameter");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Release()
|
||||
{
|
||||
//throw new System.NotImplementedException();
|
||||
TalkingDataSDK.OnPause();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 45b38e1cf28d1d3468aa14ec1d703746
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using PhxhSDK;
|
||||
using Sirenix.OdinInspector;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
[CreateAssetMenu(fileName = "TalkingDataSettings", menuName = "BISettings/TalkingDataSettings")]
|
||||
public class TalkingDataSettings : ScriptableObject
|
||||
{
|
||||
public string appId;
|
||||
|
||||
[LabelText("应用渠道")]
|
||||
public string channel = "test";//taptap
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fb5ecaf122efe6940a9af343df1fadaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Tool/sdk_packages/TalkingData/0.0.1/Assets/PhxhSDK/ThirdParty/TalkingData/Plugins.meta
vendored
Normal file
8
Tool/sdk_packages/TalkingData/0.0.1/Assets/PhxhSDK/ThirdParty/TalkingData/Plugins.meta
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 19e4dbea2284739499a4c9ad1c2de03e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ee65f5205a466f74682efbf92cce982c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.unity3d.player"
|
||||
android:installLocation="preferExternal"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<supports-screens
|
||||
android:smallScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:xlargeScreens="true"
|
||||
android:anyDensity="true"/>
|
||||
<application
|
||||
android:icon="@drawable/app_icon"
|
||||
android:label="@string/app_name"
|
||||
android:debuggable="true">
|
||||
<activity
|
||||
android:name="com.unity3d.player.UnityPlayerActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
|
||||
<meta-data android:name="android.app.lib_name" android:value="unity"/>
|
||||
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false"/>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f08cb7790eb54c84f873b1cfe361397b
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4cfda361e3d62b343ae975e4eaa9c14a
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Tool/sdk_packages/TalkingData/0.0.1/Assets/PhxhSDK/ThirdParty/TalkingData/Plugins/iOS.meta
vendored
Normal file
8
Tool/sdk_packages/TalkingData/0.0.1/Assets/PhxhSDK/ThirdParty/TalkingData/Plugins/iOS.meta
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 331d08408b8a3404fba8977e9b50617c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,365 @@
|
|||
//
|
||||
// TalkingDataSDK.h
|
||||
// TalkingData
|
||||
//
|
||||
// Created by liweiqiang on 21-03-16.
|
||||
// Copyright (c) 2021年 TendCloud. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, TalkingDataDisable) {
|
||||
TalkingDataDisablePreciseArea = 1 << 0,
|
||||
TalkingDataDisableAnalyticsIntellignet = 1 << 1,
|
||||
TalkingDataDisableDeviceIdentification = 1 << 2,
|
||||
TalkingDataDisableAntiCheating = 1 << 3,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TalkingDataVendorIdType) {
|
||||
TalkingDataVendorIdTypeZX = 1, // 卓信
|
||||
TalkingDataVendorIdTypeGX = 2, // 广协
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, TalkingDataSharingFilter) {
|
||||
TalkingDataSharingFilterShare = 0, // 可共享
|
||||
TalkingDataSharingFilterOnlyInstall = 1, // 仅共享Install事件
|
||||
TalkingDataSharingFilterUnshare = 2, // 不可共享
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TalkingDataProfileType) {
|
||||
TalkingDataProfileTypeAnonymous = 0, // 匿名账户
|
||||
TalkingDataProfileTypeRegistered = 1, // 显性注册账户
|
||||
TalkingDataProfileTypeSinaWeibo = 2, // 新浪微博
|
||||
TalkingDataProfileTypeQQ = 3, // QQ账户
|
||||
TalkingDataProfileTypeQQWeibo = 4, // 腾讯微博
|
||||
TalkingDataProfileTypeND91 = 5, // 91账户
|
||||
TalkingDataProfileTypeWeiXin = 6, // 微信
|
||||
TalkingDataProfileTypeType1 = 11, // 自定义类型1
|
||||
TalkingDataProfileTypeType2 = 12, // 自定义类型2
|
||||
TalkingDataProfileTypeType3 = 13, // 自定义类型3
|
||||
TalkingDataProfileTypeType4 = 14, // 自定义类型4
|
||||
TalkingDataProfileTypeType5 = 15, // 自定义类型5
|
||||
TalkingDataProfileTypeType6 = 16, // 自定义类型6
|
||||
TalkingDataProfileTypeType7 = 17, // 自定义类型7
|
||||
TalkingDataProfileTypeType8 = 18, // 自定义类型8
|
||||
TalkingDataProfileTypeType9 = 19, // 自定义类型9
|
||||
TalkingDataProfileTypeType10 = 20, // 自定义类型10
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TalkingDataGender) {
|
||||
TalkingDataGenderUnknown = 0, // 未知
|
||||
TalkingDataGenderMale = 1, // 男
|
||||
TalkingDataGenderFemale = 2, // 女
|
||||
};
|
||||
|
||||
|
||||
@interface TalkingDataProfile : NSObject
|
||||
|
||||
+ (TalkingDataProfile *)createProfile;
|
||||
|
||||
// 账户名称
|
||||
@property (nonatomic, strong) NSString *name;
|
||||
// 账户类型
|
||||
@property (nonatomic, assign) TalkingDataProfileType type;
|
||||
// 用户性别
|
||||
@property (nonatomic, assign) TalkingDataGender gender;
|
||||
// 用户年龄
|
||||
@property (nonatomic, assign) int age;
|
||||
|
||||
// 自定义属性1-10,类型为NSString或NSNumber
|
||||
@property (nonatomic, strong) id property1;
|
||||
@property (nonatomic, strong) id property2;
|
||||
@property (nonatomic, strong) id property3;
|
||||
@property (nonatomic, strong) id property4;
|
||||
@property (nonatomic, strong) id property5;
|
||||
@property (nonatomic, strong) id property6;
|
||||
@property (nonatomic, strong) id property7;
|
||||
@property (nonatomic, strong) id property8;
|
||||
@property (nonatomic, strong) id property9;
|
||||
@property (nonatomic, strong) id property10;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TalkingDataSearch : NSObject
|
||||
|
||||
+ (TalkingDataSearch *)createSearch;
|
||||
|
||||
// 搜索类别
|
||||
@property (nonatomic, strong) NSString *category;
|
||||
// 搜索内容
|
||||
@property (nonatomic, strong) NSString *content;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@interface TalkingDataSDK : NSObject
|
||||
|
||||
/**
|
||||
* 获取TalkingData分配的设备ID
|
||||
* @return deviceId 设备的ID
|
||||
*/
|
||||
+ (NSString *)getDeviceId;
|
||||
|
||||
/**
|
||||
* 设置不显示日志。如发布时不需显示日志,应当最先调用该接口。
|
||||
*/
|
||||
+ (void)setVerboseLogDisable;
|
||||
|
||||
/**
|
||||
* 设置关闭配置
|
||||
*/
|
||||
+ (void)setConfigurationDisable:(TalkingDataDisable)options;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 开启后台使用时长统计,需在SDK初始化之前调用。
|
||||
*/
|
||||
+ (void)backgroundSessionEnabled;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
/**
|
||||
* 用于精准的追踪以Safari作为资源载体的广告来源,如果需要使用应当在init接口之前调用。
|
||||
*/
|
||||
+ (void)enableSFSafariViewControllerTracking API_DEPRECATED("此接口会影响到用户交互,使用前请确保和产品、业务沟通清楚!", ios(1, 1));
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 此接口已废弃,请调用'initSDK'和'startA'接口,详细说明请见官网集成文档。
|
||||
*/
|
||||
+ (void)init:(NSString *)appId channelId:(NSString *)channelId custom:(NSString *)custom NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* SDK初始化接口,仅会执行SDK初始化,不会进行任何信息采集。
|
||||
* 请在application:didFinishLaunchingWithOptions:中调用
|
||||
* @param appId 应用的唯一标识,统计后台注册得到
|
||||
* @param channelId 渠道名(可选)。如“AppStore”
|
||||
* @param custom 自定义参数(可选)。
|
||||
*/
|
||||
+ (void)initSDK:(NSString *)appId channelId:(NSString *)channelId custom:(NSString *)custom;
|
||||
|
||||
/**
|
||||
* SDK启动分析,基础数据准备。
|
||||
*/
|
||||
+ (void)startA;
|
||||
|
||||
/**
|
||||
* 设置第三方的ID
|
||||
* @param vendorId 第三方的ID
|
||||
* @param type ID的提供方
|
||||
*/
|
||||
+ (void)setVendorId:(NSString *)vendorId ofType:(TalkingDataVendorIdType)type;
|
||||
|
||||
/**
|
||||
* 设置位置信息
|
||||
* @param latitude 纬度
|
||||
* @param longitude 经度
|
||||
*/
|
||||
+ (void)setLatitude:(double)latitude longitude:(double)longitude;
|
||||
|
||||
/**
|
||||
* 设置自定义数据是否可共享
|
||||
* @param flag 是否可共享
|
||||
*/
|
||||
+ (void)setCustomDataSwitch:(TalkingDataSharingFilter)flag;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
/**
|
||||
* 是否捕捉程序崩溃记录
|
||||
* 如果需要记录程序崩溃日志,请将值设成YES,并且在初始化后尽早调用
|
||||
* @param enable 默认NO
|
||||
*/
|
||||
+ (void)setExceptionReportEnabled:(BOOL)enable;
|
||||
|
||||
/**
|
||||
* 是否捕捉异常信号
|
||||
* 如果需要开启异常信号捕捉功能,请将值设成YES,并且在初始化后尽早调用
|
||||
* @param enable 默认NO
|
||||
*/
|
||||
+ (void)setSignalReportEnabled:(BOOL)enable;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 开始跟踪某一页面,记录页面打开时间
|
||||
* 建议在viewWillAppear或者viewDidAppear中调用
|
||||
* @param pageName 页面名称
|
||||
*/
|
||||
+ (void)onPageBegin:(NSString *)pageName;
|
||||
|
||||
/**
|
||||
* 结束某一页面的跟踪,记录页面的关闭时间
|
||||
* 此接口与onPageBegin接口结对使用
|
||||
* 建议在viewWillDisappear或者viewDidDisappear中调用
|
||||
* @param pageName 页面名称,请跟onPageBegin接口的页面名称保持一致
|
||||
*/
|
||||
+ (void)onPageEnd:(NSString *)pageName;
|
||||
|
||||
/**
|
||||
* 获取短链
|
||||
* @param params 生成短链所参数
|
||||
* @param callback 返回结果
|
||||
*/
|
||||
+ (void)getShortUrl:(NSDictionary *)params callback:(void (^)(NSString *shortUrl))callback;
|
||||
|
||||
|
||||
/**
|
||||
* 处理UniversalLink
|
||||
* @param userActivity 获取到的NSUserActivity对象
|
||||
* @return deeplink 深度链接
|
||||
*/
|
||||
+ (NSString *)handleUniversalLink:(NSUserActivity *)userActivity;
|
||||
|
||||
/**
|
||||
* 唤醒事件
|
||||
* @param link 唤醒链接
|
||||
*/
|
||||
+ (void)onReceiveDeepLink:(NSURL *)link;
|
||||
|
||||
/**
|
||||
* 注册
|
||||
* @param profileId 账户ID
|
||||
* @param profile 账户属性
|
||||
* @param invitationCode 邀请码
|
||||
* @param eventValue 用户自定义事件参数
|
||||
*/
|
||||
+ (void)onRegister:(NSString *)profileId profile:(TalkingDataProfile *)profile invitationCode:(NSString *)invitationCode eventValue:(NSDictionary *)eventValue;
|
||||
+ (void)onRegister:(NSString *)profileId profile:(TalkingDataProfile *)profile invitationCode:(NSString *)invitationCode;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param profileId 账户ID
|
||||
* @param profile 账户属性
|
||||
* @param eventValue 用户自定义事件参数
|
||||
*/
|
||||
+ (void)onLogin:(NSString *)profileId profile:(TalkingDataProfile *)profile eventValue:(NSDictionary *)eventValue;
|
||||
+ (void)onLogin:(NSString *)profileId profile:(TalkingDataProfile *)profile;
|
||||
|
||||
/**
|
||||
* 更新账户信息
|
||||
* @param profile 账户属性
|
||||
*/
|
||||
+ (void)onProfileUpdate:(TalkingDataProfile *)profile;
|
||||
|
||||
/**
|
||||
* 添加支付信息
|
||||
* @param profileId 账户ID
|
||||
* @param method 支付方式
|
||||
* @param content 支付信息
|
||||
*/
|
||||
+ (void)onCreateCard:(NSString *)profileId method:(NSString *)method content:(NSString *)content;
|
||||
|
||||
/**
|
||||
* 收藏
|
||||
* @param category 收藏类别
|
||||
* @param content 收藏内容
|
||||
* @param eventValue 用户自定义事件参数
|
||||
*/
|
||||
+ (void)onFavorite:(NSString *)category content:(NSString *)content eventValue:(NSDictionary *)eventValue;
|
||||
+ (void)onFavorite:(NSString *)category content:(NSString *)content;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
* @param profileId 账户ID
|
||||
* @param content 分享内容
|
||||
* @param eventValue 用户自定义事件参数
|
||||
*/
|
||||
+ (void)onShare:(NSString *)profileId content:(NSString *)content eventValue:(NSDictionary *)eventValue;
|
||||
+ (void)onShare:(NSString *)profileId content:(NSString *)content;
|
||||
|
||||
/**
|
||||
* 签到打卡
|
||||
* @param profileId 账户ID
|
||||
* @param punchId 签到打卡ID
|
||||
*/
|
||||
+ (void)onPunch:(NSString *)profileId punchId:(NSString *)punchId;
|
||||
|
||||
/**
|
||||
* 搜索事件
|
||||
* @param search 搜索信息详情
|
||||
*/
|
||||
+ (void)onSearch:(TalkingDataSearch *)search;
|
||||
|
||||
|
||||
/**
|
||||
* 付费
|
||||
* @param profileId 账户ID
|
||||
* @param orderId 订单ID
|
||||
* @param amount 订单金额
|
||||
* @param currencyType 货币类型
|
||||
* @param paymentType 支付类型
|
||||
* @param itemId 商品ID
|
||||
* @param itemCount 商品个数
|
||||
*/
|
||||
+ (void)onPay:(NSString *)profileId orderId:(NSString *)orderId amount:(int)amount currencyType:(NSString *)currencyType paymentType:(NSString *)paymentType itemId:(NSString *)itemId itemCount:(int)itemCount;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建角色
|
||||
* @param name 角色名称
|
||||
*/
|
||||
+ (void)onCreateRole:(NSString *)name;
|
||||
|
||||
/**
|
||||
* 通过关卡
|
||||
* @param profileId 账户ID
|
||||
* @param levelId 关卡ID
|
||||
*/
|
||||
+ (void)onLevelPass:(NSString *)profileId levelId:(NSString *)levelId;
|
||||
|
||||
/**
|
||||
* 完成新手教程
|
||||
* @param profileId 账户ID
|
||||
* @param content 教程信息
|
||||
*/
|
||||
+ (void)onGuideFinished:(NSString *)profileId content:(NSString *)content;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 解锁成就
|
||||
* @param profileId 账户ID
|
||||
* @param achievementId 成就ID
|
||||
*/
|
||||
+ (void)onAchievementUnlock:(NSString *)profileId achievementId:(NSString *)achievementId;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 自定义事件
|
||||
* @param eventId 事件名称
|
||||
* @param parameters 事件参数 (key只支持NSString, value支持NSString和NSNumber)
|
||||
* @param eventValue 用户自定义事件参数
|
||||
*/
|
||||
+ (void)onEvent:(NSString *)eventId parameters:(NSDictionary *)parameters eventValue:(NSDictionary *)eventValue;
|
||||
+ (void)onEvent:(NSString *)eventId parameters:(NSDictionary *)parameters;
|
||||
+ (void)onEvent:(NSString *)eventId value:(double)eventValue parameters:(NSDictionary *)parameters API_DEPRECATED_WITH_REPLACEMENT("onEvent:parameters", ios(1,1));
|
||||
|
||||
/**
|
||||
* 添加自定义事件全局参数
|
||||
* @param key 参数的key
|
||||
* @param value 参数的value,NSString或NSNumber类型
|
||||
*/
|
||||
+ (void)setGlobalKV:(NSString *)key value:(id)value;
|
||||
|
||||
/**
|
||||
* 删除自定义事件全局参数
|
||||
* @param key 参数的key
|
||||
*/
|
||||
+ (void)removeGlobalKV:(NSString *)key;
|
||||
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cea468a925cabc34eb7c255e78ca8f22
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AndroidSharedLibraryType: Executable
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,465 @@
|
|||
#import "TalkingDataSDK.h"
|
||||
|
||||
// #define TD_RETAIL // 电商零售
|
||||
#define TD_GAME // 游戏娱乐
|
||||
// #define TD_FINANCE // 金融借贷
|
||||
// #define TD_TOUR // 旅游出行
|
||||
// #define TD_ONLINEEDU // 在线教育
|
||||
// #define TD_READING // 小说阅读
|
||||
// #define TD_OTHER // 其他行业
|
||||
|
||||
// Converts C style string to NSString
|
||||
static NSString *TDCreateNSString(const char *string) {
|
||||
return string ? [NSString stringWithUTF8String:string] : nil;
|
||||
}
|
||||
|
||||
static NSDictionary *TDCreateNSDictionary(const char *json) {
|
||||
NSString *valStr = TDCreateNSString(json);
|
||||
NSData *valData = [valStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
if (valData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [NSJSONSerialization JSONObjectWithData:valData options:0 error:nil];
|
||||
}
|
||||
|
||||
static char *tdDeviceId = NULL;
|
||||
|
||||
extern "C" {
|
||||
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
void TDInitSDK(const char *appId, const char *channelId, const char *custom) {
|
||||
if ([TalkingDataSDK respondsToSelector:@selector(setFrameworkTag:)]) {
|
||||
[TalkingDataSDK performSelector:@selector(setFrameworkTag:) withObject:@2];
|
||||
}
|
||||
[TalkingDataSDK initSDK:TDCreateNSString(appId)
|
||||
channelId:TDCreateNSString(channelId)
|
||||
custom:TDCreateNSString(custom)];
|
||||
}
|
||||
|
||||
void TDStartA() {
|
||||
[TalkingDataSDK startA];
|
||||
}
|
||||
|
||||
void TDBackgroundSessionEnabled() {
|
||||
[TalkingDataSDK backgroundSessionEnabled];
|
||||
}
|
||||
|
||||
const char *TDGetDeviceId() {
|
||||
if (!tdDeviceId) {
|
||||
NSString *deviceId = [TalkingDataSDK getDeviceId];
|
||||
tdDeviceId = (char *)calloc(deviceId.length + 1, sizeof(char));
|
||||
strcpy(tdDeviceId, deviceId.UTF8String);
|
||||
}
|
||||
return tdDeviceId;
|
||||
}
|
||||
|
||||
void TDSetVerboseLogDisable() {
|
||||
[TalkingDataSDK setVerboseLogDisable];
|
||||
}
|
||||
|
||||
void TDSetLocation(double latitude, double longitude) {
|
||||
[TalkingDataSDK setLatitude:latitude longitude:longitude];
|
||||
}
|
||||
|
||||
void TDOnPageBegin(const char *pageName) {
|
||||
[TalkingDataSDK onPageBegin:TDCreateNSString(pageName)];
|
||||
}
|
||||
|
||||
void TDOnPageEnd(const char *pageName) {
|
||||
[TalkingDataSDK onPageEnd:TDCreateNSString(pageName)];
|
||||
}
|
||||
|
||||
void TDOnReceiveDeepLink(const char *url) {
|
||||
[TalkingDataSDK onReceiveDeepLink:[NSURL URLWithString:TDCreateNSString(url)]];
|
||||
}
|
||||
|
||||
void TDOnRegister(const char *profileId, const char *profileJson, const char *invitationCode, const char *eventValueJson) {
|
||||
NSDictionary *profileDic = TDCreateNSDictionary(profileJson);
|
||||
TalkingDataProfile *profile = [TalkingDataProfile createProfile];
|
||||
profile.name = [profileDic objectForKey:@"name"];
|
||||
NSNumber *typeNum = [profileDic objectForKey:@"type"];
|
||||
if ([typeNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.type = (TalkingDataProfileType)[typeNum unsignedIntegerValue];
|
||||
}
|
||||
NSNumber *genderNum = [profileDic objectForKey:@"gender"];
|
||||
if ([genderNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.gender = (TalkingDataGender)[genderNum unsignedIntegerValue];
|
||||
}
|
||||
NSNumber *ageNum = [profileDic objectForKey:@"age"];
|
||||
if ([ageNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.age = [ageNum intValue];
|
||||
}
|
||||
profile.property1 = [profileDic objectForKey:@"property1"];
|
||||
profile.property2 = [profileDic objectForKey:@"property2"];
|
||||
profile.property3 = [profileDic objectForKey:@"property3"];
|
||||
profile.property4 = [profileDic objectForKey:@"property4"];
|
||||
profile.property5 = [profileDic objectForKey:@"property5"];
|
||||
profile.property6 = [profileDic objectForKey:@"property6"];
|
||||
profile.property7 = [profileDic objectForKey:@"property7"];
|
||||
profile.property8 = [profileDic objectForKey:@"property8"];
|
||||
profile.property9 = [profileDic objectForKey:@"property9"];
|
||||
profile.property10 = [profileDic objectForKey:@"property10"];
|
||||
[TalkingDataSDK onRegister:TDCreateNSString(profileId)
|
||||
profile:profile
|
||||
invitationCode:TDCreateNSString(invitationCode)
|
||||
eventValue:TDCreateNSDictionary(eventValueJson)];
|
||||
}
|
||||
|
||||
void TDOnLogin(const char *profileId, const char *profileJson, const char *eventValueJson) {
|
||||
NSString *profileStr = TDCreateNSString(profileJson);
|
||||
NSData *profileData = [profileStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSDictionary *profileDic = TDCreateNSDictionary(eventValueJson);
|
||||
TalkingDataProfile *profile = [TalkingDataProfile createProfile];
|
||||
profile.name = [profileDic objectForKey:@"name"];
|
||||
NSNumber *typeNum = [profileDic objectForKey:@"type"];
|
||||
if ([typeNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.type = (TalkingDataProfileType)[typeNum unsignedIntegerValue];
|
||||
}
|
||||
NSNumber *genderNum = [profileDic objectForKey:@"gender"];
|
||||
if ([genderNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.gender = (TalkingDataGender)[genderNum unsignedIntegerValue];
|
||||
}
|
||||
NSNumber *ageNum = [profileDic objectForKey:@"age"];
|
||||
if ([ageNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.age = [ageNum intValue];
|
||||
}
|
||||
profile.property1 = [profileDic objectForKey:@"property1"];
|
||||
profile.property2 = [profileDic objectForKey:@"property2"];
|
||||
profile.property3 = [profileDic objectForKey:@"property3"];
|
||||
profile.property4 = [profileDic objectForKey:@"property4"];
|
||||
profile.property5 = [profileDic objectForKey:@"property5"];
|
||||
profile.property6 = [profileDic objectForKey:@"property6"];
|
||||
profile.property7 = [profileDic objectForKey:@"property7"];
|
||||
profile.property8 = [profileDic objectForKey:@"property8"];
|
||||
profile.property9 = [profileDic objectForKey:@"property9"];
|
||||
profile.property10 = [profileDic objectForKey:@"property10"];
|
||||
[TalkingDataSDK onLogin:TDCreateNSString(profileId)
|
||||
profile:profile
|
||||
eventValue:TDCreateNSDictionary(eventValueJson)];
|
||||
}
|
||||
|
||||
void TDOnProfileUpdate(const char *profileJson) {
|
||||
NSDictionary *profileDic = TDCreateNSDictionary(profileJson);
|
||||
TalkingDataProfile *profile = [TalkingDataProfile createProfile];
|
||||
profile.name = [profileDic objectForKey:@"name"];
|
||||
NSNumber *typeNum = [profileDic objectForKey:@"type"];
|
||||
if ([typeNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.type = (TalkingDataProfileType)[typeNum unsignedIntegerValue];
|
||||
}
|
||||
NSNumber *genderNum = [profileDic objectForKey:@"gender"];
|
||||
if ([genderNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.gender = (TalkingDataGender)[genderNum unsignedIntegerValue];
|
||||
}
|
||||
NSNumber *ageNum = [profileDic objectForKey:@"age"];
|
||||
if ([ageNum isKindOfClass:[NSNumber class]]) {
|
||||
profile.age = [ageNum intValue];
|
||||
}
|
||||
profile.property1 = [profileDic objectForKey:@"property1"];
|
||||
profile.property2 = [profileDic objectForKey:@"property2"];
|
||||
profile.property3 = [profileDic objectForKey:@"property3"];
|
||||
profile.property4 = [profileDic objectForKey:@"property4"];
|
||||
profile.property5 = [profileDic objectForKey:@"property5"];
|
||||
profile.property6 = [profileDic objectForKey:@"property6"];
|
||||
profile.property7 = [profileDic objectForKey:@"property7"];
|
||||
profile.property8 = [profileDic objectForKey:@"property8"];
|
||||
profile.property9 = [profileDic objectForKey:@"property9"];
|
||||
profile.property10 = [profileDic objectForKey:@"property10"];
|
||||
[TalkingDataSDK onProfileUpdate:profile];
|
||||
}
|
||||
|
||||
void TDOnCreateCard(const char *profileId, const char *method, const char *content) {
|
||||
[TalkingDataSDK onCreateCard:TDCreateNSString(profileId)
|
||||
method:TDCreateNSString(method)
|
||||
content:TDCreateNSString(content)];
|
||||
}
|
||||
|
||||
void TDOnFavorite(const char *category, const char *content, const char *eventValue) {
|
||||
[TalkingDataSDK onFavorite:TDCreateNSString(category)
|
||||
content:TDCreateNSString(content)
|
||||
eventValue:TDCreateNSDictionary(eventValue)];
|
||||
}
|
||||
|
||||
void TDOnShare(const char *profileId, const char *content, const char *eventValue) {
|
||||
[TalkingDataSDK onShare:TDCreateNSString(profileId)
|
||||
content:TDCreateNSString(content)
|
||||
eventValue:TDCreateNSDictionary(eventValue)];
|
||||
}
|
||||
|
||||
void TDOnPunch(const char *profileId, const char *punchId) {
|
||||
[TalkingDataSDK onPunch:TDCreateNSString(profileId)
|
||||
punchId:TDCreateNSString(punchId)];
|
||||
}
|
||||
|
||||
void TDOnSearch(const char *searchJson) {
|
||||
NSDictionary *searchDic = TDCreateNSDictionary(searchJson);
|
||||
TalkingDataSearch *search = [TalkingDataSearch createSearch];
|
||||
search.category = [searchDic objectForKey:@"category"];
|
||||
search.content = [searchDic objectForKey:@"content"];
|
||||
#ifdef TD_RETAIL
|
||||
search.itemId = [searchDic objectForKey:@"itemId"];
|
||||
search.itemLocationId = [searchDic objectForKey:@"itemLocationId"];
|
||||
#endif
|
||||
#ifdef TD_TOUR
|
||||
search.destination = [searchDic objectForKey:@"destination"];
|
||||
search.origin = [searchDic objectForKey:@"origin"];
|
||||
search.startDate = [[searchDic objectForKey:@"startDate"] longLongValue];
|
||||
search.endDate = [[searchDic objectForKey:@"endDate"] longLongValue];
|
||||
#endif
|
||||
[TalkingDataSDK onSearch:search];
|
||||
}
|
||||
|
||||
#if (defined(TD_RETAIL) || defined(TD_FINANCE) || defined(TD_TOUR) || defined(TD_ONLINEEDU))
|
||||
void TDOnContact(const char *profileId, const char *content) {
|
||||
[TalkingDataSDK onContact:TDCreateNSString(profileId)
|
||||
content:TDCreateNSString(content)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(TD_GAME) || defined(TD_TOUR) || defined(TD_ONLINEEDU) || defined(TD_READING) || defined(TD_OTHER))
|
||||
void TDOnPay(const char *profileId, const char *orderId, int amount, const char *currencyType, const char *paymentType, const char *itemId, int itemCount) {
|
||||
[TalkingDataSDK onPay:TDCreateNSString(profileId)
|
||||
orderId:TDCreateNSString(orderId)
|
||||
amount:amount
|
||||
currencyType:TDCreateNSString(currencyType)
|
||||
paymentType:TDCreateNSString(paymentType)
|
||||
itemId:TDCreateNSString(itemId)
|
||||
itemCount:itemCount];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(TD_RETAIL) || defined(TD_FINANCE) || defined(TD_TOUR) || defined(TD_ONLINEEDU))
|
||||
void TDOnChargeBack(const char *profileId, const char *orderId, const char *reason, const char *type) {
|
||||
[TalkingDataSDK onChargeBack:TDCreateNSString(profileId)
|
||||
orderId:TDCreateNSString(orderId)
|
||||
reason:TDCreateNSString(reason)
|
||||
type:TDCreateNSString(type)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(TD_FINANCE) || defined(TD_ONLINEEDU))
|
||||
void TDOnReservation(const char *profileId, const char *reservationId, const char *category, int amount, const char *term) {
|
||||
[TalkingDataSDK onReservation:TDCreateNSString(profileId)
|
||||
reservationId:TDCreateNSString(reservationId)
|
||||
category:TDCreateNSString(category)
|
||||
amount:amount
|
||||
term:TDCreateNSString(term)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(TD_RETAIL) || defined(TD_TOUR))
|
||||
void TDOnBooking(const char *profileId, const char *bookingId, const char *category, int amount, const char *content) {
|
||||
[TalkingDataSDK onBooking:TDCreateNSString(profileId)
|
||||
bookingId:TDCreateNSString(bookingId)
|
||||
category:TDCreateNSString(category)
|
||||
amount:amount
|
||||
content:TDCreateNSString(content)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TD_RETAIL
|
||||
void TDOnViewItem(const char *itemId, const char *category, const char *name, int unitPrice, const char *eventValueJson) {
|
||||
[TalkingDataSDK onViewItem:TDCreateNSString(itemId)
|
||||
category:TDCreateNSString(category)
|
||||
name:TDCreateNSString(name)
|
||||
unitPrice:unitPrice
|
||||
eventValue:TDCreateNSDictionary(eventValueJson)];
|
||||
}
|
||||
|
||||
void TDOnAddItemToShoppingCart(const char *itemId, const char *category, const char *name, int unitPrice, int amount, const char *eventValueJson) {
|
||||
[TalkingDataSDK onAddItemToShoppingCart:TDCreateNSString(itemId)
|
||||
category:TDCreateNSString(category)
|
||||
name:TDCreateNSString(name)
|
||||
unitPrice:unitPrice
|
||||
amount:amount
|
||||
eventValue:TDCreateNSDictionary(eventValueJson)];
|
||||
}
|
||||
|
||||
void TDOnViewShoppingCart(const char *shoppingCartJson) {
|
||||
NSDictionary *shoppingCartDic = TDCreateNSDictionary(shoppingCartJson);
|
||||
TalkingDataShoppingCart *shoppingCart = [TalkingDataShoppingCart createShoppingCart];
|
||||
NSArray *items = shoppingCartDic[@"items"];
|
||||
for (NSDictionary *item in items) {
|
||||
[shoppingCart addItem:item[@"itemId"]
|
||||
category:item[@"category"]
|
||||
name:item[@"name"]
|
||||
unitPrice:[item[@"unitPrice"] intValue]
|
||||
amount:[item[@"amount"] intValue]];
|
||||
}
|
||||
[TalkingDataSDK onViewShoppingCart:shoppingCart];
|
||||
}
|
||||
|
||||
void TDOnPlaceOrder(const char *orderJson, const char *profileId, const char *eventValueJson) {
|
||||
NSDictionary *orderDic = TDCreateNSDictionary(orderJson);
|
||||
TalkingDataOrder *order = [TalkingDataOrder createOrder:orderDic[@"orderId"]
|
||||
total:[orderDic[@"total"] intValue]
|
||||
currencyType:orderDic[@"currencyType"]];
|
||||
NSArray *items = orderDic[@"items"];
|
||||
for (NSDictionary *item in items) {
|
||||
[order addItem:item[@"itemId"]
|
||||
category:item[@"category"]
|
||||
name:item[@"name"]
|
||||
unitPrice:[item[@"unitPrice"] intValue]
|
||||
amount:[item[@"amount"] intValue]];
|
||||
}
|
||||
[TalkingDataSDK onPlaceOrder:order
|
||||
profileId:TDCreateNSString(profileId)
|
||||
eventValue:TDCreateNSDictionary(eventValueJson)];
|
||||
}
|
||||
|
||||
void TDOnOrderPaySucc(const char *orderJson, const char *paymentType, const char *profileId) {
|
||||
NSDictionary *orderDic = TDCreateNSDictionary(orderJson);
|
||||
TalkingDataOrder *order = [TalkingDataOrder createOrder:orderDic[@"orderId"]
|
||||
total:[orderDic[@"total"] intValue]
|
||||
currencyType:orderDic[@"currencyType"]];
|
||||
NSArray *items = orderDic[@"items"];
|
||||
for (NSDictionary *item in items) {
|
||||
[order addItem:item[@"itemId"]
|
||||
category:item[@"category"]
|
||||
name:item[@"name"]
|
||||
unitPrice:[item[@"unitPrice"] intValue]
|
||||
amount:[item[@"amount"] intValue]];
|
||||
}
|
||||
[TalkingDataSDK onOrderPaySucc:order
|
||||
paymentType:TDCreateNSString(paymentType)
|
||||
profileId:TDCreateNSString(profileId)];
|
||||
}
|
||||
|
||||
void TDOnCancelOrder(const char *orderJson) {
|
||||
NSDictionary *orderDic = TDCreateNSDictionary(orderJson);
|
||||
TalkingDataOrder *order = [TalkingDataOrder createOrder:orderDic[@"orderId"]
|
||||
total:[orderDic[@"total"] intValue]
|
||||
currencyType:orderDic[@"currencyType"]];
|
||||
NSArray *items = orderDic[@"items"];
|
||||
for (NSDictionary *item in items) {
|
||||
[order addItem:item[@"itemId"]
|
||||
category:item[@"category"]
|
||||
name:item[@"name"]
|
||||
unitPrice:[item[@"unitPrice"] intValue]
|
||||
amount:[item[@"amount"] intValue]];
|
||||
}
|
||||
[TalkingDataSDK onCancelOrder:order];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TD_FINANCE
|
||||
void TDOnCredit(const char *profileId, int amount, const char *content) {
|
||||
[TalkingDataSDK onCredit:TDCreateNSString(profileId)
|
||||
amount:amount
|
||||
content:TDCreateNSString(content)];
|
||||
}
|
||||
|
||||
void TDOnTransaction(const char *profileId, const char *transactionJson) {
|
||||
NSString *transactionStr = TDCreateNSString(transactionJson);
|
||||
NSData *transactionData = [transactionStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSDictionary *transactionDic = TDCreateNSDictionary(transactionJson);
|
||||
TalkingDataTransaction *transaction = [TalkingDataTransaction createTransaction];
|
||||
transaction.transactionId = [transactionDic objectForKey:@"transactionId"];
|
||||
transaction.category = [transactionDic objectForKey:@"category"];
|
||||
transaction.amount = [[transactionDic objectForKey:@"amount"] intValue];
|
||||
transaction.personA = [transactionDic objectForKey:@"personA"];
|
||||
transaction.personB = [transactionDic objectForKey:@"personB"];
|
||||
transaction.startDate = [[transactionDic objectForKey:@"startDate"] longValue];
|
||||
transaction.endDate = [[transactionDic objectForKey:@"endDate"] longValue];
|
||||
transaction.currencyType = [transactionDic objectForKey:@"currencyType"];
|
||||
transaction.content = [transactionDic objectForKey:@"content"];
|
||||
[TalkingDataSDK onTransaction:TDCreateNSString(profileId)
|
||||
transaction:transaction];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TD_GAME
|
||||
void TDOnCreateRole(const char *name) {
|
||||
[TalkingDataSDK onCreateRole:TDCreateNSString(name)];
|
||||
}
|
||||
|
||||
void TDOnLevelPass(const char *profileId, const char *levelId) {
|
||||
[TalkingDataSDK onLevelPass:TDCreateNSString(profileId)
|
||||
levelId:TDCreateNSString(levelId)];
|
||||
}
|
||||
|
||||
void TDOnGuideFinished(const char *profileId, const char *content) {
|
||||
[TalkingDataSDK onGuideFinished:TDCreateNSString(profileId)
|
||||
content:TDCreateNSString(content)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TD_ONLINEEDU
|
||||
void TDOnLearn(const char *profileId, const char *course, long long begin, int duration) {
|
||||
[TalkingDataSDK onLearn:TDCreateNSString(profileId)
|
||||
course:TDCreateNSString(course)
|
||||
begin:begin
|
||||
duration:duration];
|
||||
}
|
||||
|
||||
void TDOnPreviewFinished(const char *profileId, const char *content) {
|
||||
[TalkingDataSDK onPreviewFinished:TDCreateNSString(profileId)
|
||||
content:TDCreateNSString(content)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TD_READING
|
||||
void TDOnRead(const char *profileId, const char *book, long long begin, int duration) {
|
||||
[TalkingDataSDK onRead:TDCreateNSString(profileId)
|
||||
book:TDCreateNSString(book)
|
||||
begin:begin
|
||||
duration:duration];
|
||||
}
|
||||
|
||||
void TDOnFreeFinished(const char *profileId, const char *content) {
|
||||
[TalkingDataSDK onFreeFinished:TDCreateNSString(profileId)
|
||||
content:TDCreateNSString(content)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(TD_GAME) || defined(TD_ONLINEEDU))
|
||||
void TDOnAchievementUnlock(const char *profileId, const char *achievementId) {
|
||||
[TalkingDataSDK onAchievementUnlock:TDCreateNSString(profileId)
|
||||
achievementId:TDCreateNSString(achievementId)];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(TD_FINANCE) || defined(TD_TOUR) || defined(TD_OTHER))
|
||||
void TDOnBrowse(const char *profileId, const char *content, long long begin, int duration) {
|
||||
[TalkingDataSDK onBrowse:TDCreateNSString(profileId)
|
||||
content:TDCreateNSString(content)
|
||||
begin:begin
|
||||
duration:duration];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(TD_RETAIL) || defined(TD_FINANCE) || defined(TD_TOUR) || defined(TD_OTHER))
|
||||
void TDOnTrialFinished(const char *profileId, const char *content) {
|
||||
[TalkingDataSDK onTrialFinished:TDCreateNSString(profileId)
|
||||
content:TDCreateNSString(content)];
|
||||
}
|
||||
#endif
|
||||
|
||||
void TDOnEvent(const char *eventId, const char *parameters, const char *eventValueJson) {
|
||||
NSString *parameterStr = TDCreateNSString(parameters);
|
||||
NSDictionary *parameterDic = nil;
|
||||
if (parameterStr) {
|
||||
NSData *parameterData = [parameterStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
parameterDic = [NSJSONSerialization JSONObjectWithData:parameterData options:0 error:nil];
|
||||
}
|
||||
[TalkingDataSDK onEvent:TDCreateNSString(eventId)
|
||||
parameters:parameterDic
|
||||
eventValue:TDCreateNSDictionary(eventValueJson)];
|
||||
}
|
||||
|
||||
void TDSetGlobalKV(const char *key, const char *strVal, double numVal) {
|
||||
if (strVal != NULL) {
|
||||
[TalkingDataSDK setGlobalKV:TDCreateNSString(key)
|
||||
value:TDCreateNSString(strVal)];
|
||||
} else {
|
||||
[TalkingDataSDK setGlobalKV:TDCreateNSString(key)
|
||||
value:[NSNumber numberWithDouble:numVal]];
|
||||
}
|
||||
}
|
||||
|
||||
void TDRemoveGlobalKV(const char *key) {
|
||||
[TalkingDataSDK removeGlobalKV:TDCreateNSString(key)];
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic warning "-Wmissing-prototypes"
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e23cce180e3eda4da10f4b7eb062f13
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,81 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 62318a94b40096f49a43901c2775a212
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AndroidSharedLibraryType: Executable
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue