diff --git a/AntiAddiction/AntiAddiction.uplugin b/AntiAddiction/AntiAddiction.uplugin index 84278a1..a0221f1 100644 --- a/AntiAddiction/AntiAddiction.uplugin +++ b/AntiAddiction/AntiAddiction.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 31605001, - "VersionName": "3.17.0", + "Version": 31800001, + "VersionName": "3.18.0", "FriendlyName": "AntiAddiction", "Description": "", "Category": "TapTap", diff --git a/AntiAddiction/Content/AAUBackView.uasset b/AntiAddiction/Content/AAUBackView.uasset index adae6dc..5fbe4b0 100644 Binary files a/AntiAddiction/Content/AAUBackView.uasset and b/AntiAddiction/Content/AAUBackView.uasset differ diff --git a/AntiAddiction/Source/AntiAddiction/AntiAddiction_Android_UPL.xml b/AntiAddiction/Source/AntiAddiction/AntiAddiction_Android_UPL.xml index 7db766d..a67c846 100644 --- a/AntiAddiction/Source/AntiAddiction/AntiAddiction_Android_UPL.xml +++ b/AntiAddiction/Source/AntiAddiction/AntiAddiction_Android_UPL.xml @@ -18,8 +18,8 @@ -dependencies.implementation(name: 'AntiAddiction_3.17.0',ext:'aar') -dependencies.implementation(name: 'AntiAddictionUI_3.17.0',ext:'aar') +dependencies.implementation(name: 'AntiAddiction_3.18.0',ext:'aar') +dependencies.implementation(name: 'AntiAddictionUI_3.18.0',ext:'aar') diff --git a/AntiAddiction/Source/AntiAddiction/Public/AntiAddiction.h b/AntiAddiction/Source/AntiAddiction/Public/AntiAddiction.h index 57eba7b..2642df3 100644 --- a/AntiAddiction/Source/AntiAddiction/Public/AntiAddiction.h +++ b/AntiAddiction/Source/AntiAddiction/Public/AntiAddiction.h @@ -4,8 +4,8 @@ #include "Modules/ModuleManager.h" -#define AntiAddictionUE_VERSION_NUMBER "31700001" -#define AntiAddictionUE_VERSION "3.17.0" +#define AntiAddictionUE_VERSION_NUMBER "31800001" +#define AntiAddictionUE_VERSION "3.18.0" class FAntiAddictionModule : public IModuleInterface { diff --git a/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddictionUI_3.17.0.aar b/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddictionUI_3.17.0.aar deleted file mode 100644 index 168a44c..0000000 Binary files a/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddictionUI_3.17.0.aar and /dev/null differ diff --git a/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddictionUI_3.18.0.aar b/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddictionUI_3.18.0.aar new file mode 100644 index 0000000..47bbc31 Binary files /dev/null and b/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddictionUI_3.18.0.aar differ diff --git a/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddiction_3.17.0.aar b/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddiction_3.18.0.aar similarity index 96% rename from AntiAddiction/Source/ThirdParty/Android/libs/AntiAddiction_3.17.0.aar rename to AntiAddiction/Source/ThirdParty/Android/libs/AntiAddiction_3.18.0.aar index ca76531..9f005ed 100644 Binary files a/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddiction_3.17.0.aar and b/AntiAddiction/Source/ThirdParty/Android/libs/AntiAddiction_3.18.0.aar differ diff --git a/AntiAddiction/Source/ThirdParty/iOS/Frameworks/AntiAddictionService.zip b/AntiAddiction/Source/ThirdParty/iOS/Frameworks/AntiAddictionService.zip index d3da911..585a7fe 100644 Binary files a/AntiAddiction/Source/ThirdParty/iOS/Frameworks/AntiAddictionService.zip and b/AntiAddiction/Source/ThirdParty/iOS/Frameworks/AntiAddictionService.zip differ diff --git a/AntiAddiction/Source/ThirdParty/iOS/Frameworks/AntiAddictionUI.zip b/AntiAddiction/Source/ThirdParty/iOS/Frameworks/AntiAddictionUI.zip index bafc2a2..86b9af8 100644 Binary files a/AntiAddiction/Source/ThirdParty/iOS/Frameworks/AntiAddictionUI.zip and b/AntiAddiction/Source/ThirdParty/iOS/Frameworks/AntiAddictionUI.zip differ diff --git a/LeanCloud/Source/LeanCloud/LeanCloud.Build.cs b/LeanCloud/Source/LeanCloud/LeanCloud.Build.cs index 864c2f5..d7a3500 100644 --- a/LeanCloud/Source/LeanCloud/LeanCloud.Build.cs +++ b/LeanCloud/Source/LeanCloud/LeanCloud.Build.cs @@ -41,6 +41,7 @@ public LeanCloud(ReadOnlyTargetRules Target) : base(Target) "SlateCore", "Json", "JsonUtilities", + "HTTP", // ... add private dependencies that you statically link with here ... } ); diff --git a/LeanCloud/Source/LeanCloud/LeanCloud_Android_UPL.xml b/LeanCloud/Source/LeanCloud/LeanCloud_Android_UPL.xml index e30bb75..b7c81e4 100644 --- a/LeanCloud/Source/LeanCloud/LeanCloud_Android_UPL.xml +++ b/LeanCloud/Source/LeanCloud/LeanCloud_Android_UPL.xml @@ -53,8 +53,8 @@ -dependencies.implementation('cn.leancloud:realtime-android:8.2.2') -dependencies.implementation('cn.leancloud:storage-android:8.2.7') +dependencies.implementation('cn.leancloud:realtime-android:8.2.17') +dependencies.implementation('cn.leancloud:storage-android:8.2.17') dependencies.implementation('io.reactivex.rxjava2:rxandroid:2.1.1') diff --git a/LeanCloud/Source/LeanCloud/Private/LCUser.cpp b/LeanCloud/Source/LeanCloud/Private/LCUser.cpp index b1c85e9..7952af1 100644 --- a/LeanCloud/Source/LeanCloud/Private/LCUser.cpp +++ b/LeanCloud/Source/LeanCloud/Private/LCUser.cpp @@ -12,6 +12,13 @@ FString FLCUser::KeyAuthDataAnonymous = "anonymous"; FString FLCUser::KeySessionToken = "sessionToken"; FString FLCUser::CLASS_NAME = "_User"; +FString GetSyncString() +{ + const int64 Ticks = FDateTime::UtcNow().ToUnixTimestamp() * 1000; + const FString TimeStr = FString::Printf(TEXT("%010lld"), Ticks); + return FMD5::HashAnsiString(*(TimeStr + FLCConfig::Get().ClientToken)) + TEXT(",") + TimeStr; +} + FLCUser::FLCUser(TSharedPtr InServerData): FLCObject(CLASS_NAME, InServerData) { } @@ -51,6 +58,54 @@ bool FLCUser::IsAuthenticated() const { return !GetSessionToken().IsEmpty(); } +void FLCUser::RetrieveShortToken(const FStringSignature& OnSuccess, const FLCError::FDelegate& OnFailed) +{ + if (TSharedPtr Error = FLCConfig::Get().CheckConfig()) + { + OnFailed.ExecuteIfBound(*Error); + return; + } + const TSharedRef HttpRequest = FHttpModule::Get().CreateRequest(); + HttpRequest->SetVerb(TEXT("GET")); + + FString Url = FLCConfig::Get().ServerURL + TEXT("/storage/1.1/users/tap-support/identity"); + HttpRequest->SetURL(Url); + + HttpRequest->SetHeader(TEXT("X-LC-Id"), FLCConfig::Get().ClientID); + HttpRequest->SetHeader(TEXT("X-LC-Sign"), GetSyncString()); + HttpRequest->SetHeader(TEXT("X-LC-Session"), GetSessionToken()); + HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json")); + + HttpRequest->OnProcessRequestComplete().BindSP(this, &FLCUser::OnRetrieveShortTokenCallback, OnSuccess, OnFailed); + + if (!HttpRequest->ProcessRequest()) + { + OnFailed.ExecuteIfBound(FLCError(-1, TEXT("Net Error. http send failed."))); + } +} + +void FLCUser::OnRetrieveShortTokenCallback(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bConnectedSuccessfully, FStringSignature OnSuccess, FLCError::FDelegate OnError) +{ + if (bConnectedSuccessfully && Response && EHttpResponseCodes::IsOk(Response->GetResponseCode())) + { + FString ContentString = Response->GetContentAsString(); + TSharedPtr JsonObject; + const TSharedRef> JsonReader = TJsonReaderFactory<>::Create(ContentString); + if (FJsonSerializer::Deserialize(JsonReader, JsonObject) && JsonObject.IsValid()) + { + FString Token; + if (JsonObject->TryGetStringField(TEXT("identityToken"), Token)) + { + OnSuccess.ExecuteIfBound(Token); + return; + } + } + OnError.ExecuteIfBound(FLCError(-1, FString::Printf(TEXT("Net Error, http response content:%s."), *ContentString))); + return; + } + OnError.ExecuteIfBound(FLCError(-1, TEXT("Net Error, Http failed."))); +} + TSharedPtr FLCUser::GetAuthData() const { const TSharedPtr * TempPtr = nullptr; ServerData->TryGetObjectField(KeyAuthData, TempPtr); diff --git a/LeanCloud/Source/LeanCloud/Private/LeanCloudImpl.cpp b/LeanCloud/Source/LeanCloud/Private/LeanCloudImpl.cpp index 0e4045e..f7efac2 100644 --- a/LeanCloud/Source/LeanCloud/Private/LeanCloudImpl.cpp +++ b/LeanCloud/Source/LeanCloud/Private/LeanCloudImpl.cpp @@ -1,4 +1,5 @@ #include "LeanCloudImpl.h" + #include "Tools/LCDebuger.h" #if PLATFORM_IOS @@ -12,7 +13,8 @@ typedef FLeanCloud_iOS LeanCloud; typedef FLeanCloud_Android LeanCloud; #else -typedef FLeanCloudImpl LeanCloud; +#include "PC/LeanCloud_PC.h" +typedef FLeanCloud_PC LeanCloud; #endif #define UnsupportedPlatformsLog LCDebuger::ErrorLog(FString::Printf(TEXT("LeanCloud Unsupported Platforms Call %s"), ANSI_TO_TCHAR(__FUNCTION__))); diff --git a/LeanCloud/Source/LeanCloud/Private/LeanCloudType.cpp b/LeanCloud/Source/LeanCloud/Private/LeanCloudType.cpp index 4e637b1..cf1499d 100644 --- a/LeanCloud/Source/LeanCloud/Private/LeanCloudType.cpp +++ b/LeanCloud/Source/LeanCloud/Private/LeanCloudType.cpp @@ -1 +1,24 @@ #include "LeanCloudType.h" + +FLCConfig FLCConfig::Instance; +FLCConfig& FLCConfig::Get() +{ + return Instance; +} + +TSharedPtr FLCConfig::CheckConfig() const +{ + if (ClientID.IsEmpty()) + { + return MakeShared(-1, TEXT("ClientID is empty.")); + } + if (ClientToken.IsEmpty()) + { + return MakeShared(-1, TEXT("ClientToken is empty.")); + } + if (ServerURL.IsEmpty()) + { + return MakeShared(-1, TEXT("ServerURL is empty.")); + } + return nullptr; +} diff --git a/LeanCloud/Source/LeanCloud/Private/PC/LeanCloud_PC.cpp b/LeanCloud/Source/LeanCloud/Private/PC/LeanCloud_PC.cpp new file mode 100644 index 0000000..cbb9b94 --- /dev/null +++ b/LeanCloud/Source/LeanCloud/Private/PC/LeanCloud_PC.cpp @@ -0,0 +1,15 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "LeanCloud_PC.h" + + +FLeanCloud_PC::FLeanCloud_PC() +{ +} + +void FLeanCloud_PC::Init(const FLCConfig& InConfig) +{ + FLCConfig::Get() = InConfig; +} + diff --git a/LeanCloud/Source/LeanCloud/Private/PC/LeanCloud_PC.h b/LeanCloud/Source/LeanCloud/Private/PC/LeanCloud_PC.h new file mode 100644 index 0000000..5cae41d --- /dev/null +++ b/LeanCloud/Source/LeanCloud/Private/PC/LeanCloud_PC.h @@ -0,0 +1,17 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "LeanCloudImpl.h" + +/** + * + */ +class LEANCLOUD_API FLeanCloud_PC : public FLeanCloudImpl +{ +public: + FLeanCloud_PC(); + virtual void Init(const FLCConfig& InConfig) override; + +}; diff --git a/LeanCloud/Source/LeanCloud/Public/LCObject.h b/LeanCloud/Source/LeanCloud/Public/LCObject.h index 29de5be..055cc8c 100644 --- a/LeanCloud/Source/LeanCloud/Public/LCObject.h +++ b/LeanCloud/Source/LeanCloud/Public/LCObject.h @@ -1,10 +1,10 @@ #pragma once -struct LEANCLOUD_API FLCObject { +struct LEANCLOUD_API FLCObject : public TSharedFromThis{ public: FLCObject(const FString& InClassName, TSharedPtr InServerData = nullptr); - ~FLCObject(); + virtual ~FLCObject(); static FLCObject CreateWithoutData(const FString& InClassName, const FString& ObjectId); diff --git a/LeanCloud/Source/LeanCloud/Public/LCUser.h b/LeanCloud/Source/LeanCloud/Public/LCUser.h index 38d720f..1e723f7 100644 --- a/LeanCloud/Source/LeanCloud/Public/LCUser.h +++ b/LeanCloud/Source/LeanCloud/Public/LCUser.h @@ -1,5 +1,8 @@ #pragma once +#include "LCError.h" #include "LCObject.h" +#include "Http.h" +#include "LeanCloudType.h" struct LEANCLOUD_API FLCUser: public FLCObject { public: @@ -13,6 +16,7 @@ struct LEANCLOUD_API FLCUser: public FLCObject { bool IsAnonymous() const; bool IsMobilePhoneVerified() const; bool IsAuthenticated() const; + virtual void RetrieveShortToken(const FStringSignature& OnSuccess, const FLCError::FDelegate& OnFailed); protected: static FString KeyUserName; @@ -25,5 +29,7 @@ struct LEANCLOUD_API FLCUser: public FLCObject { static FString KeySessionToken; static FString CLASS_NAME; + void OnRetrieveShortTokenCallback(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bConnectedSuccessfully, FStringSignature OnSuccess, FLCError::FDelegate OnError); + TSharedPtr GetAuthData() const; }; diff --git a/LeanCloud/Source/LeanCloud/Public/LeanCloudType.h b/LeanCloud/Source/LeanCloud/Public/LeanCloudType.h index 8e32e7f..ceedfa3 100644 --- a/LeanCloud/Source/LeanCloud/Public/LeanCloudType.h +++ b/LeanCloud/Source/LeanCloud/Public/LeanCloudType.h @@ -1,4 +1,5 @@ #pragma once +#include "LCError.h" #include "LeanCloudType.generated.h" @@ -15,4 +16,11 @@ struct LEANCLOUD_API FLCConfig { UPROPERTY(EditAnywhere, BlueprintReadWrite) FString ServerURL; + static FLCConfig& Get(); + + TSharedPtr CheckConfig() const; +protected: + static FLCConfig Instance; }; + +DECLARE_DELEGATE_OneParam(FStringSignature, const FString&); diff --git a/LeanCloud/Source/ThirdParty/iOS/Frameworks/LeanCloudObjc.zip b/LeanCloud/Source/ThirdParty/iOS/Frameworks/LeanCloudObjc.zip index df926c2..c0b2480 100644 Binary files a/LeanCloud/Source/ThirdParty/iOS/Frameworks/LeanCloudObjc.zip and b/LeanCloud/Source/ThirdParty/iOS/Frameworks/LeanCloudObjc.zip differ diff --git a/TapBillboard/Source/TapBillboard/Public/TapBillboardModule.h b/TapBillboard/Source/TapBillboard/Public/TapBillboardModule.h index 0408709..c962247 100644 --- a/TapBillboard/Source/TapBillboard/Public/TapBillboardModule.h +++ b/TapBillboard/Source/TapBillboard/Public/TapBillboardModule.h @@ -7,8 +7,8 @@ struct FTUConfig; typedef TSharedPtr FTapBillboardPtr; -#define TapBillboard_VERSION_NUMBER "31700001" -#define TapBillboard_VERSION "3.17.0" +#define TapBillboard_VERSION_NUMBER "31800001" +#define TapBillboard_VERSION "3.18.0" class TAPBILLBOARD_API FTapBillboardModule : public IModuleInterface { diff --git a/TapBillboard/Source/TapBillboard/TapBillboard_Android_UPL.xml b/TapBillboard/Source/TapBillboard/TapBillboard_Android_UPL.xml index d58c6d6..484528b 100644 --- a/TapBillboard/Source/TapBillboard/TapBillboard_Android_UPL.xml +++ b/TapBillboard/Source/TapBillboard/TapBillboard_Android_UPL.xml @@ -14,7 +14,7 @@ - dependencies.implementation(name: 'TapBillboard_3.17.0',ext:'aar') + dependencies.implementation(name: 'TapBillboard_3.18.0',ext:'aar') diff --git a/TapBillboard/Source/ThirdParty/Android/libs/TapBillboard_3.17.0.aar b/TapBillboard/Source/ThirdParty/Android/libs/TapBillboard_3.17.0.aar deleted file mode 100644 index d60cb70..0000000 Binary files a/TapBillboard/Source/ThirdParty/Android/libs/TapBillboard_3.17.0.aar and /dev/null differ diff --git a/TapBillboard/Source/ThirdParty/Android/libs/TapBillboard_3.18.0.aar b/TapBillboard/Source/ThirdParty/Android/libs/TapBillboard_3.18.0.aar new file mode 100644 index 0000000..88633c8 Binary files /dev/null and b/TapBillboard/Source/ThirdParty/Android/libs/TapBillboard_3.18.0.aar differ diff --git a/TapBillboard/Source/ThirdParty/iOS/Frameworks/TapBillboardSDK.zip b/TapBillboard/Source/ThirdParty/iOS/Frameworks/TapBillboardSDK.zip index 3339088..b31cb2f 100644 Binary files a/TapBillboard/Source/ThirdParty/iOS/Frameworks/TapBillboardSDK.zip and b/TapBillboard/Source/ThirdParty/iOS/Frameworks/TapBillboardSDK.zip differ diff --git a/TapBillboard/TapBillboard.uplugin b/TapBillboard/TapBillboard.uplugin index 1ba3149..3927325 100644 --- a/TapBillboard/TapBillboard.uplugin +++ b/TapBillboard/TapBillboard.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 31602001, - "VersionName": "3.17.0", + "Version": 31800001, + "VersionName": "3.18.0", "FriendlyName": "TapBillboard", "Description": "TapTap Billboard", "Category": "TapTap", diff --git a/TapBootstrap/Source/TapBootstrap/Private/Android/Java/TapBootstrapUE.java b/TapBootstrap/Source/TapBootstrap/Private/Android/Java/TapBootstrapUE.java index 43b440f..6fd33d4 100644 --- a/TapBootstrap/Source/TapBootstrap/Private/Android/Java/TapBootstrapUE.java +++ b/TapBootstrap/Source/TapBootstrap/Private/Android/Java/TapBootstrapUE.java @@ -22,6 +22,7 @@ import java.util.Set; import cn.leancloud.LCUser; +import cn.leancloud.json.JSONObject; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; @@ -30,7 +31,7 @@ public static void init(Activity activity, String clientID, String clientToken, Handler mainHandler = new Handler(Looper.getMainLooper()); mainHandler.post(new Runnable() { @Override - public void run() { + public void run() { TapDBConfig dbConfig = new TapDBConfig(); dbConfig.setEnable(dbEnable); dbConfig.setChannel(channel); @@ -42,24 +43,24 @@ public void run() { .withClientToken(clientToken) .withRegionType(isCN ? TapRegionType.CN : TapRegionType.IO) .withTapDBConfig(dbConfig); - + if(billboardEnable){ Set> dimensionSet = new HashSet<>(); for (int i = 0; i < dimensionString.length; i += 2) { dimensionSet.add(Pair.create(dimensionString[i], dimensionString[i+1])); } - + TapBillboardConfig billboardConfig = new TapBillboardConfig.Builder() - .withDimensionSet(dimensionSet) + .withDimensionSet(dimensionSet) .withServerUrl(billboardUrl) .build(); - + builder.withBillboardConfig(billboardConfig); } - + TapConfig tapConfig = builder.build(); - + TapBootstrap.init(activity, tapConfig); } }); @@ -217,7 +218,7 @@ public void onComplete() { public static void save(TDSUser user) { user.saveInBackground(); } - + public static void queryTapFriendsLeaderBoard(String name, int from, int limit, int callBackID) { TDSLeaderBoardRanking.queryTapFriendsLeaderBoard(name, from, limit, new Callback>() { @Override @@ -231,13 +232,42 @@ public void onFail(TapError error) { } }); } - + + public static void retrieveShortToken(String sessionToken, int callBackID) { + TDSUser.retrieveShortTokenInBackground(sessionToken).subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(JSONObject jsonObject) { + String credential = jsonObject.getString("identityToken"); + onRetrieveShortTokenSuccess(credential, callBackID); + } + + @Override + public void onError(Throwable error) { + onRetrieveShortTokenError(-1, error.toString(), callBackID); + } + + @Override + public void onComplete() { + + } + }); + } + public native void onUserError(int code, String Message, int callBackID); public native void onUserSuccess(TDSUser user, int callBackID); - + public native void onRankingsError(int code, String Message, int callBackID); public native void onRankingsSuccess(List result, int callBackID); + public native static void onRetrieveShortTokenError(int code, String Message, int callBackID); + + public native static void onRetrieveShortTokenSuccess(String credential, int callBackID); + } diff --git a/TapBootstrap/Source/TapBootstrap/Private/Android/TapBootstrapImplAndroid.cpp b/TapBootstrap/Source/TapBootstrap/Private/Android/TapBootstrapImplAndroid.cpp index 6d16931..d173302 100644 --- a/TapBootstrap/Source/TapBootstrap/Private/Android/TapBootstrapImplAndroid.cpp +++ b/TapBootstrap/Source/TapBootstrap/Private/Android/TapBootstrapImplAndroid.cpp @@ -9,8 +9,11 @@ typedef TTuple UserResultDelegate; typedef TTuple RankingsResultDelegate; +typedef TTuple RetrieveShortTokenDelegate; TMap UserResultCallBacks; TMap RankingsResultCallBacks; +TMap RetrieveShortTokenCallBacks; + #define TapBootstrapUE "com/tds/TapBootstrapUE" @@ -30,18 +33,24 @@ void FTapBootstrapImplAndroid::Init(const FTUConfig& InConfig) { bool IsCN = InConfig.RegionType == ERegionType::CN; bool DBConfigEnable = InConfig.DBConfig.Enable; bool bBillboardEnable = InConfig.BillboardConfig.IsValid(); - auto jBillboardUrl = JNI.ToJavaString(InConfig.BillboardConfig->BillboardUrl); + if (bBillboardEnable) { + auto jBillboardUrl = JNI.ToJavaString(InConfig.BillboardConfig->BillboardUrl); - JNIEnv* JEnv = *JNI; + JNIEnv* JEnv = *JNI; - auto jDimensionString = NewScopedJavaObject(JEnv, (jobjectArray)JEnv->NewObjectArray(InConfig.BillboardConfig->Dimensions.Num() * 2, FJavaWrapper::JavaStringClass, nullptr)); - int32 Index = 0; - for (TTuple& T : InConfig.BillboardConfig->Dimensions) - { - JEnv->SetObjectArrayElement(*jDimensionString, Index++, *FJavaHelper::ToJavaString(JEnv, T.Key)); - JEnv->SetObjectArrayElement(*jDimensionString, Index++, *FJavaHelper::ToJavaString(JEnv, T.Value)); + auto jDimensionString = NewScopedJavaObject(JEnv, (jobjectArray)JEnv->NewObjectArray(InConfig.BillboardConfig->Dimensions.Num() * 2, FJavaWrapper::JavaStringClass, nullptr)); + int32 Index = 0; + for (TTuple& T : InConfig.BillboardConfig->Dimensions) + { + JEnv->SetObjectArrayElement(*jDimensionString, Index++, *FJavaHelper::ToJavaString(JEnv, T.Key)); + JEnv->SetObjectArrayElement(*jDimensionString, Index++, *FJavaHelper::ToJavaString(JEnv, T.Value)); + } + JNI.CallStaticVoidMethod(ClassObject, "init", "(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ljava/lang/String;ZLjava/lang/String;[Ljava/lang/String;)V", *Activity, *ClientID, *ClientToken, *ServerURL, IsCN, DBConfigEnable, *Channel, *GameVersion, bBillboardEnable, *jBillboardUrl, *jDimensionString); + } else { + JNI.CallStaticVoidMethod(ClassObject, "init", "(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ljava/lang/String;ZLjava/lang/String;[Ljava/lang/String;)V", *Activity, *ClientID, *ClientToken, *ServerURL, IsCN, DBConfigEnable, *Channel, *GameVersion, bBillboardEnable, NULL, NULL); } - JNI.CallStaticVoidMethod(ClassObject, "init", "(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/lang/String;Ljava/lang/String;ZLjava/lang/String;[Ljava/lang/String;)V", *Activity, *ClientID, *ClientToken, *ServerURL, IsCN, DBConfigEnable, *Channel, *GameVersion, bBillboardEnable, *jBillboardUrl, *jDimensionString); + + } TSharedPtr FTapBootstrapImplAndroid::GetCurrentUser() { @@ -149,6 +158,18 @@ void FTapBootstrapImplAndroid::QueryTapFriendsLeaderBoard(const FString& Name, i *JNI.ToJavaString(Name), From, Limit, InCallBackID); } +void FTapBootstrapImplAndroid::RetrieveShortToken(const FLCUser& InUser, const FStringSignature& OnSuccess, + const FLCError::FDelegate& OnFailed) { + int InCallBackID = GetCallBackID(); + RetrieveShortTokenCallBacks.Add(InCallBackID, MakeTuple(OnSuccess, OnFailed)); + + TapJNI::JNI JNI; + auto ClassObject = JNI.FindClass(TapBootstrapUE); + JNI.CallStaticVoidMethod(ClassObject, "retrieveShortToken", + "(Ljava/lang/String;I)V", + *JNI.ToJavaString(InUser.GetSessionToken()), InCallBackID); +} + int FTapBootstrapImplAndroid::GetCallBackID() { return CallBackID++; @@ -237,6 +258,36 @@ extern "C" { }); } + __attribute__((visibility("default"))) void Java_com_tds_TapBootstrapUE_onRetrieveShortTokenSuccess(JNIEnv *jenv, jclass thiz, jstring credential, int callBackID) + { + auto CallBackPtr = RetrieveShortTokenCallBacks.Find(callBackID); + if (CallBackPtr == nullptr) { + return; + } + TapJNI::JNI JNI(jenv); + FString Credential = JNI.GetFStringFromParam(credential); + FStringSignature CallBack = (*CallBackPtr).Get<0>(); + TUHelper::PerformOnGameThread([=]() { + CallBack.ExecuteIfBound(Credential); + RetrieveShortTokenCallBacks.Remove(callBackID); + }); + } + + __attribute__((visibility("default"))) void Java_com_tds_TapBootstrapUE_onRetrieveShortTokenError(JNIEnv* jenv, jclass thiz, jint code, jstring Message, jint callBackID) { + auto CallBackPtr = RetrieveShortTokenCallBacks.Find(callBackID); + if (CallBackPtr == nullptr) { + return; + } + TapJNI::JNI JNI(jenv); + FString Msg_UE = JNI.GetFStringFromParam(Message); + FLCError Error(code, Msg_UE); + FLCError::FDelegate CallBack = (*CallBackPtr).Get<1>(); + TUHelper::PerformOnGameThread([=]() { + CallBack.ExecuteIfBound(Error); + RetrieveShortTokenCallBacks.Remove(callBackID); + }); + } + #ifdef __cplusplus } diff --git a/TapBootstrap/Source/TapBootstrap/Private/Android/TapBootstrapImplAndroid.h b/TapBootstrap/Source/TapBootstrap/Private/Android/TapBootstrapImplAndroid.h index bdbb79b..d312a11 100644 --- a/TapBootstrap/Source/TapBootstrap/Private/Android/TapBootstrapImplAndroid.h +++ b/TapBootstrap/Source/TapBootstrap/Private/Android/TapBootstrapImplAndroid.h @@ -21,6 +21,8 @@ class FTapBootstrapImplAndroid: public FTapBootstrapImpl{ virtual void SaveUser(const FTDSUser& InUser) override; virtual void QueryTapFriendsLeaderBoard(const FString& Name, int From, int Limit, FTDSLeaderBoardRanking::FRankingsDelegate OnSuccess, FTUError::FDelegate OnError) override; + virtual void RetrieveShortToken(const FLCUser& InUser, const FStringSignature& OnSuccess, + const FLCError::FDelegate& OnFailed) override; private: int CallBackID = 0; int GetCallBackID(); diff --git a/TapBootstrap/Source/TapBootstrap/Private/IOS/TapBootstrapImpliOS.cpp b/TapBootstrap/Source/TapBootstrap/Private/IOS/TapBootstrapImpliOS.cpp index d26ea1f..c8a1fd3 100644 --- a/TapBootstrap/Source/TapBootstrap/Private/IOS/TapBootstrapImpliOS.cpp +++ b/TapBootstrap/Source/TapBootstrap/Private/IOS/TapBootstrapImpliOS.cpp @@ -245,3 +245,22 @@ void FTapBootstrapImpliOS::QueryTapFriendsLeaderBoard(const FString& Name, int F } }]; } + +void FTapBootstrapImpliOS::RetrieveShortToken(const FLCUser& InUser, const FStringSignature& OnSuccess, + const FLCError::FDelegate& OnFailed) { + FStringSignature OnSuccess_UE = OnSuccess; + FLCError::FDelegate OnFailed_UE = OnFailed; + [TDSUser retrieveShortTokenWithCallback:^(NSString *_Nullable jwt, NSError *_Nullable error) { + if (error) { + FLCError Error = FLCError(error.code, IOSHelper::Convert(error.localizedDescription)); + TUHelper::PerformOnGameThread([=]() { + OnFailed_UE.ExecuteIfBound(Error); + }); + } else { + FString JWT = IOSHelper::Convert(jwt); + TUHelper::PerformOnGameThread([=]() { + OnSuccess_UE.ExecuteIfBound(JWT); + }); + } + }]; +} diff --git a/TapBootstrap/Source/TapBootstrap/Private/IOS/TapBootstrapImpliOS.h b/TapBootstrap/Source/TapBootstrap/Private/IOS/TapBootstrapImpliOS.h index 3dc2cf4..03bcdd8 100644 --- a/TapBootstrap/Source/TapBootstrap/Private/IOS/TapBootstrapImpliOS.h +++ b/TapBootstrap/Source/TapBootstrap/Private/IOS/TapBootstrapImpliOS.h @@ -21,4 +21,6 @@ class FTapBootstrapImpliOS: public FTapBootstrapImpl{ virtual void SaveUser(const FTDSUser& InUser) override; virtual void QueryTapFriendsLeaderBoard(const FString& Name, int From, int Limit, FTDSLeaderBoardRanking::FRankingsDelegate OnSuccess, FTUError::FDelegate OnError) override; + virtual void RetrieveShortToken(const FLCUser& InUser, const FStringSignature& OnSuccess, + const FLCError::FDelegate& OnFailed) override; }; diff --git a/TapBootstrap/Source/TapBootstrap/Private/TDSUser.cpp b/TapBootstrap/Source/TapBootstrap/Private/TDSUser.cpp index 08327be..e058c6b 100644 --- a/TapBootstrap/Source/TapBootstrap/Private/TDSUser.cpp +++ b/TapBootstrap/Source/TapBootstrap/Private/TDSUser.cpp @@ -60,6 +60,15 @@ void FTDSUser::DisassociateAuthData(const FString& Platform, FDelegate OnSuccess FTapBootstrapImpl::Get()->DisassociateAuthData(*this, Platform, OnSuccess, OnError); } +void FTDSUser::RetrieveShortToken(const FStringSignature& OnSuccess, const FLCError::FDelegate& OnFailed) { +#if PLATFORM_IOS || PLATFORM_ANDROID + FTapBootstrapImpl::Get()->RetrieveShortToken(*this, OnSuccess, OnFailed); +#else + FLCUser::RetrieveShortToken(OnSuccess, OnFailed); +#endif + +} + void FTDSUser::SaveUser() { FTapBootstrapImpl::Get()->SaveUser(*this); } diff --git a/TapBootstrap/Source/TapBootstrap/Private/TapBootstrapImpl.cpp b/TapBootstrap/Source/TapBootstrap/Private/TapBootstrapImpl.cpp index 18fae76..6036e3d 100644 --- a/TapBootstrap/Source/TapBootstrap/Private/TapBootstrapImpl.cpp +++ b/TapBootstrap/Source/TapBootstrap/Private/TapBootstrapImpl.cpp @@ -78,3 +78,8 @@ void FTapBootstrapImpl::QueryTapFriendsLeaderBoard(const FString& Name, int From FTDSLeaderBoardRanking::FRankingsDelegate OnSuccess, FTUError::FDelegate OnError) { UnsupportedPlatformsLog } + +void FTapBootstrapImpl::RetrieveShortToken(const FLCUser& InUser, const FStringSignature& OnSuccess, + const FLCError::FDelegate& OnFailed) { + UnsupportedPlatformsLog +} diff --git a/TapBootstrap/Source/TapBootstrap/Private/TapBootstrapImpl.h b/TapBootstrap/Source/TapBootstrap/Private/TapBootstrapImpl.h index c3a5330..cc24f14 100644 --- a/TapBootstrap/Source/TapBootstrap/Private/TapBootstrapImpl.h +++ b/TapBootstrap/Source/TapBootstrap/Private/TapBootstrapImpl.h @@ -32,6 +32,8 @@ class FTapBootstrapImpl { virtual void QueryTapFriendsLeaderBoard(const FString& Name, int From, int Limit, FTDSLeaderBoardRanking::FRankingsDelegate OnSuccess, FTUError::FDelegate OnError); + virtual void RetrieveShortToken(const FLCUser& InUser, const FStringSignature& OnSuccess, const FLCError::FDelegate& OnFailed); + private: static TSharedPtr Instance; }; diff --git a/TapBootstrap/Source/TapBootstrap/Public/TDSUser.h b/TapBootstrap/Source/TapBootstrap/Public/TDSUser.h index 928deea..e57e5fe 100644 --- a/TapBootstrap/Source/TapBootstrap/Public/TDSUser.h +++ b/TapBootstrap/Source/TapBootstrap/Public/TDSUser.h @@ -86,6 +86,8 @@ struct TAPBOOTSTRAP_API FTDSUser: public FLCUser */ void DisassociateAuthData(const FString& Platform, FDelegate OnSuccess, FTUError::FDelegate OnError); + virtual void RetrieveShortToken(const FStringSignature& OnSuccess, const FLCError::FDelegate& OnFailed) override; + protected: static FString KeyAvatar; diff --git a/TapBootstrap/Source/TapBootstrap/Public/TapBootstrapModule.h b/TapBootstrap/Source/TapBootstrap/Public/TapBootstrapModule.h index 147d1bd..81b565d 100644 --- a/TapBootstrap/Source/TapBootstrap/Public/TapBootstrapModule.h +++ b/TapBootstrap/Source/TapBootstrap/Public/TapBootstrapModule.h @@ -4,8 +4,8 @@ #include "Modules/ModuleManager.h" -#define TapUEBootstrap_VERSION_NUMBER "31700001" -#define TapUEBootstrap_VERSION "3.17.0" +#define TapUEBootstrap_VERSION_NUMBER "31800001" +#define TapUEBootstrap_VERSION "3.18.0" class TAPBOOTSTRAP_API FTapBootstrapModule : public IModuleInterface diff --git a/TapBootstrap/Source/TapBootstrap/TapBootstrap_Android_UPL.xml b/TapBootstrap/Source/TapBootstrap/TapBootstrap_Android_UPL.xml index a285a81..4c00b0d 100644 --- a/TapBootstrap/Source/TapBootstrap/TapBootstrap_Android_UPL.xml +++ b/TapBootstrap/Source/TapBootstrap/TapBootstrap_Android_UPL.xml @@ -19,7 +19,7 @@ -dependencies.implementation(name: 'TapBootstrap_3.17.0', ext:'aar') +dependencies.implementation(name: 'TapBootstrap_3.18.0', ext:'aar') dependencies.implementation('io.reactivex.rxjava2:rxandroid:2.1.1') diff --git a/TapBootstrap/Source/ThirdParty/Android/libs/TapBootstrap_3.17.0.aar b/TapBootstrap/Source/ThirdParty/Android/libs/TapBootstrap_3.17.0.aar deleted file mode 100644 index ab9cfe4..0000000 Binary files a/TapBootstrap/Source/ThirdParty/Android/libs/TapBootstrap_3.17.0.aar and /dev/null differ diff --git a/TapBootstrap/Source/ThirdParty/Android/libs/TapBootstrap_3.18.0.aar b/TapBootstrap/Source/ThirdParty/Android/libs/TapBootstrap_3.18.0.aar new file mode 100644 index 0000000..4a6a912 Binary files /dev/null and b/TapBootstrap/Source/ThirdParty/Android/libs/TapBootstrap_3.18.0.aar differ diff --git a/TapBootstrap/Source/ThirdParty/iOS/Frameworks/TapBootstrapSDK.zip b/TapBootstrap/Source/ThirdParty/iOS/Frameworks/TapBootstrapSDK.zip index f7c130e..f44b0dd 100644 Binary files a/TapBootstrap/Source/ThirdParty/iOS/Frameworks/TapBootstrapSDK.zip and b/TapBootstrap/Source/ThirdParty/iOS/Frameworks/TapBootstrapSDK.zip differ diff --git a/TapBootstrap/TapBootstrap.uplugin b/TapBootstrap/TapBootstrap.uplugin index bfa8e4d..e98942a 100644 --- a/TapBootstrap/TapBootstrap.uplugin +++ b/TapBootstrap/TapBootstrap.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 31605001, - "VersionName": "3.17.0", + "Version": 31800001, + "VersionName": "3.18.0", "FriendlyName": "TapBootstrap", "Description": "TapTap Bootstrap", "Category": "TapTap", diff --git a/TapCommon/Source/TapCommon/Private/android/TapJNI.cpp b/TapCommon/Source/TapCommon/Private/android/TapJNI.cpp index 6ef0f28..c4f4e51 100644 --- a/TapCommon/Source/TapCommon/Private/android/TapJNI.cpp +++ b/TapCommon/Source/TapCommon/Private/android/TapJNI.cpp @@ -25,10 +25,10 @@ namespace TapJNI { } if (Class == NULL) { - TUDebuger::ErrorLog(FString::Printf(TEXT("LCJNI Class: %s not found"), UTF8_TO_TCHAR(name))); + TUDebuger::ErrorLog(FString::Printf(TEXT("TapJNI Class: %s not found"), UTF8_TO_TCHAR(name))); } else { - TUDebuger::DisplayLog(FString::Printf(TEXT("LCJNI Class: %s"), UTF8_TO_TCHAR(name))); + TUDebuger::DisplayLog(FString::Printf(TEXT("TapJNI Class: %s"), UTF8_TO_TCHAR(name))); } return MakeScopedJavaObject(Env, Class); } @@ -38,28 +38,50 @@ namespace TapJNI { return MakeScopedJavaObject(Env, Class); } - jmethodID JNI::GetMethodID(const Class& Class, const char* methodName, const char* methodsig) const { - jmethodID methodID = Env->GetMethodID(*Class, methodName, methodsig); + jmethodID JNI::GetMethodID(const Class& Class, const char* name, const char* sig) const { + jmethodID methodID = Env->GetMethodID(*Class, name, sig); if (methodID == NULL) { - TUDebuger::ErrorLog(FString::Printf(TEXT("LCJNI Method: %s not found"), UTF8_TO_TCHAR(methodName))); + TUDebuger::ErrorLog(FString::Printf(TEXT("TapJNI GetMethodID: %s not found"), UTF8_TO_TCHAR(name))); } else { - TUDebuger::DisplayLog(FString::Printf(TEXT("LCJNI Method: %s"), UTF8_TO_TCHAR(methodName))); + TUDebuger::DisplayLog(FString::Printf(TEXT("TapJNI GetMethodID: %s"), UTF8_TO_TCHAR(name))); } return methodID; } - jmethodID JNI::GetStaticMethodID(const Class& Class, const char* methodName, const char* methodsig) const { - jmethodID methodID = Env->GetStaticMethodID(*Class, methodName, methodsig); + jmethodID JNI::GetStaticMethodID(const Class& Class, const char* name, const char* sig) const { + jmethodID methodID = Env->GetStaticMethodID(*Class, name, sig); if (methodID == NULL) { - TUDebuger::ErrorLog(FString::Printf(TEXT("LCJNI Method: %s not found"), UTF8_TO_TCHAR(methodName))); + TUDebuger::ErrorLog(FString::Printf(TEXT("TapJNI GetStaticMethodID: %s not found"), UTF8_TO_TCHAR(name))); } else { - TUDebuger::DisplayLog(FString::Printf(TEXT("LCJNI Method: %s"), UTF8_TO_TCHAR(methodName))); + TUDebuger::DisplayLog(FString::Printf(TEXT("TapJNI GetStaticMethodID: %s"), UTF8_TO_TCHAR(name))); } return methodID; } + jfieldID JNI::GetFieldID(const Class& Class, const char* name, const char* sig) const { + jfieldID fieldID = Env->GetFieldID(*Class, name, sig); + if (fieldID == NULL) { + TUDebuger::ErrorLog(FString::Printf(TEXT("TapJNI GetFieldID: %s not found"), UTF8_TO_TCHAR(name))); + } + else { + TUDebuger::DisplayLog(FString::Printf(TEXT("TapJNI GetFieldID: %s"), UTF8_TO_TCHAR(name))); + } + return fieldID; + } + + jfieldID JNI::GetStaticFieldID(const Class& Class, const char* name, const char* sig) const { + jfieldID fieldID = Env->GetStaticFieldID(*Class, name, sig); + if (fieldID == NULL) { + TUDebuger::ErrorLog(FString::Printf(TEXT("TapJNI GetStaticFieldID: %s not found"), UTF8_TO_TCHAR(name))); + } + else { + TUDebuger::DisplayLog(FString::Printf(TEXT("TapJNI GetStaticFieldID: %s"), UTF8_TO_TCHAR(name))); + } + return fieldID; + } + Object JNI::GetActivity() const { return MakeScopedJavaObject(Env, FAndroidApplication::GetGameActivityThis(), false); } @@ -94,11 +116,11 @@ namespace TapJNI { va_end(ap); if (resultObject == NULL) { TUDebuger::ErrorLog( - FString::Printf(TEXT("LCJNI NewObject: %s fail"), UTF8_TO_TCHAR(CtorSig))); + FString::Printf(TEXT("TapJNI NewObject: %s fail"), UTF8_TO_TCHAR(CtorSig))); } else { TUDebuger::DisplayLog( - FString::Printf(TEXT("LCJNI NewObject: %s success"), UTF8_TO_TCHAR(CtorSig))); + FString::Printf(TEXT("TapJNI NewObject: %s success"), UTF8_TO_TCHAR(CtorSig))); } return MakeScopedJavaObject(Env, resultObject); } @@ -113,11 +135,11 @@ namespace TapJNI { va_end(ap); if (resultObject == NULL) { TUDebuger::ErrorLog( - FString::Printf(TEXT("LCJNI Object Method: %s create object fail"), UTF8_TO_TCHAR(methodName))); + FString::Printf(TEXT("TapJNI Object Method: %s create object fail"), UTF8_TO_TCHAR(methodName))); } else { TUDebuger::DisplayLog( - FString::Printf(TEXT("LCJNI Object Method: %s create object success"), UTF8_TO_TCHAR(methodName))); + FString::Printf(TEXT("TapJNI Object Method: %s create object success"), UTF8_TO_TCHAR(methodName))); } return MakeScopedJavaObject(Env, resultObject); } @@ -219,11 +241,11 @@ namespace TapJNI { va_end(ap); if (resultObject == NULL) { TUDebuger::ErrorLog( - FString::Printf(TEXT("LCJNI Class Method: %s create object fail"), UTF8_TO_TCHAR(methodName))); + FString::Printf(TEXT("TapJNI Class Method: %s create object fail"), UTF8_TO_TCHAR(methodName))); } else { TUDebuger::DisplayLog( - FString::Printf(TEXT("LCJNI Class Method: %s create object success"), UTF8_TO_TCHAR(methodName))); + FString::Printf(TEXT("TapJNI Class Method: %s create object success"), UTF8_TO_TCHAR(methodName))); } return MakeScopedJavaObject(Env, resultObject); } @@ -305,6 +327,217 @@ namespace TapJNI { Env->CallStaticVoidMethodV(*Class, methodID, ap); va_end(ap); } + + void JNI::SetObjectField(const Object& object, const char* name, const char* sig, const Object& value) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, sig); + Env->SetObjectField(*object, fieldID, *value); + } + + void JNI::SetBooleanField(const Object& object, const char* name, bool value) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "Z"); + Env->SetBooleanField(*object, fieldID, value); + } + + void JNI::SetCharField(const Object& object, const char* name, char value) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "C"); + Env->SetCharField(*object, fieldID, value); + } + + void JNI::SetShortField(const Object& object, const char* name, short value) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "S"); + Env->SetShortField(*object, fieldID, value); + } + + void JNI::SetIntField(const Object& object, const char* name, int value) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "I"); + Env->SetIntField(*object, fieldID, value); + } + + void JNI::SetLongField(const Object& object, const char* name, long value) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "J"); + Env->SetLongField(*object, fieldID, value); + } + + void JNI::SetFloatField(const Object& object, const char* name, float value) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "F"); + Env->SetFloatField(*object, fieldID, value); + } + + void JNI::SetDoubleField(const Object& object, const char* name, double value) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "D"); + Env->SetDoubleField(*object, fieldID, value); + } + + void JNI::SetFStringField(const Object& object, const char* name, const FString& value) const { + SetObjectField(object, name, "Ljava/lang/String;", ToJavaString(value)); + } + + FString JNI::GetFStringField(const Object& object, const char* name) const { + return GetFString(GetObjectField(object, name, "Ljava/lang/String;")); + } + + void JNI::SetStaticFStringField(const Class& Class, const char* name, const FString& value) const { + SetStaticObjectField(Class, name, "Ljava/lang/String;", ToJavaString(value)); + } + + FString JNI::GetStaticFStringField(const Class& Class, const char* name) const { + return GetFString(GetStaticObjectField(Class, name, "Ljava/lang/String;")); + } + + Object JNI::GetObjectField(const Object& object, const char* name, const char* sig) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, sig); + jobject resultObject = Env->GetObjectField(*object, fieldID); + if (resultObject == NULL) { + TUDebuger::ErrorLog( + FString::Printf(TEXT("TapJNI GetObjectField: %s fail"), UTF8_TO_TCHAR(name))); + } + else { + TUDebuger::DisplayLog( + FString::Printf(TEXT("TapJNI GetObjectField: %s success"), UTF8_TO_TCHAR(name))); + } + return MakeScopedJavaObject(Env, resultObject); + } + + bool JNI::GetBooleanField(const Object& object, const char* name) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "Z"); + return Env->GetBooleanField(*object, fieldID);; + } + + char JNI::GetCharField(const Object& object, const char* name) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "C"); + return Env->GetCharField(*object, fieldID);; + } + + short JNI::GetShortField(const Object& object, const char* name) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "S"); + return Env->GetShortField(*object, fieldID);; + } + + int JNI::GetIntField(const Object& object, const char* name) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "I"); + return Env->GetIntField(*object, fieldID);; + } + + long JNI::GetLongField(const Object& object, const char* name) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "J"); + return Env->GetLongField(*object, fieldID);; + } + + float JNI::GetFloatField(const Object& object, const char* name) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "F"); + return Env->GetFloatField(*object, fieldID);; + } + + double JNI::GetDoubleField(const Object& object, const char* name) const { + Class Class = GetObjectClass(object); + jfieldID fieldID = GetFieldID(Class, name, "D"); + return Env->GetDoubleField(*object, fieldID);; + } + + void JNI::SetStaticObjectField(const Class& Class, const char* name, const char* sig, const Object& value) const { + jfieldID fieldID = GetFieldID(Class, name, sig); + Env->SetStaticObjectField(*Class, fieldID, *value); + } + + void JNI::SetStaticBooleanField(const Class& Class, const char* name, bool value) const { + jfieldID fieldID = GetFieldID(Class, name, "Z"); + Env->SetStaticBooleanField(*Class, fieldID, value); + } + + void JNI::SetStaticCharField(const Class& Class, const char* name, char value) const { + jfieldID fieldID = GetFieldID(Class, name, "C"); + Env->SetStaticCharField(*Class, fieldID, value); + } + + void JNI::SetStaticShortField(const Class& Class, const char* name, short value) const { + jfieldID fieldID = GetFieldID(Class, name, "S"); + Env->SetStaticShortField(*Class, fieldID, value); + } + + void JNI::SetStaticIntField(const Class& Class, const char* name, int value) const { + jfieldID fieldID = GetFieldID(Class, name, "I"); + Env->SetStaticIntField(*Class, fieldID, value); + } + + void JNI::SetStaticLongField(const Class& Class, const char* name, long value) const { + jfieldID fieldID = GetFieldID(Class, name, "J"); + Env->SetStaticLongField(*Class, fieldID, value); + } + + void JNI::SetStaticFloatField(const Class& Class, const char* name, float value) const { + jfieldID fieldID = GetFieldID(Class, name, "F"); + Env->SetStaticFloatField(*Class, fieldID, value); + } + + void JNI::SetStaticDoubleField(const Class& Class, const char* name, double value) const { + jfieldID fieldID = GetFieldID(Class, name, "D"); + Env->SetStaticDoubleField(*Class, fieldID, value); + } + + Object JNI::GetStaticObjectField(const Class& Class, const char* name, const char* sig) const { + jfieldID fieldID = GetFieldID(Class, name, sig); + jobject resultObject = Env->GetStaticObjectField(*Class, fieldID); + if (resultObject == NULL) { + TUDebuger::ErrorLog( + FString::Printf(TEXT("TapJNI GetStaticObjectField: %s fail"), UTF8_TO_TCHAR(name))); + } + else { + TUDebuger::DisplayLog( + FString::Printf(TEXT("TapJNI GetStaticObjectField: %s success"), UTF8_TO_TCHAR(name))); + } + return MakeScopedJavaObject(Env, resultObject); + } + + bool JNI::GetStaticBooleanField(const Class& Class, const char* name) const { + jfieldID fieldID = GetFieldID(Class, name, "Z"); + return Env->GetStaticBooleanField(*Class, fieldID);; + } + + char JNI::GetStaticCharField(const Class& Class, const char* name) const { + jfieldID fieldID = GetFieldID(Class, name, "C"); + return Env->GetStaticCharField(*Class, fieldID);; + } + + short JNI::GetStaticShortField(const Class& Class, const char* name) const { + jfieldID fieldID = GetFieldID(Class, name, "S"); + return Env->GetStaticShortField(*Class, fieldID);; + } + + int JNI::GetStaticIntField(const Class& Class, const char* name) const { + jfieldID fieldID = GetFieldID(Class, name, "I"); + return Env->GetStaticIntField(*Class, fieldID);; + } + + long JNI::GetStaticLongField(const Class& Class, const char* name) const { + jfieldID fieldID = GetFieldID(Class, name, "J"); + return Env->GetStaticLongField(*Class, fieldID);; + } + + float JNI::GetStaticFloatField(const Class& Class, const char* name) const { + jfieldID fieldID = GetFieldID(Class, name, "F"); + return Env->GetStaticFloatField(*Class, fieldID);; + } + + double JNI::GetStaticDoubleField(const Class& Class, const char* name) const { + jfieldID fieldID = GetFieldID(Class, name, "D"); + return Env->GetStaticDoubleField(*Class, fieldID);; + } + FString JNI::GetFString(const Object& JavaString) const { FString ReturnString = GetFStringFromParam((jstring)*JavaString); diff --git a/TapCommon/Source/TapCommon/Public/Android/TapJNI.h b/TapCommon/Source/TapCommon/Public/Android/TapJNI.h index 2e035fb..1be0560 100644 --- a/TapCommon/Source/TapCommon/Public/Android/TapJNI.h +++ b/TapCommon/Source/TapCommon/Public/Android/TapJNI.h @@ -78,10 +78,17 @@ namespace TapJNI { // Returns the underlying JNI pointer JNIEnv * operator*() const { return Env; } + template + ScopedJavaObject MakeJavaObject(const T& InObjRef, bool InNeedDelete = true) { + return ScopedJavaObject(Env, InObjRef, InNeedDelete); + } + Class FindClass(const char* name) const; Class GetObjectClass(const Object& object) const; - jmethodID GetMethodID(const Class& Class, const char* methodName, const char* methodsig) const; - jmethodID GetStaticMethodID(const Class& Class, const char* methodName, const char* methodsig) const; + jmethodID GetMethodID(const Class& Class, const char* name, const char* sig) const; + jmethodID GetStaticMethodID(const Class& Class, const char* name, const char* sig) const; + jfieldID GetFieldID(const Class& Class, const char* name, const char* sig) const; + jfieldID GetStaticFieldID(const Class& Class, const char* name, const char* sig) const; Object GetActivity() const; Object GetJavaObject(int Value) const; @@ -109,6 +116,47 @@ namespace TapJNI { float CallStaticFloatMethod(LC_JNIClassCallMethodArgs) const; double CallStaticDoubleMethod(LC_JNIClassCallMethodArgs) const; void CallStaticVoidMethod(LC_JNIClassCallMethodArgs) const; + + void SetObjectField(const Object& object, const char* name, const char* sig, const Object& value) const; + void SetBooleanField(const Object& object, const char* name, bool value) const; + void SetCharField(const Object& object, const char* name, char value) const; + void SetShortField(const Object& object, const char* name, short value) const; + void SetIntField(const Object& object, const char* name, int value) const; + void SetLongField(const Object& object, const char* name, long value) const; + void SetFloatField(const Object& object, const char* name, float value) const; + void SetDoubleField(const Object& object, const char* name, double value) const; + void SetFStringField(const Object& object, const char* name, const FString& value) const; + + Object GetObjectField(const Object& object, const char* name, const char* sig) const; + bool GetBooleanField(const Object& object, const char* name) const; + char GetCharField(const Object& object, const char* name) const; + short GetShortField(const Object& object, const char* name) const; + int GetIntField(const Object& object, const char* name) const; + long GetLongField(const Object& object, const char* name) const; + float GetFloatField(const Object& object, const char* name) const; + double GetDoubleField(const Object& object, const char* name) const; + FString GetFStringField(const Object& object, const char* name) const; + + void SetStaticObjectField(const Class& Class, const char* name, const char* sig, const Object& value) const; + void SetStaticBooleanField(const Class& Class, const char* name, bool value) const; + void SetStaticCharField(const Class& Class, const char* name, char value) const; + void SetStaticShortField(const Class& Class, const char* name, short value) const; + void SetStaticIntField(const Class& Class, const char* name, int value) const; + void SetStaticLongField(const Class& Class, const char* name, long value) const; + void SetStaticFloatField(const Class& Class, const char* name, float value) const; + void SetStaticDoubleField(const Class& Class, const char* name, double value) const; + void SetStaticFStringField(const Class& Class, const char* name, const FString& value) const; + + Object GetStaticObjectField(const Class& Class, const char* name, const char* sig) const; + bool GetStaticBooleanField(const Class& Class, const char* name) const; + char GetStaticCharField(const Class& Class, const char* name) const; + short GetStaticShortField(const Class& Class, const char* name) const; + int GetStaticIntField(const Class& Class, const char* name) const; + long GetStaticLongField(const Class& Class, const char* name) const; + float GetStaticFloatField(const Class& Class, const char* name) const; + double GetStaticDoubleField(const Class& Class, const char* name) const; + FString GetStaticFStringField(const Class& Class, const char* name) const; + // Converts the java string to FString and calls DeleteLocalRef on the passed-in java string reference FString GetFString(const Object& JavaString) const; diff --git a/TapCommon/Source/TapCommon/Public/TapCommon.h b/TapCommon/Source/TapCommon/Public/TapCommon.h index d65ea62..dd0f290 100644 --- a/TapCommon/Source/TapCommon/Public/TapCommon.h +++ b/TapCommon/Source/TapCommon/Public/TapCommon.h @@ -4,8 +4,8 @@ #include "Modules/ModuleManager.h" -#define TapUECommon_VERSION_NUMBER "31700001" -#define TapUECommon_VERSION "3.17.0" +#define TapUECommon_VERSION_NUMBER "31800001" +#define TapUECommon_VERSION "3.18.0" class FSlateStyleSet; diff --git a/TapCommon/Source/TapCommon/TapCommon_Android_UPL.xml b/TapCommon/Source/TapCommon/TapCommon_Android_UPL.xml index b3df65c..c71e8de 100644 --- a/TapCommon/Source/TapCommon/TapCommon_Android_UPL.xml +++ b/TapCommon/Source/TapCommon/TapCommon_Android_UPL.xml @@ -83,7 +83,7 @@ repositories { flatDir { dirs 'src/main/libs/' } } -dependencies.implementation(name: 'TapCommon_3.17.0',ext:'aar') +dependencies.implementation(name: 'TapCommon_3.18.0',ext:'aar') android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/TapCommon/Source/TapCommon/Tools/TUHelper.h b/TapCommon/Source/TapCommon/Tools/TUHelper.h index 45e893d..2f677c0 100644 --- a/TapCommon/Source/TapCommon/Tools/TUHelper.h +++ b/TapCommon/Source/TapCommon/Tools/TUHelper.h @@ -35,7 +35,7 @@ class TAPCOMMON_API TUHelper template static TReturn InvokeFunction(FString CLassName, FString FunctionName, TArgs&&... args) { - TReturn Value; + TReturn Value = TReturn(); if (CLassName.IsEmpty() || FunctionName.IsEmpty()) { TUDebuger::ErrorLog("类名或者方法名不得为空"); diff --git a/TapCommon/Source/ThirdParty/Android/libs/TapCommon_3.17.0.aar b/TapCommon/Source/ThirdParty/Android/libs/TapCommon_3.17.0.aar deleted file mode 100644 index 1dd1798..0000000 Binary files a/TapCommon/Source/ThirdParty/Android/libs/TapCommon_3.17.0.aar and /dev/null differ diff --git a/TapCommon/Source/ThirdParty/Android/libs/TapCommon_3.18.0.aar b/TapCommon/Source/ThirdParty/Android/libs/TapCommon_3.18.0.aar new file mode 100644 index 0000000..7ebb3be Binary files /dev/null and b/TapCommon/Source/ThirdParty/Android/libs/TapCommon_3.18.0.aar differ diff --git a/TapCommon/Source/ThirdParty/iOS/Frameworks/TapCommonSDK.zip b/TapCommon/Source/ThirdParty/iOS/Frameworks/TapCommonSDK.zip index 3c253a5..b74ef18 100644 Binary files a/TapCommon/Source/ThirdParty/iOS/Frameworks/TapCommonSDK.zip and b/TapCommon/Source/ThirdParty/iOS/Frameworks/TapCommonSDK.zip differ diff --git a/TapCommon/TapCommon.uplugin b/TapCommon/TapCommon.uplugin index 687d7ed..c740629 100644 --- a/TapCommon/TapCommon.uplugin +++ b/TapCommon/TapCommon.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 31605001, - "VersionName": "3.17.0", + "Version": 31800001, + "VersionName": "3.18.0", "FriendlyName": "TapCommon", "Description": "TapTap Common", "Category": "TapTap", diff --git a/TapDB/Source/TapDB/Public/TapDB.h b/TapDB/Source/TapDB/Public/TapDB.h index 546988b..c0fc051 100644 --- a/TapDB/Source/TapDB/Public/TapDB.h +++ b/TapDB/Source/TapDB/Public/TapDB.h @@ -4,8 +4,8 @@ #include "Modules/ModuleManager.h" -#define TapUEDB_VERSION_NUMBER "31700001" -#define TapUEDB_VERSION "3.17.0" +#define TapUEDB_VERSION_NUMBER "31800001" +#define TapUEDB_VERSION "3.18.0" class FTapDBModule : public IModuleInterface { diff --git a/TapDB/Source/TapDB/TapDB_Android_UPL.xml b/TapDB/Source/TapDB/TapDB_Android_UPL.xml index fc3afe5..8f97fb9 100644 --- a/TapDB/Source/TapDB/TapDB_Android_UPL.xml +++ b/TapDB/Source/TapDB/TapDB_Android_UPL.xml @@ -18,7 +18,7 @@ -dependencies.implementation(name: 'TapDB_3.17.0',ext:'aar') +dependencies.implementation(name: 'TapDB_3.18.0',ext:'aar') diff --git a/TapDB/Source/ThirdParty/Android/libs/TapDB_3.17.0.aar b/TapDB/Source/ThirdParty/Android/libs/TapDB_3.18.0.aar similarity index 78% rename from TapDB/Source/ThirdParty/Android/libs/TapDB_3.17.0.aar rename to TapDB/Source/ThirdParty/Android/libs/TapDB_3.18.0.aar index 76631ce..64bc080 100644 Binary files a/TapDB/Source/ThirdParty/Android/libs/TapDB_3.17.0.aar and b/TapDB/Source/ThirdParty/Android/libs/TapDB_3.18.0.aar differ diff --git a/TapDB/Source/ThirdParty/iOS/Frameworks/TapDB.zip b/TapDB/Source/ThirdParty/iOS/Frameworks/TapDB.zip index 350d95c..c172720 100644 Binary files a/TapDB/Source/ThirdParty/iOS/Frameworks/TapDB.zip and b/TapDB/Source/ThirdParty/iOS/Frameworks/TapDB.zip differ diff --git a/TapDB/TapDB.uplugin b/TapDB/TapDB.uplugin index 75d221a..8945948 100644 --- a/TapDB/TapDB.uplugin +++ b/TapDB/TapDB.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 31605001, - "VersionName": "3.17.0", + "Version": 31800001, + "VersionName": "3.18.0", "FriendlyName": "TapDB", "Description": "TapTap TapDB", "Category": "TapTap", diff --git a/TapLogin/Source/TapLogin/Public/TapLogin.h b/TapLogin/Source/TapLogin/Public/TapLogin.h index 2d9c5a9..1002373 100644 --- a/TapLogin/Source/TapLogin/Public/TapLogin.h +++ b/TapLogin/Source/TapLogin/Public/TapLogin.h @@ -2,8 +2,8 @@ #pragma once -#define TapUELogin_VERSION_NUMBER "31700001" -#define TapUELogin_VERSION "3.17.0" +#define TapUELogin_VERSION_NUMBER "31800001" +#define TapUELogin_VERSION "3.18.0" class FTapLoginModule : public IModuleInterface { diff --git a/TapLogin/Source/TapLogin/TapLogin_Android_UPL.xml b/TapLogin/Source/TapLogin/TapLogin_Android_UPL.xml index b95f475..8c64ed1 100644 --- a/TapLogin/Source/TapLogin/TapLogin_Android_UPL.xml +++ b/TapLogin/Source/TapLogin/TapLogin_Android_UPL.xml @@ -18,7 +18,7 @@ -dependencies.implementation(name: 'TapLogin_3.17.0',ext:'aar') +dependencies.implementation(name: 'TapLogin_3.18.0',ext:'aar') diff --git a/TapLogin/Source/ThirdParty/Android/libs/TapLogin_3.17.0.aar b/TapLogin/Source/ThirdParty/Android/libs/TapLogin_3.17.0.aar deleted file mode 100644 index 3d15bf3..0000000 Binary files a/TapLogin/Source/ThirdParty/Android/libs/TapLogin_3.17.0.aar and /dev/null differ diff --git a/TapLogin/Source/ThirdParty/Android/libs/TapLogin_3.18.0.aar b/TapLogin/Source/ThirdParty/Android/libs/TapLogin_3.18.0.aar new file mode 100644 index 0000000..0e8c706 Binary files /dev/null and b/TapLogin/Source/ThirdParty/Android/libs/TapLogin_3.18.0.aar differ diff --git a/TapLogin/Source/ThirdParty/iOS/Frameworks/TapLoginSDK.zip b/TapLogin/Source/ThirdParty/iOS/Frameworks/TapLoginSDK.zip index 985503c..f1c00fe 100644 Binary files a/TapLogin/Source/ThirdParty/iOS/Frameworks/TapLoginSDK.zip and b/TapLogin/Source/ThirdParty/iOS/Frameworks/TapLoginSDK.zip differ diff --git a/TapLogin/TapLogin.uplugin b/TapLogin/TapLogin.uplugin index 068cbdf..a0b73df 100644 --- a/TapLogin/TapLogin.uplugin +++ b/TapLogin/TapLogin.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 31605001, - "VersionName": "3.17.0", + "Version": 31800001, + "VersionName": "3.18.0", "FriendlyName": "TapLogin", "Description": "TapTap Login", "Category": "TapTap", diff --git a/TapSupport/Source/TapSupport/Private/Mobile/TUSupportMobileImpl.cpp b/TapSupport/Source/TapSupport/Private/Mobile/TUSupportMobileImpl.cpp index ca660a5..e58d59a 100644 --- a/TapSupport/Source/TapSupport/Private/Mobile/TUSupportMobileImpl.cpp +++ b/TapSupport/Source/TapSupport/Private/Mobile/TUSupportMobileImpl.cpp @@ -1,10 +1,8 @@ #include "TUSupportMobileImpl.h" -#include "TapUESupport.h" -#include "TUDebuger.h" #include "TUJsonHelper.h" #include "TUMobileBridge.h" -#include "TUSupportUnreadStatusResult.h" + #define TapSupportService "TDSTapSupportService" @@ -17,114 +15,17 @@ TUSupportMobileImpl::TUSupportMobileImpl() { TUMobileBridge::Register(TapSupport_SERVICE_CLZ, TapSupport_SERVICE_IMPL); } -void TUSupportMobileImpl::Init(FTapSupportConfig _Config) { - TSharedPtr JsonObject = MakeShareable(new FJsonObject); - JsonObject->SetStringField("server", _Config.ServerUrl); - JsonObject->SetStringField("productID", _Config.ProductID); - - FString JsonOutString; - TSharedRef>> Writer = TJsonWriterFactory< - TCHAR, TCondensedJsonPrintPolicy>::Create(&JsonOutString); - Writer->WriteObjectStart(); - Writer->WriteValue(TEXT("config"), TUJsonHelper::GetJsonString(JsonObject)); - Writer->WriteObjectEnd(); - Writer->Close(); - - TUMobileBridge::AsyncPerform(TapSupportService, "setConfig", JsonOutString, [](const FString& ResultJsonStr) { - auto UnreadStatusResult = TUJsonHelper::GetUStruct(ResultJsonStr); - if (!UnreadStatusResult.IsValid()) { - TUDebuger::ErrorLog("TUSupportMobileImpl::Init CallBack Error"); - return; - } - if (UnreadStatusResult->IsSuccessful()) { - TapUESupport::OnUnreadStatusChanged.ExecuteIfBound(UnreadStatusResult->HasUnread()); - } else { - TapUESupport::OnErrorCallBack.ExecuteIfBound(FTUError(UnreadStatusResult->code, UnreadStatusResult->errorMsg)); - } - }, false); -} - -void TUSupportMobileImpl::SetDefaultMetaData(TSharedPtr MetaData) { - FString JsonOutString; - TSharedRef>> Writer = TJsonWriterFactory< - TCHAR, TCondensedJsonPrintPolicy>::Create(&JsonOutString); - Writer->WriteObjectStart(); - Writer->WriteValue(TEXT("setDefaultMetaData"), TUJsonHelper::GetJsonString(MetaData)); - Writer->WriteObjectEnd(); - Writer->Close(); - TUMobileBridge::AsyncPerform(TapSupportService, "setDefaultMetaData", JsonOutString); -} - -void TUSupportMobileImpl::SetDefaultFieldsData(TSharedPtr FieldsData) { +void TUSupportMobileImpl::OpenFullUrl(const FString& Path) { FString JsonOutString; TSharedRef>> Writer = TJsonWriterFactory< TCHAR, TCondensedJsonPrintPolicy>::Create(&JsonOutString); Writer->WriteObjectStart(); - Writer->WriteValue(TEXT("setDefaultFieldsData"), TUJsonHelper::GetJsonString(FieldsData)); + Writer->WriteValue(TEXT("openFullUrl"), Path); Writer->WriteObjectEnd(); Writer->Close(); - TUMobileBridge::AsyncPerform(TapSupportService, "setDefaultFieldsData", JsonOutString); -} - -void TUSupportMobileImpl::LoginAnonymously(const FString& UserID) { - FString JsonOutString; - TSharedRef>> Writer = TJsonWriterFactory< - TCHAR, TCondensedJsonPrintPolicy>::Create(&JsonOutString); - Writer->WriteObjectStart(); - Writer->WriteValue(TEXT("loginAnonymously"), UserID); - Writer->WriteObjectEnd(); - Writer->Close(); - TUMobileBridge::AsyncPerform(TapSupportService, "loginAnonymously", JsonOutString); -} - -void TUSupportMobileImpl::Logout() { - TUMobileBridge::AsyncPerform(TapSupportService, "logout", ""); -} - -FString TUSupportMobileImpl::GetSupportWebUrl(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) { - FString JsonOutString; - TSharedRef>> Writer = TJsonWriterFactory< - TCHAR, TCondensedJsonPrintPolicy>::Create(&JsonOutString); - Writer->WriteObjectStart(); - Writer->WriteValue(TEXT("path"), Path); - Writer->WriteValue(TEXT("metaData"), TUJsonHelper::GetJsonString(MetaData)); - Writer->WriteValue(TEXT("fieldsData"), TUJsonHelper::GetJsonString(FieldsData)); - Writer->WriteObjectEnd(); - Writer->Close(); - auto ResultStr = TUMobileBridge::Perform(TapSupportService, "getSupportWebUrl", JsonOutString); - auto ResultJsonObject = TUJsonHelper::GetJsonObject(ResultStr); - FString Url = ""; - ResultJsonObject->TryGetStringField("url", Url); - return Url; -} - -void TUSupportMobileImpl::OpenSupportView(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) { - FString JsonOutString; - TSharedRef>> Writer = TJsonWriterFactory< - TCHAR, TCondensedJsonPrintPolicy>::Create(&JsonOutString); - Writer->WriteObjectStart(); - Writer->WriteValue(TEXT("openSupportView"), Path); - Writer->WriteValue(TEXT("metaData"), TUJsonHelper::GetJsonString(MetaData)); - Writer->WriteValue(TEXT("fieldsData"), TUJsonHelper::GetJsonString(FieldsData)); - Writer->WriteObjectEnd(); - Writer->Close(); - TUMobileBridge::AsyncPerform(TapSupportService, "openSupportView", JsonOutString); + TUMobileBridge::AsyncPerform(TapSupportService, "openFullUrl", JsonOutString); } void TUSupportMobileImpl::CloseSupportView() { TUMobileBridge::AsyncPerform(TapSupportService, "closeSupportView", ""); } - -void TUSupportMobileImpl::Resume() { - TUMobileBridge::AsyncPerform(TapSupportService, "resume", ""); -} - -void TUSupportMobileImpl::Pause() { - TUMobileBridge::AsyncPerform(TapSupportService, "pause", ""); -} - -void TUSupportMobileImpl::FetchUnReadStatus() { - TUMobileBridge::AsyncPerform(TapSupportService, "fetchUnreadStatus", ""); -} diff --git a/TapSupport/Source/TapSupport/Private/Mobile/TUSupportMobileImpl.h b/TapSupport/Source/TapSupport/Private/Mobile/TUSupportMobileImpl.h index f696dec..b9a1bf2 100644 --- a/TapSupport/Source/TapSupport/Private/Mobile/TUSupportMobileImpl.h +++ b/TapSupport/Source/TapSupport/Private/Mobile/TUSupportMobileImpl.h @@ -1,20 +1,10 @@ #pragma once -#include "TUSupportImpl.h" +#include "PC/TUSupportPCImpl.h" -class TUSupportMobileImpl: public TUSupportImpl { +class TUSupportMobileImpl: public TUSupportPCImpl { public: TUSupportMobileImpl(); - virtual void Init(FTapSupportConfig _Config) override; - virtual void SetDefaultMetaData(TSharedPtr MetaData) override; - virtual void SetDefaultFieldsData(TSharedPtr FieldsData) override; - virtual void LoginAnonymously(const FString& UserID) override; - virtual void Logout() override; - virtual FString GetSupportWebUrl(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) override; - virtual void OpenSupportView(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) override; + virtual void OpenFullUrl(const FString& Path) override; virtual void CloseSupportView() override; - virtual void Resume() override; - virtual void Pause() override; - virtual void FetchUnReadStatus() override; + }; diff --git a/TapSupport/Source/TapSupport/Private/Mobile/TUSupportUnreadStatusResult.h b/TapSupport/Source/TapSupport/Private/Mobile/TUSupportUnreadStatusResult.h deleted file mode 100644 index a485666..0000000 --- a/TapSupport/Source/TapSupport/Private/Mobile/TUSupportUnreadStatusResult.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "CoreMinimal.h" -#include "TUSupportUnreadStatusResult.generated.h" - -USTRUCT(BlueprintType) -struct FTUSupportUnreadStatusResult -{ - GENERATED_USTRUCT_BODY() - - UPROPERTY() - FString errorMsg; - - UPROPERTY() - uint64 code = 0; - - UPROPERTY() - uint64 hasUnRead = 0; - - bool HasUnread() { - return hasUnRead == 1; - } - - bool IsSuccessful() { - return code == 0; - } -}; \ No newline at end of file diff --git a/TapSupport/Source/TapSupport/Private/PC/TUSupportNet.cpp b/TapSupport/Source/TapSupport/Private/PC/TUSupportNet.cpp index 23681fb..004cb02 100644 --- a/TapSupport/Source/TapSupport/Private/PC/TUSupportNet.cpp +++ b/TapSupport/Source/TapSupport/Private/PC/TUSupportNet.cpp @@ -7,34 +7,44 @@ TUSupportNet::TUSupportNet() { } -void TUSupportNet::FetchUnReadStatus(const FString& UserID, +void TUSupportNet::FetchUnReadStatus(ESupportLoginType LoginType, const FString& UserID, TFunction Callback) { const TSharedPtr request = MakeShareable(new TUSupportNet()); request->Type = Get; request->URL = TUSupportImpl::Get()->Config.ServerUrl / "/api/2/unread"; - request->Headers.Add("X-Anonymous-ID", UserID); + switch (LoginType) + { + case ESupportLoginType::None: + return; + case ESupportLoginType::Anonymous: + request->Headers.Add("X-Anonymous-ID", UserID); + break; + case ESupportLoginType::Custom: + request->Headers.Add("X-Credential", UserID); + break; + case ESupportLoginType::TDS: + request->Headers.Add("X-TDS-Credential", UserID); + break; + default: ; + } request->Parameters->SetStringField("product", TUSupportImpl::Get()->Config.ProductID); request->onCompleted.BindLambda([=](TSharedPtr Response) { if (!Callback) { return; } - FTUError Error = FTUError(); - if (Response->state == TUHttpResponse::clientError) { - Error.code = TUHttpResponse::clientError; - Error.msg = "request fail"; + TSharedPtr JsonObject; + const TSharedRef> JsonReader = TJsonReaderFactory<>::Create(Response->contentString); + if (FJsonSerializer::Deserialize(JsonReader, JsonObject) && JsonObject.IsValid()) + { + FTUError Error = FTUError(); + JsonObject->TryGetNumberField(TEXT("numCode"), Error.code); + JsonObject->TryGetStringField(TEXT("message"), Error.msg); + JsonObject->TryGetStringField(TEXT("code"), Error.error_description); + Callback(TEXT(""), Error); } - else if (Response->state == TUHttpResponse::serverError) { - Error.code = TUHttpResponse::serverError; - Error.msg = "server error"; - } - else if (Response->state == TUHttpResponse::networkError) { - Error.code = TUHttpResponse::networkError; - Error.msg = "network connection error"; - } - if (Error.msg.IsEmpty()) { - Callback(Response->contentString, Error); - } else { - Callback("", Error); + else + { + Callback(Response->contentString, FTUError()); } }); TUHttpManager::Get().request(request); diff --git a/TapSupport/Source/TapSupport/Private/PC/TUSupportNet.h b/TapSupport/Source/TapSupport/Private/PC/TUSupportNet.h index 2d89cfb..9788461 100644 --- a/TapSupport/Source/TapSupport/Private/PC/TUSupportNet.h +++ b/TapSupport/Source/TapSupport/Private/PC/TUSupportNet.h @@ -2,11 +2,13 @@ #include "TUError.h" #include "TUHttpRequest.h" +enum class ESupportLoginType : uint8; + class TUSupportNet: public TUHttpRequest { public: TUSupportNet(); - static void FetchUnReadStatus(const FString& UserID, TFunction Callback); + static void FetchUnReadStatus(ESupportLoginType LoginType, const FString& UserID, TFunction Callback); }; diff --git a/TapSupport/Source/TapSupport/Private/PC/TUSupportPCImpl.cpp b/TapSupport/Source/TapSupport/Private/PC/TUSupportPCImpl.cpp index b8ad36d..5567a63 100644 --- a/TapSupport/Source/TapSupport/Private/PC/TUSupportPCImpl.cpp +++ b/TapSupport/Source/TapSupport/Private/PC/TUSupportPCImpl.cpp @@ -1,70 +1,107 @@ #include "TUSupportPCImpl.h" + #include "TapUESupport.h" #include "TUDebuger.h" -#include "TUDeviceInfo.h" #include "TUHelper.h" #include "TUJsonHelper.h" #include "TUSettings.h" #include "TUSupportNet.h" #include "GenericPlatform/GenericPlatformHttp.h" -#include "TUWebViewJavascriptBridge/TUWebViewJavascriptBridge_JS.h" #include "UI/TUSupportWebView.h" + TUSupportPCImpl::TUSupportPCImpl() { - NextDelay = 10; + NextDelay = LOOP_INC_SECONDS; } TUSupportPCImpl::~TUSupportPCImpl() { - CancelTimer(); } void TUSupportPCImpl::Init(FTapSupportConfig _Config) { Config = _Config; } -void TUSupportPCImpl::SetDefaultMetaData(TSharedPtr MetaData) { - DefaultMetaData = MetaData; -} - void TUSupportPCImpl::SetDefaultFieldsData(TSharedPtr FieldsData) { DefaultFieldsData = FieldsData; } +void TUSupportPCImpl::UpdateDefaultField(const FString& Key, const TSharedPtr& NewValue) +{ + if (!DefaultFieldsData) + { + DefaultFieldsData = MakeShared(); + } + DefaultFieldsData->SetField(Key, NewValue); +} + void TUSupportPCImpl::LoginAnonymously(const FString& UserID) { if (Config.ServerUrl.IsEmpty()) { return; } check(!UserID.IsEmpty()); - if (!AnonymousID.IsEmpty() && UserID != AnonymousID) { + if (!CachedId.IsEmpty() && UserID != CachedId) { Logout(); } - AnonymousID = UserID; - Pause(); + CachedId = UserID; + LoginType = ESupportLoginType::Anonymous; + FetchLoop(); } -FString TUSupportPCImpl::GetSupportWebUrl(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) { +void TUSupportPCImpl::LoginWithCustomCredential(const FString& Credential) +{ + CachedId = Credential; + LoginType = ESupportLoginType::Custom; + FetchLoop(); +} + +void TUSupportPCImpl::LoginWithTDSCredential(const FString& Credential, const FSimpleDelegate& OnSuccess, const FTapFailed& OnFailed) +{ + const TSharedRef HttpRequest = FHttpModule::Get().CreateRequest(); + + const FString Url = FString::Printf(TEXT("%s/api/2/users/tds/token"), *Config.ServerUrl); + HttpRequest->SetURL(Url); + + HttpRequest->SetVerb(TEXT("POST")); + + HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json")); + + FString JsonString; + const TSharedRef>> Writer = TJsonWriterFactory>::Create(&JsonString); + Writer->WriteObjectStart(); + Writer->WriteValue(TEXT("jwt"), Credential); + Writer->WriteObjectEnd(); + Writer->Close(); + HttpRequest->SetContentAsString(JsonString); + + HttpRequest->OnProcessRequestComplete().BindRaw(this, &TUSupportPCImpl::NetTDSLoginCallback, OnSuccess, OnFailed); + + if (!HttpRequest->ProcessRequest()) + { + OnFailed.ExecuteIfBound(FTUError(-1, TEXT("Network error."))); + } +} + +FString TUSupportPCImpl::GetSupportWebUrl(const FString& Path, TSharedPtr FieldsData) { if (Config.ServerUrl.IsEmpty()) { TUDebuger::WarningLog("TapSupport Server Url is Empty"); return ""; } - if (AnonymousID.IsEmpty()) { + if (CachedId.IsEmpty() || LoginType == ESupportLoginType::None) { TUDebuger::WarningLog("TapSupport: Please Login first"); return ""; } - TSharedPtr RealMetaData = MetaData; - if (!RealMetaData.IsValid() || RealMetaData->Values.Num() == 0) { - RealMetaData = DefaultMetaData; + + TSharedPtr RealFieldsData = MakeShared(); + if (DefaultFieldsData) + { + RealFieldsData->Values = DefaultFieldsData->Values; } - TSharedPtr RealFieldsData = FieldsData; - if (!RealFieldsData.IsValid() || RealFieldsData->Values.Num() == 0) { - RealFieldsData = DefaultFieldsData; + if (FieldsData) + { + RealFieldsData->Values.Append(FieldsData->Values); } TSharedPtr ParasObject = MakeShareable(new FJsonObject); - if (RealMetaData.IsValid() && RealMetaData->Values.Num() > 0) { - ParasObject->SetStringField("meta", TUJsonHelper::GetJsonString(RealMetaData)); - } if (RealFieldsData.IsValid() && RealFieldsData->Values.Num() > 0) { ParasObject->SetStringField("fields", TUJsonHelper::GetJsonString(RealFieldsData)); } @@ -73,33 +110,48 @@ FString TUSupportPCImpl::GetSupportWebUrl(const FString& Path, TSharedPtrGetTimerManager().ClearTimer(TimerHandle); + } + + NextDelay = LOOP_INC_SECONDS; + + TUSettings::GetGameInstance()->GetTimerManager().SetTimer( + TimerHandle, + FTimerDelegate::CreateRaw(this, &TUSupportPCImpl::FetchLoop), + (bUnregister && !bWebOpen) ? UNREGISTER_SECONDS : NextDelay, + false); + bWebOpen = false; } void TUSupportPCImpl::Pause() { - StopNotification = true; - CancelTimer(); - NextDelay = 10; + if (TimerHandle.IsValid()) { + TUSettings::GetGameInstance()->GetTimerManager().ClearTimer(TimerHandle); + } + TimerHandle.Invalidate(); } void TUSupportPCImpl::Logout() { Pause(); CloseSupportView(); - AnonymousID = ""; + CachedId = ""; + LoginType = ESupportLoginType::None; + UnreadStatus.Reset(); } void TUSupportPCImpl::FetchUnReadStatus() { + if (Config.ServerUrl.IsEmpty()) { TUDebuger::WarningLog("TapSupport Server Url is Empty"); return; } - if (AnonymousID.IsEmpty()) { + if (CachedId.IsEmpty() || LoginType == ESupportLoginType::None) { TUDebuger::WarningLog("TapSupport: Please Login first"); return; } - TUSupportNet::FetchUnReadStatus(GetAnonymousID(), [=](const FString& Model, const FTUError& Error) { - if (Model.IsEmpty()) { - TapUESupport::OnErrorCallBack.ExecuteIfBound(Error); - } else { - if (Model != UnreadStatus) { - NextDelay = 10; - TapUESupport::OnUnreadStatusChanged.ExecuteIfBound(Model == "true"); + + TUSupportNet::FetchUnReadStatus( + LoginType, + CachedId, + [=](const FString& Model, const FTUError& Error) + { + if (Model.IsEmpty()) + { + bUnregister = Error.error_description == TEXT("USER_NOT_REGISTERED"); + TapUESupport::OnErrorCallBack.ExecuteIfBound(Error); } - UnreadStatus = Model; - } - StartNext(); - }); + else + { + if (Model != UnreadStatus) + { + Resume(); + TapUESupport::OnUnreadStatusChanged.ExecuteIfBound(Model == "true"); + } + bUnregister = false; + UnreadStatus = Model; + } + }); } -void TUSupportPCImpl::StartNext() { - if (StopNotification) { +void TUSupportPCImpl::OpenFullUrl(const FString& Path) { + TUHelper::LaunchURL(*Path, NULL, NULL); +} + +void TUSupportPCImpl::NetTDSLoginCallback(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FSimpleDelegate OnSuccess, FTapFailed OnFailed) +{ + if (!HttpResponse) + { + OnFailed.ExecuteIfBound(FTUError(-1, TEXT("Net error"))); return; } - TUSettings::GetGameInstance()->GetTimerManager().SetTimer(TimerHandle, [=]() { - FetchUnReadStatus(); - }, FMath::Max(10, NextDelay), false); - if (NextDelay < 300) { - NextDelay += 10; + + const FString ContentString = HttpResponse->GetContentAsString(); + + TSharedPtr JsonObject; + const TSharedRef > JsonReader = TJsonReaderFactory<>::Create(ContentString); + if (!FJsonSerializer::Deserialize(JsonReader, JsonObject) || !JsonObject.IsValid()) + { + OnFailed.ExecuteIfBound(FTUError(HttpResponse->GetResponseCode(), FString::Printf(TEXT("Net error, Deserialize failed, response content: %s"), *ContentString))); + return; + } + + if (JsonObject->TryGetStringField(TEXT("jwt"), CachedId)) + { + LoginType = ESupportLoginType::TDS; + FetchLoop(); + OnSuccess.ExecuteIfBound(); + return; } + OnFailed.ExecuteIfBound(FTUError(-1, TEXT("Net error"))); } -void TUSupportPCImpl::CancelTimer() { - if (TimerHandle.IsValid()) { - TUSettings::GetGameInstance()->GetTimerManager().ClearTimer(TimerHandle); +void TUSupportPCImpl::FetchLoop() +{ + if (Config.ServerUrl.IsEmpty()) { + TUDebuger::WarningLog("TapSupport Server Url is Empty"); + return; } - TimerHandle.Invalidate(); -} + if (CachedId.IsEmpty() || LoginType == ESupportLoginType::None) { + TUDebuger::WarningLog("TapSupport: Please Login first"); + return; + } + + TUSupportNet::FetchUnReadStatus( + LoginType, + CachedId, + [this](const FString& Model, const FTUError& Error) + { + NextDelay = FMath::Min(LOOP_MAX_SECONDS, NextDelay + LOOP_INC_SECONDS); + + if (Model.IsEmpty()) + { + bUnregister = Error.error_description == TEXT("USER_NOT_REGISTERED"); + TapUESupport::OnErrorCallBack.ExecuteIfBound(Error); + } + else + { + if (Model != UnreadStatus) + { + Resume(); + TapUESupport::OnUnreadStatusChanged.ExecuteIfBound(Model == "true"); + } + UnreadStatus = Model; + bUnregister = false; + } -FString TUSupportPCImpl::GetAnonymousID() { - // if (AnonymousID.IsEmpty()) { - // AnonymousID = TUDeviceInfo::GetLoginId(); - // } - return AnonymousID; + TUSettings::GetGameInstance()->GetTimerManager().SetTimer( + TimerHandle, + FTimerDelegate::CreateRaw(this, &TUSupportPCImpl::FetchLoop), + bUnregister ? UNREGISTER_SECONDS : NextDelay, + false); + }); } diff --git a/TapSupport/Source/TapSupport/Private/PC/TUSupportPCImpl.h b/TapSupport/Source/TapSupport/Private/PC/TUSupportPCImpl.h index 0f14e6d..a94c9e6 100644 --- a/TapSupport/Source/TapSupport/Private/PC/TUSupportPCImpl.h +++ b/TapSupport/Source/TapSupport/Private/PC/TUSupportPCImpl.h @@ -1,38 +1,40 @@ #pragma once #include "TUSupportImpl.h" +#include "Http.h" + class TUSupportPCImpl: public TUSupportImpl { public: TUSupportPCImpl(); virtual ~TUSupportPCImpl() override; virtual void Init(FTapSupportConfig _Config) override; - virtual void SetDefaultMetaData(TSharedPtr MetaData) override; virtual void SetDefaultFieldsData(TSharedPtr FieldsData) override; + virtual void UpdateDefaultField(const FString& Key, const TSharedPtr& NewValue) override; virtual void LoginAnonymously(const FString& UserID) override; - virtual FString GetSupportWebUrl(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) override; - virtual void OpenSupportView(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) override; + virtual void LoginWithCustomCredential(const FString& Credential) override; + virtual void LoginWithTDSCredential(const FString& Credential, const FSimpleDelegate& OnSuccess, const FTapFailed& OnFailed) override; + virtual FString GetSupportWebUrl(const FString& Path, TSharedPtr FieldsData) override; + virtual void OpenSupportView(const FString& Path, TSharedPtr FieldsData) override; virtual void CloseSupportView() override; virtual void Resume() override; virtual void Pause() override; virtual void Logout() override; virtual void FetchUnReadStatus() override; + virtual void OpenFullUrl(const FString& Path); + private: - TSharedPtr DefaultMetaData; + void NetTDSLoginCallback(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FSimpleDelegate OnSuccess, FTapFailed OnFailed); + + void FetchLoop(); + TSharedPtr DefaultFieldsData; - FString AnonymousID; + FString CachedId; + ESupportLoginType LoginType = ESupportLoginType::None; FString UnreadStatus; - bool StopNotification = true; - - void StartNext(); - FTimerHandle TimerHandle; - int32 NextDelay = 10; - - void CancelTimer(); - FString GetAnonymousID(); - // FString EncodeJsonObject(TSharedPtr JsonObject); + float NextDelay = 10.f; + bool bUnregister = false; + bool bWebOpen = false; }; diff --git a/TapSupport/Source/TapSupport/Private/TUSupportImpl.cpp b/TapSupport/Source/TapSupport/Private/TUSupportImpl.cpp index adf1e2b..43c0160 100644 --- a/TapSupport/Source/TapSupport/Private/TUSupportImpl.cpp +++ b/TapSupport/Source/TapSupport/Private/TUSupportImpl.cpp @@ -29,11 +29,12 @@ void TUSupportImpl::Init(FTapSupportConfig _Config) { UnsupportedPlatformsLog } -void TUSupportImpl::SetDefaultMetaData(TSharedPtr MetaData) { +void TUSupportImpl::SetDefaultFieldsData(TSharedPtr FieldsData) { UnsupportedPlatformsLog } -void TUSupportImpl::SetDefaultFieldsData(TSharedPtr FieldsData) { +void TUSupportImpl::UpdateDefaultField(const FString& Key, const TSharedPtr& NewValue) +{ UnsupportedPlatformsLog } @@ -45,14 +46,12 @@ void TUSupportImpl::Logout() { UnsupportedPlatformsLog } -FString TUSupportImpl::GetSupportWebUrl(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) { +FString TUSupportImpl::GetSupportWebUrl(const FString& Path, TSharedPtr FieldsData) { UnsupportedPlatformsLog return ""; } -void TUSupportImpl::OpenSupportView(const FString& Path, TSharedPtr MetaData, - TSharedPtr FieldsData) { +void TUSupportImpl::OpenSupportView(const FString& Path, TSharedPtr FieldsData) { UnsupportedPlatformsLog } diff --git a/TapSupport/Source/TapSupport/Private/TUSupportImpl.h b/TapSupport/Source/TapSupport/Private/TUSupportImpl.h index 62e2f26..3211e9a 100644 --- a/TapSupport/Source/TapSupport/Private/TUSupportImpl.h +++ b/TapSupport/Source/TapSupport/Private/TUSupportImpl.h @@ -1,6 +1,19 @@ #pragma once +#include "TUError.h" #include "TUSupportType.h" +enum class ESupportLoginType : uint8 +{ + None, + Anonymous, + Custom, + TDS +}; + +#define LOOP_INC_SECONDS 10.f +#define LOOP_MAX_SECONDS 300.f +#define UNREGISTER_SECONDS 3600.f + class TUSupportImpl { public: @@ -12,18 +25,22 @@ class TUSupportImpl { virtual void Init(FTapSupportConfig _Config); - virtual void SetDefaultMetaData(TSharedPtr MetaData); - virtual void SetDefaultFieldsData(TSharedPtr FieldsData); + virtual void UpdateDefaultField(const FString& Key, const TSharedPtr& NewValue); + virtual void LoginAnonymously(const FString& UserID); - virtual void Logout(); + virtual void LoginWithCustomCredential(const FString& Credential) = 0; + + virtual void LoginWithTDSCredential(const FString& Credential, const FSimpleDelegate& OnSuccess, const FTapFailed& OnFailed) = 0; - virtual FString GetSupportWebUrl(const FString& Path, TSharedPtr MetaData, TSharedPtr FieldsData); + virtual void Logout(); - virtual void OpenSupportView(const FString& Path, TSharedPtr MetaData, TSharedPtr FieldsData); + virtual FString GetSupportWebUrl(const FString& Path, TSharedPtr FieldsData); + virtual void OpenSupportView(const FString& Path, TSharedPtr FieldsData); + virtual void CloseSupportView(); virtual void Resume(); diff --git a/TapSupport/Source/TapSupport/Private/TapUESupport.cpp b/TapSupport/Source/TapSupport/Private/TapUESupport.cpp index 4fb4b6c..a693b4e 100644 --- a/TapSupport/Source/TapSupport/Private/TapUESupport.cpp +++ b/TapSupport/Source/TapSupport/Private/TapUESupport.cpp @@ -10,29 +10,53 @@ void TapUESupport::Init(FTapSupportConfig Config) { } void TapUESupport::SetDefaultMetaData(TSharedPtr MetaData) { - TUSupportImpl::Get()->SetDefaultMetaData(MetaData); + ensureMsgf(false, TEXT("'SetDefaultMetaData' is deprecated. Please use 'SetDefaultFieldsData' instead!")); } void TapUESupport::SetDefaultFieldsData(TSharedPtr FieldsData) { TUSupportImpl::Get()->SetDefaultFieldsData(FieldsData); } +void TapUESupport::UpdateDefaultField(const FString& Key, const TSharedPtr& NewValue) +{ + TUSupportImpl::Get()->UpdateDefaultField(Key, NewValue); +} + void TapUESupport::LoginAnonymously(const FString& UserID) { TUSupportImpl::Get()->LoginAnonymously(UserID); } +void TapUESupport::LoginWithCustomCredential(const FString& Credential) +{ + TUSupportImpl::Get()->LoginWithCustomCredential(Credential); +} + +void TapUESupport::LoginWithTDSCredential(const FString& Credential, const FSimpleDelegate& OnSuccess, const FTapFailed& OnFailed) +{ + TUSupportImpl::Get()->LoginWithTDSCredential(Credential, OnSuccess, OnFailed); +} + void TapUESupport::Logout() { TUSupportImpl::Get()->Logout(); } FString TapUESupport::GetSupportWebUrl(const FString& Path, TSharedPtr MetaData, TSharedPtr FieldsData) { - return TUSupportImpl::Get()->GetSupportWebUrl(Path, MetaData, FieldsData); + return TEXT(""); } void TapUESupport::OpenSupportView(const FString& Path, TSharedPtr MetaData, TSharedPtr FieldsData) { - TUSupportImpl::Get()->OpenSupportView(Path, MetaData, FieldsData); +} + +FString TapUESupport::GetSupportWebUrlV2(const FString& Path, TSharedPtr Fields) +{ + return TUSupportImpl::Get()->GetSupportWebUrl(Path, Fields); +} + +void TapUESupport::OpenSupportViewV2(const FString& Path, TSharedPtr Fields) +{ + TUSupportImpl::Get()->OpenSupportView(Path, Fields); } void TapUESupport::CloseSupportView() { diff --git a/TapSupport/Source/TapSupport/Public/TapUESupport.h b/TapSupport/Source/TapSupport/Public/TapUESupport.h index 8c1d9ed..adc11ef 100644 --- a/TapSupport/Source/TapSupport/Public/TapUESupport.h +++ b/TapSupport/Source/TapSupport/Public/TapUESupport.h @@ -1,7 +1,7 @@ #pragma once -#define TapUESupport_VERSION_NUMBER "31700001" -#define TapUESupport_VERSION "3.17.0" +#define TapUESupport_VERSION_NUMBER "31800001" +#define TapUESupport_VERSION "3.18.0" #include "TUError.h" #include "TUSupportType.h" @@ -11,46 +11,93 @@ class TAPSUPPORT_API TapUESupport { DECLARE_DELEGATE_OneParam(FErrorDelegate, const FTUError&); DECLARE_DELEGATE_OneParam(FUnreadStatusChangedDelegate, bool); - /// 初始化 - /// @param Config 配置信息 + + /** + * @brief Init support module + * @param Config Support module configuration data + */ static void Init(FTapSupportConfig Config); + /** + * @brief Error callback when fetch unread message state + */ static FErrorDelegate OnErrorCallBack; + + /** + * @brief Unread message state changed delegate + */ static FUnreadStatusChangedDelegate OnUnreadStatusChanged; + UE_DEPRECATED(4.0, "'SetDefaultMetaData' is deprecated. Please use 'SetDefaultFieldsData' instead!") static void SetDefaultMetaData(TSharedPtr MetaData); + /** + * @brief Set default field data to DC + * @param FieldsData The default key-value field data + */ static void SetDefaultFieldsData(TSharedPtr FieldsData); - /// 匿名用户登录 - /// @param UserID 匿名用户id,不能为空 + /** + * @brief Update specify field data + */ + static void UpdateDefaultField(const FString& Key, const TSharedPtr& NewValue); + + + /** + * @brief Anonymously login + * @param UserID At least 32 characters + */ static void LoginAnonymously(const FString& UserID); - /// 登出 + /** + * @brief Custom login + */ + static void LoginWithCustomCredential(const FString& Credential); + + /** + * @brief Async login with TDSUser + * @param Credential @see FTDSUser::RetrieveShortToken + */ + static void LoginWithTDSCredential(const FString& Credential, const FSimpleDelegate& OnSuccess, const FTapFailed& OnFailed); + + /** + * @brief Clear login user data + */ static void Logout(); - /// 获取网页地址 - /// @param Path 路径 - /// @param MetaData meta 参数 - /// @param FieldsData fields 参数 + UE_DEPRECATED(4.0, "'MetaData' is deprecated. Please use GetSupportWebUrl(Two params) instead!") static FString GetSupportWebUrl(const FString& Path = "", TSharedPtr MetaData = nullptr, TSharedPtr FieldsData = nullptr); - /// 打开客服网页 - /// @param Path 路径 - /// @param MetaData meta 参数 - /// @param FieldsData fields 参数 + UE_DEPRECATED(4.0, "'MetaData' is deprecated. Please use OpenSupportView(Two params) instead!") static void OpenSupportView(const FString& Path = "", TSharedPtr MetaData = nullptr, TSharedPtr FieldsData = nullptr); - /// 关闭客服网页 + /** + * @brief Generate web url + */ + static FString GetSupportWebUrlV2(const FString& Path = TEXT("/"), TSharedPtr Fields = nullptr); + + /** + * @brief Open support web view in system browser + */ + static void OpenSupportViewV2(const FString& Path = TEXT("/"), TSharedPtr Fields = nullptr); + + /** + * @brief Close opened system web browser (Mobile only) + */ static void CloseSupportView(); - /// 开始轮询获取未读状态 + /** + * @brief Resume timer fetch unread message + */ static void Resume(); - /// 结束轮询获取未读状态 + /** + * @brief Stop timer fetch unread message + */ static void Pause(); - /// 单次获取未读状态 + /** + * @brief Fetch unread message immediately, and trigger callback if need + */ static void FetchUnReadStatus(); - }; diff --git a/TapSupport/Source/TapSupport/TapSupport_Android_UPL.xml b/TapSupport/Source/TapSupport/TapSupport_Android_UPL.xml index 714b497..cca9623 100644 --- a/TapSupport/Source/TapSupport/TapSupport_Android_UPL.xml +++ b/TapSupport/Source/TapSupport/TapSupport_Android_UPL.xml @@ -18,7 +18,7 @@ - dependencies.implementation(name: 'TapSupport_3.17.0',ext:'aar') + dependencies.implementation(name: 'TapSupport_3.18.0',ext:'aar') \ No newline at end of file diff --git a/TapSupport/Source/ThirdParty/Android/Libs/TapSupport_3.17.0.aar b/TapSupport/Source/ThirdParty/Android/Libs/TapSupport_3.17.0.aar deleted file mode 100644 index 4cf92de..0000000 Binary files a/TapSupport/Source/ThirdParty/Android/Libs/TapSupport_3.17.0.aar and /dev/null differ diff --git a/TapSupport/Source/ThirdParty/Android/Libs/TapSupport_3.18.0.aar b/TapSupport/Source/ThirdParty/Android/Libs/TapSupport_3.18.0.aar new file mode 100644 index 0000000..9016e5f Binary files /dev/null and b/TapSupport/Source/ThirdParty/Android/Libs/TapSupport_3.18.0.aar differ diff --git a/TapSupport/Source/ThirdParty/iOS/Frameworks/TapSupportSDK.zip b/TapSupport/Source/ThirdParty/iOS/Frameworks/TapSupportSDK.zip index 09e0d09..b93085c 100644 Binary files a/TapSupport/Source/ThirdParty/iOS/Frameworks/TapSupportSDK.zip and b/TapSupport/Source/ThirdParty/iOS/Frameworks/TapSupportSDK.zip differ diff --git a/TapSupport/TapSupport.uplugin b/TapSupport/TapSupport.uplugin index 3c1e98e..bdb36dd 100644 --- a/TapSupport/TapSupport.uplugin +++ b/TapSupport/TapSupport.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 31605001, - "VersionName": "3.17.0", + "Version": 31800001, + "VersionName": "3.18.0", "FriendlyName": "TapSupport", "Description": "TapTap Support", "Category": "TapTap",