-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" ?> | ||
<dependencies> | ||
<androidPackages> | ||
<repositories> | ||
<repository>https://repo.maven.apache.org/maven2</repository> | ||
</repositories> | ||
<androidPackage spec="com.taptap.sdk:tap-login-unity:4.4.2"/> | ||
</androidPackages> | ||
<iosPods> | ||
<sources> | ||
<source>https://github.com/CocoaPods/Specs.git</source> | ||
</sources> | ||
<iosPod name="Kingfisher" version="~> 6.0" bitcodeEnabled="false" addToAllTargets="false"/> | ||
<iosPod name="TapTapLoginSDK" version="~> 4.4.0" bitcodeEnabled="false" addToAllTargets="false"/> | ||
</iosPods> | ||
</dependencies> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.IO; | ||
using TapSDK.Core.Editor; | ||
using UnityEditor; | ||
using UnityEditor.Callbacks; | ||
#if UNITY_IOS || UNITY_STANDALONE_OSX | ||
using UnityEditor.iOS.Xcode; | ||
#endif | ||
using UnityEngine; | ||
|
||
namespace TapSDK.Login.Editor | ||
{ | ||
#if UNITY_IOS || UNITY_STANDALONE_OSX | ||
public static class TapLoginIOSProcessor | ||
{ | ||
// 添加标签,unity导出工程后自动执行该函数 | ||
[PostProcessBuild(103)] | ||
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) | ||
{ | ||
var parentFolder = Directory.GetParent(Application.dataPath)?.FullName; | ||
|
||
var plistFile = TapFileHelper.RecursionFilterFile(parentFolder + "/Assets/Plugins/", "TDS-Info.plist"); | ||
|
||
if (plistFile == null || !plistFile.Exists) | ||
{ | ||
Debug.LogError("TapSDK Can't find TDS-Info.plist in Project/Assets/Plugins/!"); | ||
} | ||
|
||
|
||
if (buildTarget is BuildTarget.iOS) | ||
{ | ||
#if UNITY_IOS | ||
TapSDKCoreCompile.HandlerPlist(Path.GetFullPath(path), plistFile?.FullName ?? null); | ||
#endif | ||
} | ||
else if (buildTarget is BuildTarget.StandaloneOSX) | ||
{ | ||
Debug.Log($"path:{path}"); | ||
Debug.Log($"path:{Path.GetFullPath(path)}"); | ||
Debug.Log($"dir:{Path.GetDirectoryName(path)}"); | ||
Debug.Log($"dir:{Path.GetFileName(path)}"); | ||
// 获得工程路径 | ||
#if UNITY_2020_1_OR_NEWER | ||
var directory = Path.GetDirectoryName(path); | ||
if (string.IsNullOrEmpty(directory)) | ||
{ | ||
directory = ""; | ||
} | ||
|
||
var fileName = Path.GetFileName(path); | ||
if (!fileName.EndsWith(".xcodeproj")) | ||
{ | ||
fileName += ".xcodeproj"; | ||
} | ||
|
||
var projPath = Path.Combine(directory, $"{fileName}/project.pbxproj"); | ||
#elif UNITY_2019_1_OR_NEWER | ||
var projPath = Path.Combine(path, "project.pbxproj"); | ||
#else | ||
#endif | ||
#if UNITY_IOS | ||
TapSDKCoreCompile.HandlerPlist(Path.GetFullPath(path), plistFile.FullName, true); | ||
#endif | ||
} | ||
|
||
#if UNITY_IOS | ||
var projPath1 = TapSDKCoreCompile.GetProjPath(path); | ||
var proj = TapSDKCoreCompile.ParseProjPath(projPath1); | ||
var target = TapSDKCoreCompile.GetUnityTarget(proj); | ||
if (TapSDKCoreCompile.CheckTarget(target)) | ||
{ | ||
Debug.LogError("Unity-iPhone is NUll"); | ||
return; | ||
} | ||
if (TapSDKCoreCompile.HandlerIOSSetting(path, | ||
Application.dataPath, | ||
"TapTapLoginResource", | ||
"com.taptap.sdk.login", | ||
"Login", | ||
new[] {"TapTapLoginResource.bundle"}, | ||
target, projPath1, proj, "TapTapLoginSDK")) | ||
{ | ||
Debug.Log("TapLogin add Bundle Success!"); | ||
return; | ||
} | ||
Debug.LogWarning("TapLogin add Bundle Failed!"); | ||
#endif | ||
} | ||
} | ||
#endif | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using UnityEditor.Build.Reporting; | ||
using TapSDK.Core.Editor; | ||
|
||
namespace TapSDK.Login.Mobile.Editor { | ||
public class TapLoginMobileProcessBuild : SDKLinkProcessBuild { | ||
public override int callbackOrder => 0; | ||
|
||
public override string LinkPath => "TapSDK/Login/link.xml"; | ||
|
||
public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[] { | ||
new LinkedAssembly { Fullname = "TapSDK.Login.Runtime" }, | ||
new LinkedAssembly { Fullname = "TapSDK.Login.Mobile.Runtime" } | ||
}; | ||
|
||
public override Func<BuildReport, bool> IsTargetPlatform => (report) => { | ||
return BuildTargetUtils.IsSupportMobile(report.summary.platform); | ||
}; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "TapSDK.Login.Mobile.Editor", | ||
"references": [ | ||
"GUID:56f3da7a178484843974054bafe77e73" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using TapSDK.Core; | ||
using TapSDK.Login; | ||
using UnityEngine; | ||
|
||
namespace TapSDK.Login.Mobile.Runtime | ||
{ | ||
public class AccountWrapper | ||
{ | ||
public int code { get; } | ||
|
||
[CanBeNull] public string message { get; } | ||
|
||
[CanBeNull] public TapTapAccount account { get; } | ||
|
||
public AccountWrapper(string json) | ||
{ | ||
if (string.IsNullOrEmpty(json)) | ||
{ | ||
return; | ||
} | ||
var dict = Json.Deserialize(json) as Dictionary<string, object>; | ||
code = SafeDictionary.GetValue<int>(dict, "code"); | ||
message = SafeDictionary.GetValue<string>(dict, "message"); | ||
if (dict.ContainsKey("content") && dict["content"] is Dictionary<string, object> accountDict) | ||
{ | ||
account = new TapTapAccount(accountDict); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "TapSDK.Login.Mobile.Runtime", | ||
"references": [ | ||
"GUID:e8754b6153389406c963cd52996cc80f", | ||
"GUID:10560023d8780423cb943c7a324b69f2", | ||
"GUID:7d5ef2062f3704e1ab74aac0e4d5a1a7" | ||
], | ||
"includePlatforms": [ | ||
"Android", | ||
"iOS" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using TapSDK.Core; | ||
using TapSDK.Login.Mobile.Runtime; | ||
using TapSDK.Login.Internal; | ||
using UnityEngine; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace TapSDK.Login.Mobile | ||
{ | ||
public class TapTapLoginImpl: ITapTapLoginPlatform | ||
{ | ||
#if UNITY_IOS | ||
[DllImport("__Internal")] | ||
private static extern void RegisterTapTapSDKLoginAppDelegateListener(); | ||
#endif | ||
|
||
private const string SERVICE_NAME = "BridgeLoginService"; | ||
|
||
public void Init(string clientId, TapTapRegionType regionType) | ||
{ | ||
|
||
#if UNITY_IOS | ||
RegisterTapTapSDKLoginAppDelegateListener(); | ||
#endif | ||
|
||
EngineBridge.GetInstance().Register( | ||
"com.taptap.sdk.login.unity.BridgeLoginService", | ||
"com.taptap.sdk.login.unity.BridgeLoginServiceImpl"); | ||
} | ||
|
||
public Task<TapTapAccount> Login(string[] scopes) | ||
{ | ||
var tsc = new TaskCompletionSource<TapTapAccount>(); | ||
EngineBridge.GetInstance().CallHandler(new Command.Builder() | ||
.Service(SERVICE_NAME) | ||
.Method("loginWithScope") | ||
.Args("scopes", scopes) | ||
.Callback(true) | ||
.OnceTime(true) | ||
.CommandBuilder(), | ||
result => | ||
{ | ||
Debug.Log("Login result: " + result.content); | ||
var wrapper = new AccountWrapper(result.content); | ||
if (wrapper.code == 1) | ||
{ | ||
tsc.TrySetCanceled(); | ||
} else if (wrapper.code == 0) | ||
{ | ||
tsc.TrySetResult(wrapper.account); | ||
} | ||
else | ||
{ | ||
tsc.TrySetException(new Exception(wrapper.message)); | ||
} | ||
}); | ||
return tsc.Task; | ||
} | ||
|
||
public void Logout() | ||
{ | ||
EngineBridge.GetInstance().CallHandler(new Command.Builder() | ||
.Service(SERVICE_NAME) | ||
.Method("logout") | ||
.CommandBuilder()); | ||
} | ||
|
||
public async Task<TapTapAccount> GetCurrentAccount() | ||
{ | ||
Result result = await EngineBridge.GetInstance().Emit(new Command.Builder() | ||
.Service(SERVICE_NAME) | ||
.Method("getCurrentTapAccount") | ||
.Callback(true) | ||
.OnceTime(true) | ||
.CommandBuilder()); | ||
Debug.Log("Current account: " + result.content); | ||
return new AccountWrapper(result.content).account; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.