[WIP] SKU list
This commit is contained in:
@@ -96,7 +96,7 @@ public class SDKTest : MonoBehaviour
|
|||||||
public async void OnPayListBtn()
|
public async void OnPayListBtn()
|
||||||
{
|
{
|
||||||
Debug.LogError("PayList ask");
|
Debug.LogError("PayList ask");
|
||||||
var result = await TYSdkFacade.Instance.ThirdExtend();
|
var result = await TYSdkFacade.Instance.GetSKUList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGaBtn()
|
public void OnGaBtn()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class ConfigManager {
|
|||||||
public static final String UNITY_FACADE_NAME = "TYSdkFacade";
|
public static final String UNITY_FACADE_NAME = "TYSdkFacade";
|
||||||
public static final String LOGIN_CALLBACK_FUNCTION_NAME = "LoginResult";
|
public static final String LOGIN_CALLBACK_FUNCTION_NAME = "LoginResult";
|
||||||
public static final String PAY_CALLBACK_FUNCTION_NAME = "PayResult";
|
public static final String PAY_CALLBACK_FUNCTION_NAME = "PayResult";
|
||||||
public static final String PAY_TYPE_CALLBACK_FUNCTION_NAME = "PayTypeResult";
|
public static final String PAY_TYPE_CALLBACK_FUNCTION_NAME = "GetSKUList";
|
||||||
public static final String FCM_NOTICE_FUNCTION_NAME = "FCMCallback";
|
public static final String FCM_NOTICE_FUNCTION_NAME = "FCMCallback";
|
||||||
public static final String FCM_REALNAME_CALLBACK_FUNCTION_NAME = "RealNameCallback";
|
public static final String FCM_REALNAME_CALLBACK_FUNCTION_NAME = "RealNameCallback";
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,30 @@ extern "C" {
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetSKUList()
|
||||||
|
{
|
||||||
|
NSLog(@"TYSdkInterface GetSKUList ");
|
||||||
|
[XYApi XYGetLocalProductPriceWithCompletion:^(XYResp * _Nonnull resp) {
|
||||||
|
|
||||||
|
NSMutableDictionary *resultDict = [@{} mutableCopy];
|
||||||
|
[resultDict setValue:[NSString stringWithFormat:@"%ld", (long)resp.errCode] forKey:@"code"];
|
||||||
|
if(resp.errCode == XYSuccess){
|
||||||
|
NSLog(@"TYSdkInterface GetSKUList Success");
|
||||||
|
NSLog(@"SKUList %@", resp.respObj);
|
||||||
|
[resultDict setValue:resp.respObj forKey:@"respObj"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"TYSdkInterface GetSKUList Faild");
|
||||||
|
NSLog(@"SKUList %@", resp.errCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *result = DicTojsonString(resultDict);
|
||||||
|
const char* param = AllocCString(result);
|
||||||
|
UnitySendMessage("TYSdkFacade","SKUListResult", param);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
//打点
|
//打点
|
||||||
void SetGaUserInfo(const char* userId)
|
void SetGaUserInfo(const char* userId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -93,22 +93,22 @@ namespace tysdk
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get Pay list
|
// Get Pay list
|
||||||
public async Task<SKUDetail> ThirdExtend()
|
public async Task<List<SKUDetail>> GetSKUList()
|
||||||
{
|
{
|
||||||
if (!IsLoggedIn) return new SKUDetail() { code = "-1", msg = "未登录" };
|
if (!IsLoggedIn) return null;
|
||||||
|
|
||||||
#if UNITY_EDITOR || UNITY_IOS
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
await Task.Yield();
|
await Task.Yield();
|
||||||
var result = new SKUDetail();
|
return null;
|
||||||
return result;
|
#elif UNITY_ANDROID || UNITY_IOS
|
||||||
#elif UNITY_ANDROID
|
|
||||||
|
|
||||||
var taskSource = new TaskCompletionSource<SKUDetail>();
|
var taskSource = new TaskCompletionSource<List<SKUDetail>>();
|
||||||
callbacks.Add("PayTypeResult", (ITYSdkCallback callback) =>
|
callbacks.Add("SKUList", (ITYSdkCallback callback) =>
|
||||||
{
|
{
|
||||||
taskSource.SetResult((SKUDetail)callback);
|
taskSource.SetResult((List<SKUDetail>)callback);
|
||||||
});
|
});
|
||||||
UnityBridgeFunc.ThirdExtend();
|
UnityBridgeFunc.GetSKUList();
|
||||||
var result = await taskSource.Task;
|
var result = await taskSource.Task;
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@@ -116,9 +116,9 @@ namespace tysdk
|
|||||||
}
|
}
|
||||||
|
|
||||||
//商品列表的回调
|
//商品列表的回调
|
||||||
public void PayTypeResult(string json)
|
public void SKUListResult(string json)
|
||||||
{
|
{
|
||||||
Debug.Log("[thirdExtend] pay callback:");
|
Debug.Log("[TYSdkFacade] GetSKUList callback:");
|
||||||
var jresult = JObject.Parse(json);
|
var jresult = JObject.Parse(json);
|
||||||
var result = new SKUDetail();
|
var result = new SKUDetail();
|
||||||
result.code = jresult["code"].ToString();
|
result.code = jresult["code"].ToString();
|
||||||
@@ -126,8 +126,8 @@ namespace tysdk
|
|||||||
|
|
||||||
if (callbacks.TryGetValue("PayTypeResult", out var action))
|
if (callbacks.TryGetValue("PayTypeResult", out var action))
|
||||||
{
|
{
|
||||||
action.Invoke(result);
|
action.Invoke(new SKUList());
|
||||||
callbacks.Remove("PayTypeResult");
|
callbacks.Remove("SKUList");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace tysdk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SKUDetail: ITYSdkCallback
|
public class SKUDetail
|
||||||
{
|
{
|
||||||
public string code;
|
public string code;
|
||||||
public string msg;
|
public string msg;
|
||||||
@@ -55,6 +55,11 @@ namespace tysdk
|
|||||||
public string currency_code;
|
public string currency_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SKUList: ITYSdkCallback
|
||||||
|
{
|
||||||
|
public System.Collections.Generic.List<SKUDetail> list;
|
||||||
|
}
|
||||||
|
|
||||||
public class ATTInfo : ITYSdkCallback
|
public class ATTInfo : ITYSdkCallback
|
||||||
{
|
{
|
||||||
public bool isAccepted;
|
public bool isAccepted;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace tysdk
|
|||||||
string productCount, string prodorderId, string appInfo){}
|
string productCount, string prodorderId, string appInfo){}
|
||||||
|
|
||||||
//获取商品列表
|
//获取商品列表
|
||||||
public static void ThirdExtend() { }
|
public static void GetSKUList() { }
|
||||||
|
|
||||||
//打点
|
//打点
|
||||||
public static void SetGaUserInfo(string userId){}
|
public static void SetGaUserInfo(string userId){}
|
||||||
@@ -148,7 +148,7 @@ namespace tysdk
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取商品列表
|
//获取商品列表
|
||||||
public static void ThirdExtend()
|
public static void GetSKUList()
|
||||||
{
|
{
|
||||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||||
{
|
{
|
||||||
@@ -243,6 +243,10 @@ namespace tysdk
|
|||||||
public static extern void UnityKnow(string userId, string productId, string productPrice, string productName,
|
public static extern void UnityKnow(string userId, string productId, string productPrice, string productName,
|
||||||
string productCount, string prodorderId, string appInfo);
|
string productCount, string prodorderId, string appInfo);
|
||||||
|
|
||||||
|
//获取商品列表
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
public static extern void GetSKUList();
|
||||||
|
|
||||||
//打点
|
//打点
|
||||||
[DllImport("__Internal")]
|
[DllImport("__Internal")]
|
||||||
public static extern void SetGaUserInfo(string userId);
|
public static extern void SetGaUserInfo(string userId);
|
||||||
|
|||||||
Reference in New Issue
Block a user