Merge branch 'main' of 192.168.9.102:tysdk-intergration

# Conflicts:
#	sdk-intergration/Assets/Scripts/SDKTest.cs
#	sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_Pay.cs
#	sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs
This commit is contained in:
LYP
2024-08-09 11:48:57 +08:00
18 changed files with 556 additions and 21 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
bin bin
bin_BurstDebugInformation_DoNotShip bin_BurstDebugInformation_DoNotShip
sdk-intergration/.vscode sdk-intergration/.vscode
sdk-intergration/'

View File

@@ -0,0 +1,34 @@
using System.Collections;
using UnityEngine;
public class AFAdRevenueEvent {
/**
*Pre-defined keys for non-mandatory dictionary
*Code ISO 3166-1 format
**/
public const string COUNTRY = "country";
/**
*ID of the ad unit for the impression
**/
public const string AD_UNIT = "ad_unit";
/**
*Format of the ad
**/
public const string AD_TYPE = "ad_type";
/**
*ID of the ad placement for the impression
**/
public const string PLACEMENT = "placement";
/**
*Provided by Facebook Audience Network only, and will be reported to publishers
*approved by Facebook Audience Network within the closed beta
**/
public const string ECPM_PAYLOAD = "ecpm_payload";
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b73b301ad8b6f4b45809980800a9358a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,178 @@
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
using System;
namespace AppsFlyerSDK
{
public class AppsFlyerAdRevenue : MonoBehaviour
{
public static readonly string kAppsFlyerAdRevenueVersion = "6.14.3";
#if UNITY_ANDROID && !UNITY_EDITOR
private static AndroidJavaClass appsFlyerAndroid = new AndroidJavaClass("com.appsflyer.unity.afunityadrevenuegenericplugin.AdRevenueUnityWrapper");
#endif
public static void start()
{
#if UNITY_IOS && !UNITY_EDITOR
_start();
#elif UNITY_ANDROID && !UNITY_EDITOR
using(AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
using(AndroidJavaObject cls_Activity = cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) {
AndroidJavaObject cls_Application = cls_Activity.Call<AndroidJavaObject>("getApplication");
appsFlyerAndroid.CallStatic("start", cls_Application);
}
}
#else
#endif
}
public static void setIsDebug(bool isDebug)
{
#if UNITY_IOS && !UNITY_EDITOR
_setIsDebugAdrevenue(isDebug);
#elif UNITY_ANDROID && !UNITY_EDITOR
#else
#endif
}
public static void logAdRevenue(string monetizationNetwork,
AppsFlyerAdRevenueMediationNetworkType mediationNetwork,
double eventRevenue,
string revenueCurrency,
Dictionary<string, string> additionalParameters)
{
#if UNITY_IOS && !UNITY_EDITOR
_logAdRevenue(monetizationNetwork, mediationNetwork, eventRevenue, revenueCurrency, AFMiniJSON.Json.Serialize(additionalParameters));
#elif UNITY_ANDROID && !UNITY_EDITOR
int mediationNetworkAndroid = setMediationNetworkTypeAndroid(mediationNetwork);
if (mediationNetworkAndroid == -1)
{
Debug.Log("Please choose a valid mediationNetwork");
} else
{
appsFlyerAndroid.CallStatic("logAdRevenue",
monetizationNetwork,
mediationNetworkAndroid,
revenueCurrency,
eventRevenue,
convertDictionaryToJavaMap(additionalParameters));
}
#else
#endif
}
#if UNITY_IOS && !UNITY_EDITOR
[DllImport("__Internal")]
private static extern void _start();
[DllImport("__Internal")]
private static extern void _setIsDebugAdrevenue(bool isDebug);
[DllImport("__Internal")]
private static extern void _logAdRevenue(string monetizationNetwork,
AppsFlyerAdRevenueMediationNetworkType mediationNetwork,
double eventRevenue,
string revenueCurrency,
string additionalParameters);
#elif UNITY_ANDROID && !UNITY_EDITOR
#else
#endif
private static int setMediationNetworkTypeAndroid(AppsFlyerAdRevenueMediationNetworkType mediationNetwork)
{
switch (mediationNetwork)
{
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeIronSource:
return 0;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeApplovinMax:
return 1;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob:
return 2;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeFyber:
return 3;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeAppodeal:
return 4;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeAdmost:
return 5;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeTopon:
return 6;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeTradplus:
return 7;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeYandex:
return 8;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeChartBoost:
return 9;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeUnity:
return 10;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeCustomMediation:
return 11;
case AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypedirectMonetization:
return 12;
default:
return -1;
}
}
private static AndroidJavaObject convertDictionaryToJavaMap(Dictionary<string, string> dictionary)
{
AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap");
IntPtr putMethod = AndroidJNIHelper.GetMethodID(map.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
jvalue[] val;
if (dictionary != null)
{
foreach (var entry in dictionary)
{
val = AndroidJNIHelper.CreateJNIArgArray(new object[] { entry.Key, entry.Value });
AndroidJNI.CallObjectMethod(map.GetRawObject(), putMethod, val);
AndroidJNI.DeleteLocalRef(val[0].l);
AndroidJNI.DeleteLocalRef(val[1].l);
}
}
return map;
}
}
public enum AppsFlyerAdRevenueMediationNetworkType
{
AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob = 1,
AppsFlyerAdRevenueMediationNetworkTypeIronSource = 2,
AppsFlyerAdRevenueMediationNetworkTypeApplovinMax = 3,
AppsFlyerAdRevenueMediationNetworkTypeFyber = 4,
AppsFlyerAdRevenueMediationNetworkTypeAppodeal = 5,
AppsFlyerAdRevenueMediationNetworkTypeAdmost = 6,
AppsFlyerAdRevenueMediationNetworkTypeTopon = 7,
AppsFlyerAdRevenueMediationNetworkTypeTradplus = 8,
AppsFlyerAdRevenueMediationNetworkTypeYandex = 9,
AppsFlyerAdRevenueMediationNetworkTypeChartBoost = 10,
AppsFlyerAdRevenueMediationNetworkTypeUnity = 11,
AppsFlyerAdRevenueMediationNetworkTypeCustomMediation = 12,
AppsFlyerAdRevenueMediationNetworkTypedirectMonetization = 13
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 644005ac4602e4b78ad3a8d4d29e329d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dependencies>
<androidPackages>
<androidPackage spec="com.appsflyer:adrevenue:6.9.1"></androidPackage>
<androidPackage spec="com.appsflyer:unity-adrevenue-generic-wrapper:6.9.1"></androidPackage>
</androidPackages>
<iosPods>
<iosPod name="AppsFlyer-AdRevenue" version="6.14.3" minTargetSdk="12.0">
</iosPod>
</iosPods>
</dependencies>

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6110ce30bf7674268814dc9e0395f8b0
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
//
// AppsFlyerAdRevenueWrapper.h
// Unity-iPhone
//
// Created by Jonathan Wesfield on 01/12/2019.
//
#import <Foundation/Foundation.h>
#if __has_include(<AppsFlyerAdRevenue/AppsFlyerAdRevenue.h>)
#import <AppsFlyerAdRevenue/AppsFlyerAdRevenue.h>
#endif
@interface AppsFlyerAdRevenueWrapper : NSObject
@end

View File

@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 7fa891a95d71c459daa1e92ee7a653ab
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
//
// AppsFlyerAdRevenueWrapper.mm
// Unity-iPhone
//
// Created by Jonathan Wesfield on 25/11/2019.
//
#import "AppsFlyerAdRevenueWrapper.h"
@implementation AppsFlyerAdRevenueWrapper
extern "C" {
NSString* stringFromChar(const char *str) {
return str ? [NSString stringWithUTF8String:str] : nil;
}
NSDictionary* dictionaryFromJson(const char *jsonString) {
if(jsonString){
NSData *jsonData = [[NSData alloc] initWithBytes:jsonString length:strlen(jsonString)];
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:nil];
return dictionary;
}
return nil;
}
const void _start(int length, int* adRevenueTypes){
[AppsFlyerAdRevenue start];
}
const void _setIsDebugAdrevenue(bool isDebug){
[[AppsFlyerAdRevenue shared] setIsDebug:isDebug];
}
const void _logAdRevenue(const char* monetizationNetwork,
int mediationNetwork,
double eventRevenue,
const char* revenueCurrency,
const char* additionalParameters){
[[AppsFlyerAdRevenue shared] logAdRevenueWithMonetizationNetwork:stringFromChar(monetizationNetwork)
mediationNetwork:(AppsFlyerAdRevenueMediationNetworkType) mediationNetwork
eventRevenue:[NSNumber numberWithDouble:eventRevenue]
revenueCurrency:stringFromChar(revenueCurrency)
additionalParameters:dictionaryFromJson(additionalParameters)];
}
}
@end

View File

@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: 84d99cf0f930e4c80b4bc1858e042b70
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:

View File

@@ -0,0 +1 @@
import Foundation

View File

@@ -0,0 +1,37 @@
fileFormatVersion: 2
guid: a631431c30cca4ac2bb4b40fc67e4005
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:

View File

@@ -31,7 +31,12 @@ public class SDKTest : MonoBehaviour
void Start() void Start()
{ {
//UnityBridgeFunc.UnityResetServerUrl("http://128-hwsfsdk-sdk-test01.qijihdhk.com "); //===============================================================================
//====================== Test Server ===========================
UnityBridgeFunc.UnityResetServerUrl("http://128-hwsfsdk-sdk-test01.qijihdhk.com");
//====================== Test Server ===========================
//===============================================================================
//
_InitBtn.onClick.AddListener(Init); _InitBtn.onClick.AddListener(Init);
_loginGuestBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGuest)); _loginGuestBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGuest));
_loginGoogleBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGoogle)); _loginGoogleBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGoogle));
@@ -46,7 +51,8 @@ public class SDKTest : MonoBehaviour
void Init() void Init()
{ {
TYSdkFacade.Instance.Init(); TYSdkFacade.Instance.Init();
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) => { MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) =>
{
Debug.Log($"[MaxSdk::OnSdkInitializedEvent] Init:{sdkConfiguration.IsSuccessfullyInitialized}"); Debug.Log($"[MaxSdk::OnSdkInitializedEvent] Init:{sdkConfiguration.IsSuccessfullyInitialized}");
}; };
MaxSdk.InitializeSdk(); MaxSdk.InitializeSdk();
@@ -54,12 +60,27 @@ public class SDKTest : MonoBehaviour
AppsFlyer.setIsDebug(true); AppsFlyer.setIsDebug(true);
#if UNITY_IOS #if UNITY_IOS
AppsFlyer.initSDK("rSySeWtvKabfbPZE7Lmx7C","6505145935"); AppsFlyer.initSDK("rSySeWtvKabfbPZE7Lmx7C", "6505145935");
#elif UNITY_ANDROID #elif UNITY_ANDROID
AppsFlyer.initSDK("rSySeWtvKabfbPZE7Lmx7C", null); AppsFlyer.initSDK("rSySeWtvKabfbPZE7Lmx7C", null);
#endif #endif
AppsFlyer.startSDK(); AppsFlyer.startSDK();
//AppsFlyerAdRevenue.start(); // AppsFlyerAdRevenue.start();
}
int retryAttempt;
public void InitializeRewardedAds()
{
// Attach callback
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdLoadFailedEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenuePaidEvent;
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdHiddenEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardedAdFailedToDisplayEvent;
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
} }
private async void OnLogin(EAccoutType accoutType) private async void OnLogin(EAccoutType accoutType)
@@ -68,7 +89,7 @@ public class SDKTest : MonoBehaviour
Debug.LogError($"[AggSdk::OnLogin] accoutType : {accoutType}"); Debug.LogError($"[AggSdk::OnLogin] accoutType : {accoutType}");
var info = await TYSdkFacade.Instance.Login(accoutType); var info = await TYSdkFacade.Instance.Login(accoutType);
_messageTxt.text = $"Login: {info.isSuccess}"; _messageTxt.text = $"Login: {info.isSuccess}";
if(info.isSuccess) if (info.isSuccess)
{ {
_messageTxt.text += $"\n{info.msg}"; _messageTxt.text += $"\n{info.msg}";
_messageTxt.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}"; _messageTxt.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}";
@@ -79,7 +100,7 @@ public class SDKTest : MonoBehaviour
{ {
TYSdkFacade.Instance.Logout(); TYSdkFacade.Instance.Logout();
} }
public async void OnPayTestBtn() public async void OnPayTestBtn()
{ {
string prodId = "comarkgameft1chooseone0199"; string prodId = "comarkgameft1chooseone0199";
@@ -87,15 +108,15 @@ public class SDKTest : MonoBehaviour
string prodPrice = "2,616"; string prodPrice = "2,616";
string prodName = "test:₩2,616"; string prodName = "test:₩2,616";
int count = 1; int count = 1;
Debug.LogError($"[AggSdk::Pay] prodId : {prodId} prodPrice : {prodPrice} prodName : {prodName} "); Debug.LogError($"[AggSdk::Pay] prodId : {prodId} prodPrice : {prodPrice} prodName : {prodName} ");
PaymentInfo payResult = await TYSdkFacade.Instance.Pay(prodId, prodPrice, prodName, count, pType); PaymentInfo payResult = await TYSdkFacade.Instance.Pay(prodId, prodPrice, prodName, count, pType);
} }
public async void OnPayListBtn() public async void OnPayListBtn()
{ {
ProductListInfo result = await TYSdkFacade.Instance.ThirdExtend(); ProductListInfo result = await TYSdkFacade.Instance.GetSKUList();
if (result.code == 0) if (result.code == 0)
{ {
Debug.LogError("products count:::" + result.products.Count); Debug.LogError("products count:::" + result.products.Count);
@@ -106,19 +127,80 @@ public class SDKTest : MonoBehaviour
} }
} }
public void OnGaBtn() public void OnGaBtn()
{ {
Debug.LogError("Ga ask"); Debug.LogError("Ga ask");
using ( var e = GAEvent.TackEvent("idcheckdone") ) using (var e = GAEvent.TackEvent("idcheckdone"))
{ {
e.AddContent("test ga", true); e.AddContent("test ga", true);
} }
} }
const string AD_ID = "427b872c314ad1f3";
public void OnAppMaxBtn() public void OnAppMaxBtn()
{ {
MaxSdk.ShowRewardedAd("4cea568d96f9c9d3"); if (MaxSdk.IsRewardedAdReady(AD_ID))
{
MaxSdk.ShowRewardedAd(AD_ID);
}
else
{
_messageTxt.text = "AD Not Ready, Load now";
LoadAd();
}
}
private void LoadAd()
{
MaxSdk.LoadRewardedAd("427b872c314ad1f3");
}
private void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
_messageTxt.text = $"Rewarded ad loaded. ID: {adInfo.AdUnitIdentifier}";
retryAttempt = 0;
}
private void OnRewardedAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
{
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds).
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
_messageTxt.text = $"Rewarded ad failed to load. ID: {adUnitId}. Reason: {errorInfo.Message}. Attempt: {retryAttempt}. Delay: {retryDelay}s.";
Invoke("LoadAd", (float)retryDelay);
}
private void OnRewardedAdDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) { }
private void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo)
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
_messageTxt.text = $"Rewarded ad failed to display. ID: {adUnitId}. Reason: {errorInfo.Message}";
LoadAd();
}
private void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) { }
private void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
// Rewarded ad is hidden. Pre-load the next ad
_messageTxt.text = $"Rewarded ad hidden. ID: {adUnitId}.";
LoadAd();
}
private void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward, MaxSdkBase.AdInfo adInfo)
{
_messageTxt.text = $"Rewarded ad received reward. ID: {adUnitId}. Type: {reward}. Amount: {reward.Amount}";
}
private void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
_messageTxt.text = $"Rewarded ad revenue paid. ID: {adUnitId}.";
} }
/* /*

View File

@@ -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 = "SKUListResult";
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";

View File

@@ -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 %ld %@", resp.errCode, resp.errStr);
}
NSString *result = DicTojsonString(resultDict);
const char* param = AllocCString(result);
UnitySendMessage("TYSdkFacade","SKUListResult", param);
}];
}
//打点 //打点
void SetGaUserInfo(const char* userId) void SetGaUserInfo(const char* userId)
{ {

View File

@@ -93,7 +93,7 @@ namespace tysdk
} }
// Get Pay list // Get Pay list
public async Task<ProductListInfo> ThirdExtend() public async Task<ProductListInfo> GetSKUList()
{ {
if (!IsLoggedIn) return new ProductListInfo() { code = -1, msg = "未登录" }; if (!IsLoggedIn) return new ProductListInfo() { code = -1, msg = "未登录" };
@@ -104,7 +104,7 @@ namespace tysdk
return result; return result;
#elif UNITY_ANDROID #elif UNITY_ANDROID
var taskSource = new TaskCompletionSource<ProductListInfo>(); var taskSource = new TaskCompletionSource<ProductListInfo>();
callbacks.Add("PayTypeResult", (ITYSdkCallback callback) => callbacks.Add("SKUListResult", (ITYSdkCallback callback) =>
{ {
taskSource.SetResult((ProductListInfo) callback); taskSource.SetResult((ProductListInfo) callback);
}); });
@@ -118,8 +118,9 @@ namespace tysdk
} }
//商品列表的回调 //商品列表的回调
public void PayTypeResult(string json) public void SKUListResult(string json)
{ {
Debug.Log("[TYSdkFacade] GetSKUList callback:");
var result = new ProductListInfo(); var result = new ProductListInfo();
var jresult = JObject.Parse(json); var jresult = JObject.Parse(json);
int code = int.Parse(jresult["code"].ToString()); int code = int.Parse(jresult["code"].ToString());
@@ -131,10 +132,10 @@ namespace tysdk
result.products = jsonObjList; result.products = jsonObjList;
} }
if (callbacks.TryGetValue("PayTypeResult", out var action)) if (callbacks.TryGetValue("SKUListResult", out var action))
{ {
action.Invoke(result); action.Invoke(result);
callbacks.Remove("PayTypeResult"); callbacks.Remove("SKUListResult");
} }
} }
} }

View File

@@ -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);