/* Public interface for use inside C# code */ public static TalkingDataShoppingCart CreateShoppingCart() { // Call plugin only when running on real device if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) { shoppingCart = new TalkingDataShoppingCart(); #if UNITY_ANDROID AndroidJavaClass javaClass = new AndroidJavaClass("com.tendcloud.tenddata.ShoppingCart"); shoppingCart.javaObj = javaClass.CallStatic <AndroidJavaObject>("createShoppingCart"); #endif return(shoppingCart); } return(null); }
public static void OnViewShoppingCart(TalkingDataShoppingCart shoppingCart) { // Call plugin only when running on real device if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor) { Debug.Log("ShoppingCart:" + shoppingCart); #if UNITY_IPHONE tdOnViewShoppingCart(shoppingCart.ToString()); #endif #if UNITY_ANDROID AndroidJavaClass tCAgent = new AndroidJavaClass("com.tendcloud.tenddata.TCAgent"); tCAgent.CallStatic("onViewShoppingCart", shoppingCart.javaObj); #endif } }
void OnGUI() { int i = 0; GUI.Box(new Rect(10, 10, Screen.width - 20, Screen.height - 20), "Demo Menu"); if (GUI.Button(new Rect(left, top + step * i++, width, height), "Apply Auth Code")) { TalkingDataEAuth.ApplyAuthCode("86", mobile, TalkingDataAuthCodeType.smsAuth, account, smsId); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Reapply Auth Code")) { TalkingDataEAuth.ReapplyAuthCode("86", mobile, TalkingDataAuthCodeType.voiceCallAuth, account, smsId, request_id); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Is Verify Account")) { TalkingDataEAuth.IsVerifyAccount(account); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Is Mobile Match Account")) { TalkingDataEAuth.IsMobileMatchAccount(account, "86", mobile); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Bind")) { TalkingDataEAuth.Bind("86", mobile, "001178", account); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "Unbind")) { TalkingDataEAuth.Unbind("86", mobile, account); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnRegister")) { TalkingDataPlugin.OnRegister("user01", TalkingDataAccountType.ANONYMOUS, "abc"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnLogin")) { TalkingDataPlugin.OnLogin("user01", TalkingDataAccountType.TYPE1, "abc"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnPlaceOrder")) { TalkingDataOrder order = TalkingDataOrder.CreateOrder("order01", 2466400, "CNY"); order.AddItem("A1660", "手机", "iPhone 7", 538800, 2); order.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1); TalkingDataPlugin.OnPlaceOrder("user01", order); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnOrderPaySucc")) { TalkingDataOrder order = TalkingDataOrder.CreateOrder("order01", 2466400, "CNY"); order.AddItem("A1660", "手机", "iPhone 7", 538800, 2); order.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1); TalkingDataPlugin.OnOrderPaySucc("user01", "AliPay", order); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnViewItem")) { TalkingDataPlugin.OnViewItem("A1660", "手机", "iPhone 7", 538800); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnAddItemToShoppingCart")) { TalkingDataPlugin.OnAddItemToShoppingCart("MLH12CH", "电脑", "MacBook Pro", 1388800, 1); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "OnViewShoppingCart")) { TalkingDataShoppingCart shoppingCart = TalkingDataShoppingCart.CreateShoppingCart(); if (shoppingCart != null) { shoppingCart.AddItem("A1660", "手机", "iPhone 7", 538800, 2); shoppingCart.AddItem("MLH12CH", "电脑", "MacBook Pro", 1388800, 1); TalkingDataPlugin.OnViewShoppingCart(shoppingCart); } } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackPageBegin")) { TalkingDataPlugin.TrackPageBegin("page_name"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackPageEnd")) { TalkingDataPlugin.TrackPageEnd("page_name"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackEvent")) { TalkingDataPlugin.TrackEvent("action_id"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackEventWithLabel")) { TalkingDataPlugin.TrackEventWithLabel("action_id", "action_label"); } if (GUI.Button(new Rect(left, top + step * i++, width, height), "TrackEventWithParameters")) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("StartApp" + "StartAppTime", "startAppMac" + "#" + "02/01/2013 09:52:24"); dic.Add("IntValue", 1); TalkingDataPlugin.TrackEventWithParameters("action_id", "action_label", dic); } }