[M] sync from n3

This commit is contained in:
2024-08-22 18:04:52 +08:00
parent 1a0af9d725
commit da367097c8
8 changed files with 91 additions and 30 deletions

View File

@@ -41,9 +41,15 @@ namespace tysdk.editor
private static void XcodeOverwriteFiles(string projPath, PBXProject proj)
{
var mainAppPath = Path.Combine(projPath, "Classes", "Preprocessor.h");
var mainContent = File.ReadAllText(mainAppPath);
var newContent = mainContent.Replace("#define UNITY_USES_REMOTE_NOTIFICATIONS 0", "#define UNITY_USES_REMOTE_NOTIFICATIONS 1");
string mainAppPath = Path.Combine(projPath, "MainApp", "main.mm");
string mainContent = File.ReadAllText(mainAppPath);
string newContent = mainContent.Replace("#include <UnityFramework/UnityFramework.h>", @"#include ""../UnityFramework/UnityFramework.h""");
File.WriteAllText(mainAppPath, newContent);
mainAppPath = Path.Combine(projPath, "Classes", "Preprocessor.h");
mainContent = File.ReadAllText(mainAppPath);
newContent = mainContent.Replace("#define UNITY_USES_REMOTE_NOTIFICATIONS 0", "#define UNITY_USES_REMOTE_NOTIFICATIONS 1");
File.WriteAllText(mainAppPath, newContent);
}

View File

@@ -12,11 +12,21 @@ namespace tysdk
{
public class AccountInfo
{
#if UNITY_ANDROID
private static Dictionary<string, EAccoutType> accoutTypeMap = new Dictionary<string, EAccoutType>(){
{EAccoutType.hwGoogle.ToString(), EAccoutType.hwGoogle},
{EAccoutType.hwFacebook.ToString(), EAccoutType.hwFacebook},
{"tyGuest", EAccoutType.hwGuest}
};
#else
private static Dictionary<string, EAccoutType> accoutTypeMap = new Dictionary<string, EAccoutType>(){
{"google", EAccoutType.hwGoogle},
{"fb", EAccoutType.hwFacebook},
{"tyGuest", EAccoutType.hwGuest}
};
#endif
public int userId;
public string token;
@@ -128,7 +138,7 @@ namespace tysdk
=================================================*/
public bool IsLoggedIn => _accountInfo != null;
public static bool IsLoggedIn => _accountInfo != null;
public void Logout()
{
@@ -180,7 +190,7 @@ namespace tysdk
public async Task<LoginInfo> LoginByToken()
{
var accoutInfo = AccountInfo.GetSavedAccoutInfo();
if(accoutInfo == null) new LoginInfo();
if(accoutInfo == null) return new LoginInfo();
var taskSource = new TaskCompletionSource<LoginInfo>();
callbacks.Add("LoginResult", (ITYSdkCallback callback) =>

View File

@@ -1,5 +1,3 @@
using System;
using Newtonsoft.Json.Linq;
using UnityEngine;
namespace tysdk
@@ -38,14 +36,15 @@ namespace tysdk
GA_ABTest = 10, //abtest相关事件
}
/*
public class GAEvent : IDisposable
{
private GATrackType eventType;
private string eventName;
bool AFSend = true;
public static string ABTestValue = "0";
private JObject content = new JObject();
public static Dictionary<string, string> extraContent = new Dictionary<string, string>();
public GAEvent(GATrackType eventType, string eventName, bool AFSend = true)
{
@@ -57,8 +56,7 @@ namespace tysdk
public GAEvent AddContent(string key, string value)
{
content[key] = value;
return this;
}
return this; }
public GAEvent AddContent(string key, int value)
{
@@ -78,11 +76,40 @@ namespace tysdk
return this;
}
public GAEvent AddContent(string key, JToken value)
{
content[key] = value;
return this;
}
public void Dispose()
{
content["ABTestValue"] = ABTestValue;
TYSdkFacade.Instance.EventTrack((int)eventType, eventName, content.ToString());
foreach (var item in extraContent)
{
content[item.Key] = item.Value;
}
string msg = content.ToString();
if (msg == String.Empty) return;
if (AFSend)
{
SendAfEvent(eventType,eventName,msg);
}
TYSdkFacade.Instance.EventTrack((int)eventType, eventName, msg);
content.RemoveAll();
}
private void SendAfEvent(GATrackType type,string eventName,string logMessage)
{
Dictionary<string, string> eventValues = new Dictionary<string, string>();
eventValues.Add("GA_TYPE", type.ToString());
eventValues.Add(eventName, logMessage);
AppsFlyer.sendEvent(AFInAppEvents.GA, eventValues);
}
*/
/*
*GA_TRACK默认类型
@@ -98,6 +125,7 @@ namespace tysdk
*GA_PROFILE设置用户特征
*/
//TOD SDK
/*
public static GAEvent TackEvent(string eventName, bool afSend = true)
{
return new GAEvent(GATrackType.GA_TRACK, eventName, afSend);
@@ -128,4 +156,5 @@ namespace tysdk
return new GAEvent(GATrackType.GA_LOGIN, eventName, afSend);
}
}
}
*/
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Linq;
@@ -58,10 +58,11 @@ namespace tysdk
return new SKUDetail() {
price = x["price"].ToString(),
productId = x["productId"].ToString(),
LocaleCurrencyCode = x["LocaleCurrencyCode"].ToString(),
price_currency_code = x["LocaleCurrencyCode"].ToString(),
localeCurrencySymbol = x["localeCurrencySymbol"].ToString(),
localizedDescription = x["localizedDescription"].ToString(),
title = x["localizedTitle"].ToString()
title = x["localizedTitle"].ToString(),
ProdKey = x["productIdentifier"].ToString()
};
}).ToList();
products = prodList;
@@ -90,13 +91,14 @@ namespace tysdk
public string ProdPriceStr => price;
public float ProdPrice => float.Parse(price_amount_micros) / 1000000;
public string ProdID => ourProductId;
public string ProdKey => productId;
}
#elif UNITY_IOS
public class SKUDetail
{
public string price;
public string productId;
public string LocaleCurrencyCode;
public string price_currency_code;
public string localeCurrencySymbol;
public string localizedDescription;
public string title;
@@ -105,6 +107,7 @@ namespace tysdk
public string ProdPriceStr => price;
public float ProdPrice => float.Parse(price);
public string ProdID => productId;
public string ProdKey;
public override string ToString()
{

View File

@@ -1,9 +1,7 @@
{
"name": "tysdk",
"rootNamespace": "tysdk",
"references": [
"GUID:2a37df438292d4903b4e5159c5de3bf9"
],
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,