feat:update upm
commit
fa9e703462
|
@ -0,0 +1,222 @@
|
|||
# ChangeLog
|
||||
|
||||
## 3.13.0
|
||||
### Fixed Bugs
|
||||
- Android & iOS: 支持新的 scope (basic_info & email)
|
||||
- Android: 修复一些情况下的错误崩溃
|
||||
- iOS: 支持更安全的有端授权协议
|
||||
|
||||
## 3.11.1
|
||||
|
||||
### Fixed Bugs
|
||||
- iOS: 修复登录模块对系统 URL 回调的使用方式
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.11.1
|
||||
|
||||
## 3.11.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.11.0
|
||||
|
||||
## 3.10.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.10.0
|
||||
|
||||
## 3.9.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.9.0
|
||||
|
||||
## 3.8.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.8.0
|
||||
|
||||
## 3.7.1
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.7.1
|
||||
|
||||
## 3.7.0
|
||||
|
||||
### Optimization and fixed bugs
|
||||
- 添加获取互关列表接口
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.7.0
|
||||
|
||||
|
||||
## 3.6.3
|
||||
|
||||
### Optimization and fixed bugs
|
||||
- Android 尝试修复静态变量丢失的问题
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.6.3
|
||||
|
||||
## 3.6.1
|
||||
|
||||
### Optimization and fixed bugs
|
||||
- UI 优化
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.6.1
|
||||
|
||||
## 3.6.0
|
||||
|
||||
### Optimization and fixed bugs
|
||||
|
||||
- 优化未安装 iOS Support 时 Editor 编译问题
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.6.0
|
||||
|
||||
## 3.5.2
|
||||
|
||||
### New Feature
|
||||
|
||||
- 新增 PC Web 授权登录
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.5.2
|
||||
|
||||
## 3.5.0
|
||||
|
||||
### Optimization and fixed bugs
|
||||
- 内嵌 web 登录页面支持异形刘海屏的正常展示
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.5.0
|
||||
|
||||
## 3.4.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.4.0
|
||||
|
||||
## 3.3.0
|
||||
|
||||
### Optimization and fixed bugs
|
||||
|
||||
- 优化 iOS Plist.info 修改方式,防止覆盖工程原有配置。
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.3.0
|
||||
|
||||
## 3.2.1
|
||||
|
||||
### New Feature
|
||||
|
||||
- 新增 TapTap 登录权限配置范围
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.2.0
|
||||
|
||||
## 3.2.0
|
||||
|
||||
### New Feature
|
||||
|
||||
- 支持 PC 端使用 TapTap 登录
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.2.0
|
||||
|
||||
## 3.1.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.1.0
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### New Feature
|
||||
|
||||
- 新增 TapTap OAuth 相关接口
|
||||
```
|
||||
// 登陆
|
||||
TapLogin.Login();
|
||||
// 登出
|
||||
TapLogin.Logout();
|
||||
```
|
||||
- 新增篝火测试资格
|
||||
```
|
||||
var boolean = await TapLogin.GetTestQualification();
|
||||
```
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v3.0.0
|
||||
|
||||
## 2.1.7
|
||||
|
||||
### Optimization
|
||||
|
||||
- 更新 iOS 拦截 openUrl 方式
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.7
|
||||
|
||||
### 2.1.6
|
||||
|
||||
### Optimization and fixed bugs
|
||||
|
||||
- 修复 TapTap 授权登录的一些 UI 问题
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.6
|
||||
|
||||
### 2.1.5
|
||||
|
||||
### New Feature
|
||||
|
||||
- 云玩内唤起 TapTap 客户端登陆
|
||||
|
||||
### 2.1.4
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.4
|
||||
|
||||
### 2.1.3
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.3
|
||||
|
||||
### 2.1.2
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.2
|
||||
|
||||
## 2.1.1
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.1
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Feature
|
||||
|
||||
* TapTap Login
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eeb07bf1995f44e02bf1e2f6c996794c
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f2c93960c5ec14a968e71901b4eaeaab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,58 @@
|
|||
## TapTap.Login
|
||||
|
||||
## 使用前提
|
||||
|
||||
使用 TapTap.Login 前提是必须依赖以下库:
|
||||
|
||||
* [TapTap.Common](https://github.com/TapTap/TapCommon-Unity.git)
|
||||
|
||||
> 如果游戏需要支持 PC 平台 ,则参考[ PC配置文档 ](PC.md)
|
||||
|
||||
### 1.初始化
|
||||
|
||||
#### 如果配合 `TapBoostrap` 使用,则不需要调用初始化接口
|
||||
|
||||
```c#
|
||||
TapLogin.Init(string clientID);
|
||||
```
|
||||
|
||||
### 2.唤起 TapTap 网页 或者 TapTap 客户端进行登陆
|
||||
|
||||
登陆成功之后,会返回 `AccessToken`
|
||||
|
||||
```c#
|
||||
var accessToken = await TapLogin.Login();
|
||||
```
|
||||
|
||||
配置权限范围
|
||||
|
||||
```c#
|
||||
// 默认使用 public_profile
|
||||
|
||||
var accessToken = await TapLogin.Login(new []{"public_profile"})
|
||||
;
|
||||
```
|
||||
|
||||
### 3. 获取 TapTap AccessToken
|
||||
|
||||
```c#
|
||||
var accessToken = await TapLogin.GetAccessToken();
|
||||
```
|
||||
|
||||
### 4. 获取 TapTap Profile
|
||||
|
||||
```c#
|
||||
var profile = await TapLogin.FetchProfile();
|
||||
```
|
||||
|
||||
### 5. 获取篝火测试资格
|
||||
|
||||
```c#
|
||||
var boolean = await TapLogin.GetTestQualification();
|
||||
```
|
||||
|
||||
### 6. 退出登陆
|
||||
|
||||
```c#
|
||||
TapLogin.Logout();
|
||||
```
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bba3a05fa298643d1a20c3cab5614c17
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b342e9aa171b743c5996484a958afba5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b459e69a01b34fc29e293ebc89f27f6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,67 @@
|
|||
using System.IO;
|
||||
using TapTap.Common.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
#if UNITY_IOS || UNITY_STANDALONE_OSX
|
||||
using UnityEditor.iOS.Xcode;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.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.Exists)
|
||||
{
|
||||
Debug.LogError("TapSDK Can't find TDS-Info.plist in Project/Assets/Plugins/!");
|
||||
}
|
||||
|
||||
|
||||
if (buildTarget is BuildTarget.iOS)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
TapCommonCompile.HandlerPlist(Path.GetFullPath(path), plistFile.FullName);
|
||||
#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
|
||||
TapCommonCompile.HandlerPlist(Path.GetFullPath(path), plistFile.FullName, true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 543a4c42d7c774f1cb7a7b18b19c6c5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using TapTap.Common.Editor;
|
||||
|
||||
namespace TapTap.Login.Mobile.Editor {
|
||||
public class TapLoginMobileProcessBuild : SDKLinkProcessBuild {
|
||||
public override int callbackOrder => 0;
|
||||
|
||||
public override string LinkPath => "TapTap/Login/link.xml";
|
||||
|
||||
public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[] {
|
||||
new LinkedAssembly { Fullname = "TapTap.Login.Runtime" },
|
||||
new LinkedAssembly { Fullname = "TapTap.Login.Mobile.Runtime" }
|
||||
};
|
||||
|
||||
public override Func<BuildReport, bool> IsTargetPlatform => (report) => {
|
||||
return BuildTargetUtils.IsSupportMobile(report.summary.platform);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fa860a43f603e4d569a2efe38e2760d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "TapTap.Login.Mobile.Editor",
|
||||
"references": [
|
||||
"GUID:616cea76def2d4f059b94440fc8cc03d"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 60aa8897230d6419da34689f63383ebd
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8126ac1a2c05c468581fbae88a51caad
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,46 @@
|
|||
using System.Threading.Tasks;
|
||||
using TapTap.Common;
|
||||
|
||||
namespace TapTap.Login.Mobile
|
||||
{
|
||||
public interface ITapLogin
|
||||
{
|
||||
void Init(string clientID);
|
||||
|
||||
void Init(string clientID, bool isCn, bool roundCorner);
|
||||
|
||||
void ChangeConfig(bool roundCorner, bool isPortrait);
|
||||
|
||||
Task<Profile> FetchProfile();
|
||||
|
||||
Task<Profile> GetProfile();
|
||||
|
||||
Task<AccessToken> GetAccessToken();
|
||||
|
||||
Task<AccessToken> Login();
|
||||
|
||||
Task<AccessToken> Login(string[] permissions);
|
||||
|
||||
Task<bool> GetTestQualification();
|
||||
|
||||
void Logout();
|
||||
}
|
||||
|
||||
public interface ITapLoginResultListener
|
||||
{
|
||||
void LoginCancel();
|
||||
|
||||
void LoginError(TapError error);
|
||||
|
||||
void LoginSuccess(AccessToken token);
|
||||
}
|
||||
|
||||
public static class TapLoginConstants
|
||||
{
|
||||
public static string TAP_LOGIN_SERVICE = "TDSLoginService";
|
||||
|
||||
public static string TAP_LOGIN_SERVICE_CLZ = "com.taptap.sdk.wrapper.TDSLoginService";
|
||||
|
||||
public static string TAP_LOGIN_SERVICE_IMPL = "com.taptap.sdk.wrapper.TDSLoginServiceImpl";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 69b41de145ee74f908e40d3c44ff7b6a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,230 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TapTap.Common;
|
||||
|
||||
namespace TapTap.Login.Mobile
|
||||
{
|
||||
public class TapLoginImpl : ITapLogin
|
||||
{
|
||||
private TapLoginImpl()
|
||||
{
|
||||
EngineBridge.GetInstance()
|
||||
.Register(TapLoginConstants.TAP_LOGIN_SERVICE_CLZ, TapLoginConstants.TAP_LOGIN_SERVICE_IMPL);
|
||||
}
|
||||
|
||||
private static volatile TapLoginImpl _sInstance;
|
||||
|
||||
private static readonly object Locker = new object();
|
||||
|
||||
public static TapLoginImpl GetInstance()
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
if (_sInstance == null)
|
||||
{
|
||||
_sInstance = new TapLoginImpl();
|
||||
}
|
||||
}
|
||||
|
||||
return _sInstance;
|
||||
}
|
||||
|
||||
public void Init(string clientID)
|
||||
{
|
||||
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("init")
|
||||
.Args("clientID", clientID)
|
||||
.CommandBuilder());
|
||||
}
|
||||
|
||||
public void Init(string clientID, bool isCn, bool roundCorner)
|
||||
{
|
||||
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("initWithClientID")
|
||||
.Args("clientID", clientID)
|
||||
.Args("regionType", isCn)
|
||||
.Args("roundCorner", roundCorner)
|
||||
.CommandBuilder());
|
||||
}
|
||||
|
||||
public void ChangeConfig(bool roundCorner, bool isPortrait)
|
||||
{
|
||||
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("changeConfig")
|
||||
.Args("roundCorner", roundCorner)
|
||||
.Args("isPortrait", isPortrait)
|
||||
.CommandBuilder());
|
||||
}
|
||||
|
||||
|
||||
public async Task<Profile> FetchProfile()
|
||||
{
|
||||
var command = new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("fetchProfileForCurrentAccessToken")
|
||||
.Callback(true)
|
||||
.OnceTime(true)
|
||||
.CommandBuilder();
|
||||
var result = await EngineBridge.GetInstance().Emit(command);
|
||||
if (!EngineBridge.CheckResult(result))
|
||||
{
|
||||
throw new TapException((int)TapErrorCode.ERROR_CODE_BRIDGE_EXECUTE, "TapSDK fetchProfile Failed!");
|
||||
}
|
||||
|
||||
var loginWrapper = new TapLoginWrapper(result.content);
|
||||
if (loginWrapper.LoginCallbackCode == 0)
|
||||
{
|
||||
return new Profile(loginWrapper.Wrapper);
|
||||
}
|
||||
|
||||
throw new TapException((int)TapErrorCode.ERROR_CODE_BRIDGE_EXECUTE, loginWrapper.Wrapper);
|
||||
}
|
||||
|
||||
public async Task<Profile> GetProfile()
|
||||
{
|
||||
var command = new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("currentProfile")
|
||||
.Callback(true)
|
||||
.OnceTime(true)
|
||||
.CommandBuilder();
|
||||
var result = await EngineBridge.GetInstance().Emit(command);
|
||||
if (!EngineBridge.CheckResult(result))
|
||||
{
|
||||
throw new TapException((int)TapErrorCode.ERROR_CODE_BRIDGE_EXECUTE, "TapSDK GetProfile Failed!");
|
||||
}
|
||||
|
||||
return new Profile(result.content);
|
||||
}
|
||||
|
||||
public async Task<AccessToken> GetAccessToken()
|
||||
{
|
||||
var command = new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("currentAccessToken")
|
||||
.Callback(true)
|
||||
.OnceTime(true)
|
||||
.CommandBuilder();
|
||||
|
||||
var result = await EngineBridge.GetInstance().Emit(command);
|
||||
|
||||
if (!EngineBridge.CheckResult(result))
|
||||
{
|
||||
throw new TapException((int)TapErrorCode.ERROR_CODE_BRIDGE_EXECUTE, "TapSDK GetAccessToken Failed!");
|
||||
}
|
||||
|
||||
return new AccessToken(result.content);
|
||||
}
|
||||
|
||||
public async Task<AccessToken> Login()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<AccessToken>();
|
||||
RegisterLoginCallback(tcs);
|
||||
StartLogin(new[] { TapLogin.TAP_LOGIN_SCOPE_PUBLIC_PROFILE });
|
||||
return await tcs.Task;
|
||||
}
|
||||
|
||||
public async Task<AccessToken> Login(string[] permissions)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<AccessToken>();
|
||||
RegisterLoginCallback(tcs);
|
||||
StartLogin(permissions);
|
||||
return await tcs.Task;
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
var command = new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("logout")
|
||||
.CommandBuilder();
|
||||
|
||||
EngineBridge.GetInstance().CallHandler(command);
|
||||
}
|
||||
|
||||
public async Task<bool> GetTestQualification()
|
||||
{
|
||||
var command = new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("getTestQualification")
|
||||
.Callback(true)
|
||||
.OnceTime(true)
|
||||
.CommandBuilder();
|
||||
|
||||
var result = await EngineBridge.GetInstance().Emit(command);
|
||||
|
||||
if (!EngineBridge.CheckResult(result))
|
||||
{
|
||||
throw new TapException((int)TapErrorCode.ERROR_CODE_BRIDGE_EXECUTE,
|
||||
"TapSDK GetTestQualification Failed!");
|
||||
}
|
||||
|
||||
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
||||
var testQualification = SafeDictionary.GetValue<int>(dic, "userTestQualification");
|
||||
return testQualification == 1;
|
||||
}
|
||||
|
||||
private static void StartLogin(string[] permissions)
|
||||
{
|
||||
var command = new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("startTapLogin")
|
||||
.Args("permissions", permissions)
|
||||
.CommandBuilder();
|
||||
EngineBridge.GetInstance().CallHandler(command);
|
||||
}
|
||||
|
||||
|
||||
private static void RegisterLoginCallback(TaskCompletionSource<AccessToken> tcs)
|
||||
{
|
||||
var command = new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("registerLoginCallback")
|
||||
.Callback(true)
|
||||
.OnceTime(false)
|
||||
.CommandBuilder();
|
||||
|
||||
EngineBridge.GetInstance().CallHandler(command, result =>
|
||||
{
|
||||
if (!EngineBridge.CheckResult(result))
|
||||
{
|
||||
tcs.TrySetException(new TapException((int)TapErrorCode.ERROR_CODE_BRIDGE_EXECUTE,
|
||||
"TapSDK Login Failed!"));
|
||||
return;
|
||||
}
|
||||
|
||||
var wrapper = new TapLoginWrapper(result.content);
|
||||
|
||||
switch (wrapper.LoginCallbackCode)
|
||||
{
|
||||
case 0:
|
||||
tcs.TrySetResult(new AccessToken(wrapper.Wrapper));
|
||||
break;
|
||||
case 1:
|
||||
tcs.TrySetException(new TapException((int)TapErrorCode.ERROR_CODE_BIND_CANCEL,
|
||||
"Login Cancel"));
|
||||
break;
|
||||
default:
|
||||
var tapError = TapError.SafeConstructorTapError(wrapper.Wrapper);
|
||||
tcs.TrySetException(new TapException(tapError.code,
|
||||
tapError.errorDescription));
|
||||
break;
|
||||
}
|
||||
|
||||
UnRegisterLoginCallback();
|
||||
});
|
||||
}
|
||||
|
||||
private static void UnRegisterLoginCallback()
|
||||
{
|
||||
var command = new Command.Builder()
|
||||
.Service(TapLoginConstants.TAP_LOGIN_SERVICE)
|
||||
.Method("unregisterLoginCallback")
|
||||
.CommandBuilder();
|
||||
EngineBridge.GetInstance().CallHandler(command);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6a4684c9ef1d943ffba49b2e8d38906c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,57 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace TapTap.Login.Mobile
|
||||
{
|
||||
public class TapLoginMobile : Internal.ITapLoginPlatform
|
||||
{
|
||||
public void Init(string clientID)
|
||||
{
|
||||
TapLoginImpl.GetInstance().Init(clientID);
|
||||
}
|
||||
|
||||
public void Init(string clientID, bool isCn, bool roundCorner)
|
||||
{
|
||||
TapLoginImpl.GetInstance().Init(clientID, isCn, roundCorner);
|
||||
}
|
||||
|
||||
public void ChangeConfig(bool roundCorner, bool isPortrait)
|
||||
{
|
||||
TapLoginImpl.GetInstance().ChangeConfig(roundCorner, isPortrait);
|
||||
}
|
||||
|
||||
public Task<Profile> FetchProfile()
|
||||
{
|
||||
return TapLoginImpl.GetInstance().FetchProfile();
|
||||
}
|
||||
|
||||
public Task<Profile> GetProfile()
|
||||
{
|
||||
return TapLoginImpl.GetInstance().GetProfile();
|
||||
}
|
||||
|
||||
public Task<AccessToken> GetAccessToken()
|
||||
{
|
||||
return TapLoginImpl.GetInstance().GetAccessToken();
|
||||
}
|
||||
|
||||
public Task<AccessToken> Login()
|
||||
{
|
||||
return TapLoginImpl.GetInstance().Login();
|
||||
}
|
||||
|
||||
public Task<AccessToken> Login(string[] permissions)
|
||||
{
|
||||
return TapLoginImpl.GetInstance().Login(permissions);
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
TapLoginImpl.GetInstance().Logout();
|
||||
}
|
||||
|
||||
public Task<bool> GetTestQualification()
|
||||
{
|
||||
return TapLoginImpl.GetInstance().GetTestQualification();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4295ff79f49ab4cd6a6d8895c03abb78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
using TapTap.Common;
|
||||
|
||||
namespace TapTap.Login.Mobile
|
||||
{
|
||||
public class TapLoginWrapper
|
||||
{
|
||||
public string Wrapper;
|
||||
|
||||
public int LoginCallbackCode;
|
||||
|
||||
public TapLoginWrapper(string json)
|
||||
{
|
||||
var dic = Json.Deserialize(json) as Dictionary<string, object>;
|
||||
Wrapper = SafeDictionary.GetValue<string>(dic, "wrapper");
|
||||
LoginCallbackCode = SafeDictionary.GetValue<int>(dic, "loginCallbackCode");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 13f1c9f969a6c45ad906faf33c39c76e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "TapTap.Login.Mobile.Runtime",
|
||||
"references": [
|
||||
"GUID:e8754b6153389406c963cd52996cc80f",
|
||||
"GUID:0b3f64ec33f5b4da98a17367a35b82f2",
|
||||
"GUID:43c632eee0a6f42cdaf21080b154f3a1"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Android",
|
||||
"iOS"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6ff51c32c188e424b97bac52a5cb5184
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,60 @@
|
|||
# TapTap Login PC 登录接入文档
|
||||
|
||||
> TapTap.Login PC 支持 Window 以及 Mac 两种平台,提供 Web 浏览器授权以及 TapTap 客户端扫码登录
|
||||
|
||||
|
||||
## 在 Mac 平台使用 TapTap.Login
|
||||
|
||||
### 1. 编译配置
|
||||
|
||||
* 打开 *BuildSetting* 选择 *PC、Mac & Linux Standalone* Platform,*Target Platform* 选择 MacOS
|
||||
* 勾选 *Create XCode Project* ,选择输出 XCode 工程进行编译
|
||||
|
||||
### 2. 配置 URL Types
|
||||
|
||||
* 打开输出的 *XCode Project* , 选择 *Target* ,点击 *Info* ,展开 *URL Types*,请检查是否自动添加以下 URL Scheme,如果未添加,则手动添加进去。
|
||||
> TapWeb : open-taptap-{clientId}
|
||||
|
||||
* 或者修改 *Info.plist* ,添加以下配置
|
||||
|
||||
```xml
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>TapWeb</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>open-taptap-{client_id}</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
```
|
||||
|
||||
## 在 Window 平台使用 TapTap.Login
|
||||
|
||||
#### 给 Window 添加游戏注册表
|
||||
|
||||
```
|
||||
Windows Registry Editor Version 5.00
|
||||
|
||||
[HKEY_CLASSES_ROOT\open-taptap-{client_id}]
|
||||
@="{游戏名称}"
|
||||
"URL Protocol"="{程序.exe 安装路径}}"
|
||||
|
||||
[HKEY_CLASSES_ROOT\open-taptap-{client_id}]
|
||||
@="{游戏名称}"
|
||||
|
||||
[HKEY_CLASSES_ROOT\open-taptap-{client_id}]
|
||||
|
||||
[HKEY_CLASSES_ROOT\open-taptap-{client_id}\Shell\Open]
|
||||
|
||||
[HKEY_CLASSES_ROOT\open-taptap-{client_id}\Shell\Open\Command]
|
||||
@="\"{程序.exe 安装路径}\" \"%1\""
|
||||
|
||||
```
|
||||
|
||||
打开 Window 注册表编辑器,查看 `HKEY_CLASSES_ROOT\open-taptap-{clientId}` 是否存在以及等该目录下是否包含 `DefaultIcon`、`Shell\Open\Command` 是否匹配上文中的参数
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0acb126baaec47058c09c039fb0df359
|
||||
timeCreated: 1639126466
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 389763214cb6d491d83a645bbf33a750
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4b872f00946c04ccea41c19eb6ae406a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ef9a962e4bd24262a889ea13fed9c07
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5151181fcdc5945978d9dc210cb5523e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 667a75a1a23fe417c89c8e75fdba321b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,69 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0cb5e9195d4db4ef29b7f5c2c756f40e
|
||||
folderAsset: yes
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 0
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 171b732fe9f8c4837b7cb5628396fddb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// AccountGlobalError.h
|
||||
// TapTapLoginSource
|
||||
//
|
||||
// Created by Bottle K on 2020/12/15.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
FOUNDATION_EXPORT NSString *const LOGIN_ERROR_ACCESS_DENIED;
|
||||
FOUNDATION_EXPORT NSString *const LOGIN_ERROR_INVALID_GRANT;
|
||||
FOUNDATION_EXPORT NSString *const LOGIN_ERROR_PERMISSION_RESULT;
|
||||
|
||||
@interface AccountGlobalError : NSObject
|
||||
@property (nonatomic, assign) NSInteger code;
|
||||
@property (nonatomic, copy) NSString *msg;
|
||||
@property (nonatomic, copy) NSString *error;
|
||||
@property (nonatomic, copy) NSString *errorDescription;
|
||||
|
||||
- (instancetype)initWithName:(NSString *)errorName NSError:(NSError *)error;
|
||||
|
||||
- (NSString *)toJsonString;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b64f131357f1a4e3abcee048ecc0b7fd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// IscTapLoginService.h
|
||||
// Pods-TDSLoginSource_Example
|
||||
//
|
||||
// Created by Bottle K on 2020/12/15.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TapLoginSDK/TapLoginSDK.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface IscTapLoginService : NSObject
|
||||
+ (void)addSDKLoginResultDelegate:(NSString *)sdkName delegate:(id <TapTapLoginResultDelegate>)delegate;
|
||||
|
||||
+ (void)removeSDKLoginResultDelegate:(NSString *)sdkName;
|
||||
|
||||
+ (void)startSDKLogin:(NSString *)sdkName permission:(NSArray *)permissions;
|
||||
|
||||
+ (void)handleLoginError:(NSDictionary *)params;
|
||||
|
||||
+ (void)changeConfigWithClientId:(NSString *)clientId
|
||||
regionType:(RegionType)region
|
||||
token:(TTSDKAccessToken *)token;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 56d376a9fe0fc423aa3e40e2df791647
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,62 @@
|
|||
//
|
||||
// TTSDKAccessToken.h
|
||||
// TapTapSDK
|
||||
//
|
||||
// Created by TapTap on 2017/10/17.
|
||||
// Copyright © 2017年 易玩. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* @brief TapTap登录授权数据封装类
|
||||
*
|
||||
* 该类封装了所有授权提供的返回数据
|
||||
*/
|
||||
@interface TTSDKAccessToken : NSObject
|
||||
|
||||
/// 唯一标志
|
||||
@property (nonatomic, copy) NSString * kid;
|
||||
|
||||
/// 认证码
|
||||
@property (nonatomic, copy) NSString * accessToken;
|
||||
|
||||
/// 认证码类型
|
||||
@property (nonatomic, copy) NSString * tokenType;
|
||||
|
||||
/// mac密钥
|
||||
@property (nonatomic, copy) NSString * macKey;
|
||||
|
||||
/// mac密钥计算方式
|
||||
@property (nonatomic, copy) NSString * macAlgorithm;
|
||||
|
||||
/// 用户授权的权限,多个时以逗号隔开
|
||||
@property (nonatomic, copy) NSString * scope;
|
||||
|
||||
/// 用户授权的权限 Array 形式
|
||||
@property (nonatomic, copy) NSArray<NSString *> * scopeArray;
|
||||
|
||||
/// 根据JSON生成 TTSDKAccessToken
|
||||
/// @param accessTokenString json字符串类型的AccessToken
|
||||
+ (TTSDKAccessToken *)build:(NSString *)accessTokenString;
|
||||
|
||||
/// 通过参数生成实例
|
||||
+ (TTSDKAccessToken *)build:(NSString *)kid accessToken:(NSString *)accessToken tokenType:(NSString *)tokenType macKey:(NSString *)macKey macAlgorithm:(NSString *)macAlgorithm;
|
||||
|
||||
+ (TTSDKAccessToken *)build:(NSString *)kid accessToken:(NSString *)accessToken tokenType:(NSString *)tokenType macKey:(NSString *)macKey macAlgorithm:(NSString *)macAlgorithm scope:(NSArray *)scope;
|
||||
|
||||
/// 转换成json字符串
|
||||
- (NSString *)toJsonString;
|
||||
|
||||
+ (NSArray *)scopeStringToArray:(NSString *)scopeString;
|
||||
|
||||
/**
|
||||
* @brief 获取当前认证
|
||||
*
|
||||
* 该认证会优先读取本地缓存,不存在时将会返回nil
|
||||
*/
|
||||
+ (TTSDKAccessToken *)currentAccessToken;
|
||||
|
||||
+ (void)setCurrentToken:(TTSDKAccessToken *)token;
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ca1191d4b28db4188ab632cfe644acb8
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// TTSDKConfig.h
|
||||
// TapTapSDK
|
||||
//
|
||||
// Created by wzb on 2020/5/13.
|
||||
// Copyright © 2020 易玩. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define TapLoginSDKErrorDomain @"TapLoginSDKErrorDomain"
|
||||
|
||||
typedef NS_ENUM (NSInteger, RegionType) {
|
||||
RegionTypeCN,
|
||||
RegionTypeIO
|
||||
};
|
||||
|
||||
@interface TTSDKConfig : NSObject
|
||||
|
||||
/// 是否为圆角,默认为圆角
|
||||
@property (nonatomic, assign) BOOL roundCorner;
|
||||
/// 限定登录客户端
|
||||
@property (nonatomic, assign) RegionType regionType;
|
||||
/// Server URL
|
||||
@property (nonatomic, copy) NSString *serverURL;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f78a3c00039b1495a8de303c85af6fa4
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// TTSDKLoginResult.h
|
||||
// TapTapSDK
|
||||
//
|
||||
// Created by TapTap on 2017/10/17.
|
||||
// Copyright © 2017年 易玩. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class TTSDKAccessToken;
|
||||
|
||||
/**
|
||||
* @brief 登入结果
|
||||
*
|
||||
* 该类封装了登入的响应结果(非NSError情况下)
|
||||
*/
|
||||
@interface TTSDKLoginResult : NSObject
|
||||
|
||||
/// 授权Token
|
||||
@property (nonatomic, copy) TTSDKAccessToken *token;
|
||||
|
||||
/// 用户是否选择取消授权(非拒绝授权,拒绝授权将在NSError中进行返回)
|
||||
@property (nonatomic, readonly) BOOL isCancelled;
|
||||
|
||||
- (instancetype)initWithToken:(TTSDKAccessToken *)token
|
||||
isCancelled:(BOOL)isCancelled;
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0da0eb4d246e5447fb10b08663acfa9a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// TTSDKProfile.h
|
||||
// TapTapSDK
|
||||
//
|
||||
// Created by TapTap on 2017/10/27.
|
||||
// Copyright © 2017年 易玩. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* @brief TapTap用户信息封装类
|
||||
*
|
||||
* 该类封装了所有用户信息提供的返回数据
|
||||
*/
|
||||
@interface TTSDKProfile : NSObject
|
||||
|
||||
/// 用户名
|
||||
@property (nonatomic, readonly, strong) NSString *name;
|
||||
|
||||
/// 用户头像
|
||||
@property (nonatomic, readonly, strong) NSString *avatar;
|
||||
|
||||
/// open id
|
||||
@property (nonatomic, readonly, strong) NSString *openid;
|
||||
|
||||
/// union id
|
||||
@property (nonatomic, readonly, strong) NSString *unionid;
|
||||
|
||||
@property (nonatomic, readonly, strong) NSString *email;
|
||||
|
||||
@property (nonatomic, readonly, assign, getter = isEmailVerified) BOOL emailVerified;
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)json;
|
||||
|
||||
/**
|
||||
* @brief 获取当前用户信息
|
||||
*
|
||||
* 该用户信息会优先读取本地缓存,不存在时将会返回nil
|
||||
*/
|
||||
+ (TTSDKProfile *)currentProfile;
|
||||
|
||||
+ (void)fetchProfileForCurrentAccessToken:(void (^)(TTSDKProfile *profile, NSError *error))handler;
|
||||
|
||||
- (NSString *)toJsonString;
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c5d7d17194cda40d18631256e04d00aa
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// TapFriends.h
|
||||
// TapLoginSDK
|
||||
//
|
||||
// Created by pzheng on 2022/02/23.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// Tap Friend Info
|
||||
@interface TapFriendInfo : NSObject
|
||||
|
||||
/// Nickname.
|
||||
@property (nonatomic, readonly) NSString *name;
|
||||
|
||||
/// Avatar.
|
||||
@property (nonatomic, readonly) NSString *avatar;
|
||||
|
||||
/// Open ID.
|
||||
@property (nonatomic, readonly) NSString *openid;
|
||||
|
||||
@end
|
||||
|
||||
/// Query Result
|
||||
@interface TapFriendResult : NSObject
|
||||
|
||||
/// List of `TapFriendInfo`.
|
||||
@property (nonatomic, nullable, readonly) NSArray<TapFriendInfo *> *data;
|
||||
|
||||
/// The start index of the next query.
|
||||
@property (nonatomic, nullable, readonly) NSString *cursor;
|
||||
|
||||
@end
|
||||
|
||||
/// Query Option
|
||||
@interface TapFriendQueryOption : NSObject
|
||||
|
||||
/// The limit of the result.
|
||||
@property (nonatomic) NSUInteger size;
|
||||
|
||||
/// The start index of this query.
|
||||
@property (nonatomic, nullable) NSString *cursor;
|
||||
|
||||
@end
|
||||
|
||||
/// Tap Friends
|
||||
@interface TapFriends : NSObject
|
||||
|
||||
/// Query mutual list.
|
||||
/// @param option See `TapFriendQueryOption`.
|
||||
/// @param callback Result callback.
|
||||
+ (void)queryMutualListWithOption:(TapFriendQueryOption * _Nullable)option
|
||||
callback:(void (^)(TapFriendResult * _Nullable result, NSError * _Nullable error))callback;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 91e438df41aea4bc9b8fffb15bff9bf9
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,79 @@
|
|||
//
|
||||
// TapLoginHelper.h
|
||||
// TapTapLoginSource
|
||||
//
|
||||
// Created by Bottle K on 2020/12/2.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TapLoginSDK/TTSDKConfig.h>
|
||||
#import <TapLoginSDK/TTSDKAccessToken.h>
|
||||
#import <TapLoginSDK/TTSDKProfile.h>
|
||||
#import <TapLoginSDK/TTSDKLoginResult.h>
|
||||
#import <TapLoginSDK/AccountGlobalError.h>
|
||||
#import <TapLoginSDK/TapTapLoginResultDelegate.h>
|
||||
|
||||
#define TapLoginSDK @"TapLogin"
|
||||
#define TapLoginSDK_VERSION_NUMBER @"31901001"
|
||||
#define TapLoginSDK_VERSION @"3.19.1"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TapLoginHelper : NSObject
|
||||
|
||||
/// 初始化
|
||||
/// @param clientID clientID
|
||||
+ (void)initWithClientID:(NSString *)clientID;
|
||||
|
||||
/// 初始化
|
||||
/// @param clientID clientID
|
||||
/// @param config 配置项
|
||||
+ (void)initWithClientID:(NSString *)clientID config:(TTSDKConfig *_Nullable)config;
|
||||
|
||||
/// 修改登录配置
|
||||
/// @param config 配置项
|
||||
+ (void)changeTapLoginConfig:(TTSDKConfig *_Nullable)config;
|
||||
|
||||
/// 设置登录回调
|
||||
/// @param delegate 回调
|
||||
+ (void)registerLoginResultDelegate:(id <TapTapLoginResultDelegate>)delegate;
|
||||
|
||||
/// 移除登录回调
|
||||
+ (void)unregisterLoginResultDelegate;
|
||||
|
||||
/// 获取当前设置的登录回调
|
||||
+ (id <TapTapLoginResultDelegate>)getLoginResultDelegate;
|
||||
|
||||
/// 开始登录流程
|
||||
/// @param permissions 权限列表
|
||||
+ (void)startTapLogin:(NSArray *)permissions;
|
||||
|
||||
/// 获取当前 Token
|
||||
+ (TTSDKAccessToken *)currentAccessToken;
|
||||
|
||||
/// 获取当前 Profile
|
||||
+ (TTSDKProfile *)currentProfile;
|
||||
|
||||
/// 获取当前服务器上最新的 Profile
|
||||
/// @param callback 回调
|
||||
+ (void)fetchProfileForCurrentAccessToken:(void (^)(TTSDKProfile *profile, NSError *error))callback;
|
||||
|
||||
/// 登出
|
||||
+ (void)logout;
|
||||
|
||||
/// 获取当前用户是否有测试资格
|
||||
/// @param callback 回调
|
||||
+ (void)getTestQualification:(void (^)(BOOL isQualified, NSError *_Nullable error))callback;
|
||||
|
||||
/// 当前是否有国内客户端支持
|
||||
+ (BOOL)isTapTapClientSupport;
|
||||
|
||||
/// 当前是否有国外客户端支持
|
||||
+ (BOOL)isTapTapGlobalClientSupport;
|
||||
|
||||
/// 监听 url 回调
|
||||
/// @param url url
|
||||
+ (BOOL)handleTapTapOpenURL:(NSURL *)url __attribute__((deprecated("Please use [TDSHandleUrl handleOpenURL:]")));
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae7152728fd9c4a06800a21a26968465
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// TapLoginSDK.h
|
||||
// TapLoginSDK
|
||||
//
|
||||
// Created by Bottle K on 2021/3/25.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for TapLoginSDK.
|
||||
FOUNDATION_EXPORT double TapLoginSDKVersionNumber;
|
||||
|
||||
//! Project version string for TapLoginSDK.
|
||||
FOUNDATION_EXPORT const unsigned char TapLoginSDKVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <TapLoginSDK/PublicHeader.h>
|
||||
|
||||
#import <TapLoginSDK/TTSDKConfig.h>
|
||||
#import <TapLoginSDK/TapLoginHelper.h>
|
||||
#import <TapLoginSDK/TTSDKProfile.h>
|
||||
#import <TapLoginSDK/TTSDKAccessToken.h>
|
||||
#import <TapLoginSDK/AccountGlobalError.h>
|
||||
#import <TapLoginSDK/TTSDKLoginResult.h>
|
||||
#import <TapLoginSDK/IscTaploginService.h>
|
||||
#import <TapLoginSDK/TapTapLoginResultDelegate.h>
|
||||
#import <TapLoginSDK/TapFriends.h>
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: beb0f65d46a6345ae940dffd322cad95
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// TapTapLoginResultDelegate.h
|
||||
// Pods-TDSLoginSource_Example
|
||||
//
|
||||
// Created by Bottle K on 2020/12/15.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TapLoginSDK/AccountGlobalError.h>
|
||||
#import <TapLoginSDK/TTSDKAccessToken.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol TapTapLoginResultDelegate <NSObject>
|
||||
|
||||
/// 登录成功回调
|
||||
/// @param token token对象
|
||||
- (void)onLoginSuccess:(TTSDKAccessToken *)token;
|
||||
|
||||
/// 登录取消
|
||||
- (void)onLoginCancel;
|
||||
|
||||
/// 登录失败
|
||||
/// @param error 失败原因
|
||||
- (void)onLoginError:(AccountGlobalError *)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c65dd21f3aee54e6f83eaba1b5f3b4af
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a425b7174df844844a1a03d3216ee120
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c7ccb2201ac1545ee97a2518f7c70cc6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,6 @@
|
|||
framework module TapLoginSDK {
|
||||
umbrella header "TapLoginSDK.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9ee1754935e11442ab51454950dd37a7
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 280aa7755723542c3b75ebf67cf80a3f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 44603b497110848c1bee102b300ad164
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,58 @@
|
|||
## [TapTap.Login](./Documentation/README.md)
|
||||
|
||||
## 使用前提
|
||||
|
||||
使用 TapTap.Login 前提是必须依赖以下库:
|
||||
|
||||
* [TapTap.Common](https://github.com/TapTap/TapCommon-Unity.git)
|
||||
|
||||
> 如果游戏需要支持 PC Platform ,则参考[ PC配置文档 ](./PC.md)
|
||||
|
||||
### 1.初始化
|
||||
|
||||
#### 如果配合 `TapBoostrap` 使用,则不需要调用初始化接口
|
||||
|
||||
```c#
|
||||
TapLogin.Init(string clientID);
|
||||
```
|
||||
|
||||
### 2.唤起 TapTap 网页 或者 TapTap 客户端进行登陆
|
||||
|
||||
登陆成功之后,会返回 `AccessToken`
|
||||
|
||||
```c#
|
||||
var accessToken = await TapLogin.Login();
|
||||
```
|
||||
|
||||
配置权限范围
|
||||
|
||||
```c#
|
||||
// 默认使用 public_profile
|
||||
|
||||
var accessToken = await TapLogin.Login(new []{"public_profile"})
|
||||
;
|
||||
```
|
||||
|
||||
### 3. 获取 TapTap AccessToken
|
||||
|
||||
```c#
|
||||
var accessToken = await TapLogin.GetAccessToken();
|
||||
```
|
||||
|
||||
### 4. 获取 TapTap Profile
|
||||
|
||||
```c#
|
||||
var profile = await TapLogin.FetchProfile();
|
||||
```
|
||||
|
||||
### 5. 获取篝火测试资格
|
||||
|
||||
```c#
|
||||
var boolean = await TapLogin.GetTestQualification();
|
||||
```
|
||||
|
||||
### 6. 退出登陆
|
||||
|
||||
```c#
|
||||
TapLogin.Logout();
|
||||
```
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c720d298abf1847cca49e4f58f9972e8
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ae9b1c1f703a4bdc9ee0b6d24c4194a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24cd5e31f29ae47b5866be602d4bd83c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,25 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace TapTap.Login.Internal {
|
||||
public interface ITapLoginPlatform {
|
||||
void Init(string clientID);
|
||||
|
||||
void Init(string clientID, bool isCn, bool roundCorner);
|
||||
|
||||
void ChangeConfig(bool roundCorner, bool isPortrait);
|
||||
|
||||
Task<Profile> FetchProfile();
|
||||
|
||||
Task<Profile> GetProfile();
|
||||
|
||||
Task<AccessToken> GetAccessToken();
|
||||
|
||||
Task<AccessToken> Login();
|
||||
|
||||
Task<AccessToken> Login(string[] permissions);
|
||||
|
||||
void Logout();
|
||||
|
||||
Task<bool> GetTestQualification();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4087c690e3ccd4ac38ad7d9062573224
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7755e949d0f964a27a68a703b5758d90
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
|||
using TapTap.Common;
|
||||
using TapTap.Common.Internal.Init;
|
||||
|
||||
namespace TapTap.Login.Internal.Init {
|
||||
public class LoginInitTask : IInitTask {
|
||||
public int Order => 11;
|
||||
|
||||
public void Init(TapConfig config) {
|
||||
TapLogin.Init(config.ClientID, config.RegionType == RegionType.CN, true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ef4050f6c70464872a62df912446e757
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,67 @@
|
|||
namespace TapTap.Login.Internal
|
||||
{
|
||||
public abstract class Region
|
||||
{
|
||||
public abstract string WebHost();
|
||||
|
||||
public abstract string ApiHost();
|
||||
|
||||
public abstract string AccountHost();
|
||||
|
||||
public string CodeUrl()
|
||||
{
|
||||
return WebHost() + "/oauth2/v1/device/code";
|
||||
}
|
||||
|
||||
public string TokenUrl()
|
||||
{
|
||||
return WebHost() + "/oauth2/v1/token";
|
||||
}
|
||||
|
||||
public string ProfileUrl()
|
||||
{
|
||||
return ApiHost() + "/account/profile/v1?client_id=";
|
||||
}
|
||||
|
||||
public string AccountUrl()
|
||||
{
|
||||
return AccountHost() + "/authorize?";
|
||||
}
|
||||
}
|
||||
|
||||
public class RegionCN : Region
|
||||
{
|
||||
public override string WebHost()
|
||||
{
|
||||
return "https://accounts.tapapis.cn";
|
||||
}
|
||||
|
||||
public override string ApiHost()
|
||||
{
|
||||
return "https://open.tapapis.cn";
|
||||
}
|
||||
|
||||
public override string AccountHost()
|
||||
{
|
||||
return "https://accounts.taptap.cn";
|
||||
}
|
||||
}
|
||||
|
||||
public class RegionIO : Region
|
||||
{
|
||||
public override string WebHost()
|
||||
{
|
||||
return "https://accounts.tapapis.com";
|
||||
}
|
||||
|
||||
public override string ApiHost()
|
||||
{
|
||||
return "https://open.tapapis.com";
|
||||
}
|
||||
|
||||
public override string AccountHost()
|
||||
{
|
||||
return "https://accounts.taptap.io";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1feada2e0e7bd49db8a8fa50ad07bc6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 397e36f43b9fe4d309a388111a8cb950
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TapTap.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Login
|
||||
{
|
||||
public class AccessToken
|
||||
{
|
||||
public string kid;
|
||||
|
||||
public string accessToken;
|
||||
|
||||
public string tokenType;
|
||||
|
||||
public string macKey;
|
||||
|
||||
public string macAlgorithm;
|
||||
|
||||
public HashSet<string> scopeSet;
|
||||
|
||||
public AccessToken(string json)
|
||||
{
|
||||
var dic = Json.Deserialize(json) as Dictionary<string, object>;
|
||||
kid = SafeDictionary.GetValue<string>(dic, "kid");
|
||||
accessToken = SafeDictionary.GetValue<string>(dic, "access_token");
|
||||
tokenType = SafeDictionary.GetValue<string>(dic, "token_type");
|
||||
macKey = SafeDictionary.GetValue<string>(dic, "mac_key");
|
||||
macAlgorithm = SafeDictionary.GetValue<string>(dic, "mac_algorithm");
|
||||
string scopeStr = SafeDictionary.GetValue<string>(dic, "scope");
|
||||
if (string.IsNullOrEmpty(scopeStr))
|
||||
{
|
||||
scopeSet = new HashSet<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
scopeSet = new HashSet<string>(scopeStr.Split(' '));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scopeSet = new HashSet<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AccessToken()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonUtility.ToJson(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b1c85172abe742f18d2bb494252eed8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,37 @@
|
|||
using System.Collections.Generic;
|
||||
using TapTap.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Login
|
||||
{
|
||||
public class Profile
|
||||
{
|
||||
public string name;
|
||||
|
||||
public string avatar;
|
||||
|
||||
public string openid;
|
||||
|
||||
public string unionid;
|
||||
|
||||
public string email;
|
||||
|
||||
public bool emailVerified;
|
||||
|
||||
public Profile(string json)
|
||||
{
|
||||
var dic = Json.Deserialize(json) as Dictionary<string, object>;
|
||||
name = SafeDictionary.GetValue<string>(dic, "name");
|
||||
avatar = SafeDictionary.GetValue<string>(dic, "avatar");
|
||||
openid = SafeDictionary.GetValue<string>(dic, "openid");
|
||||
unionid = SafeDictionary.GetValue<string>(dic, "unionid");
|
||||
email = SafeDictionary.GetValue<string>(dic, "email");
|
||||
emailVerified = SafeDictionary.GetValue<bool>(dic, "email_verified");
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonUtility.ToJson(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6645cb881ce9c41d5a8cc4708dd67200
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,15 @@
|
|||
namespace TapTap.Friends {
|
||||
public class TapFriendInfo {
|
||||
public string Name {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
public string Avatar {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
public string OpenId {
|
||||
get; internal set;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1704f54f800454b3fb4e7e8473f9cb37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace TapTap.Friends {
|
||||
public class TapFriendResult {
|
||||
public ReadOnlyCollection<TapFriendInfo> FriendList {
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
public string Cursor {
|
||||
get; internal set;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 10c88cb0d937247c3a4c6af903d5503d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,145 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TapTap.Login;
|
||||
using TapTap.Common;
|
||||
using TapTap.Login.Internal;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using TapTap.Common.Internal.Json;
|
||||
using TapTap.Common.Internal.Http;
|
||||
using LC.Newtonsoft.Json;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace TapTap.Friends {
|
||||
public class TapFriends {
|
||||
private static HttpClient httpClient = null;
|
||||
|
||||
public static async Task<TapFriendResult> QueryMutualList(string cursor = null, int size = 100) {
|
||||
AccessToken accessToken = await TapLogin.GetAccessToken();
|
||||
if (accessToken == null) {
|
||||
throw new ArgumentNullException(nameof(accessToken));
|
||||
}
|
||||
string url = $"{TapTapSdk.CurrentRegion.ApiHost()}/friends/v1/list";
|
||||
Dictionary<string, object> queryParams = new Dictionary<string, object> {
|
||||
{ "max_size", size },
|
||||
{"client_id",TapTapSdk.ClientId }
|
||||
};
|
||||
if (!string.IsNullOrEmpty(cursor)) {
|
||||
queryParams.Add("continuation_token", cursor);
|
||||
}
|
||||
IEnumerable<string> queryPairs = queryParams.Select(kv => $"{kv.Key}={kv.Value}");
|
||||
string queries = string.Join("&", queryPairs);
|
||||
url = $"{url}?{queries}";
|
||||
|
||||
var dt = DateTime.UtcNow - new DateTime(1970, 1, 1);
|
||||
var ts = (int)dt.TotalSeconds;
|
||||
var uri = new Uri(url);
|
||||
Dictionary<string, object> headers = new Dictionary<string, object> {
|
||||
{ "Authorization", "MAC " + GetAuthorizationHeader(accessToken.kid,accessToken.macKey,accessToken.macAlgorithm,
|
||||
"GET",uri.PathAndQuery,uri.Host,"443", ts)}
|
||||
};
|
||||
if (httpClient == null)
|
||||
{
|
||||
httpClient = new HttpClient();
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
httpClient.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8"));
|
||||
|
||||
}
|
||||
HttpRequestMessage request = new HttpRequestMessage
|
||||
{
|
||||
RequestUri = new Uri(url),
|
||||
Method = HttpMethod.Get,
|
||||
};
|
||||
HttpRequestHeaders reqHeaders = request.Headers;
|
||||
if (reqHeaders != null)
|
||||
{
|
||||
foreach (KeyValuePair<string, object> kv in headers)
|
||||
{
|
||||
reqHeaders.Add(kv.Key, kv.Value.ToString());
|
||||
}
|
||||
}
|
||||
TapHttpUtils.PrintRequest(httpClient, request);
|
||||
|
||||
HttpResponseMessage originResponse = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
|
||||
request.Dispose();
|
||||
string resultString = await originResponse.Content.ReadAsStringAsync();
|
||||
originResponse.Dispose();
|
||||
TapHttpUtils.PrintResponse(originResponse, resultString);
|
||||
|
||||
Dictionary<string, object> response;
|
||||
if (originResponse.IsSuccessStatusCode)
|
||||
{
|
||||
response = JsonConvert.DeserializeObject<Dictionary<string, object>>(resultString,
|
||||
TapJsonConverter.Default);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TapException(((int)originResponse.StatusCode), resultString);
|
||||
}
|
||||
if (response.TryGetValue("data", out object dataObj) &&
|
||||
dataObj is Dictionary<string, object> data) {
|
||||
TapFriendResult result = new TapFriendResult();
|
||||
if (data.TryGetValue("list", out object listObj) && listObj is List<object> list) {
|
||||
result.FriendList = list.Cast<Dictionary<string, object>>()
|
||||
.Select(item => new TapFriendInfo {
|
||||
OpenId = item["openid"] as string,
|
||||
Name = item.TryGetValue("nickname", out object nicknameObj) && (nicknameObj is string nickname) ?
|
||||
nickname : null,
|
||||
Avatar = item.TryGetValue("avatar", out object avatarObj) && (avatarObj is string avatar) ?
|
||||
avatar : null
|
||||
})
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
|
||||
result.Cursor = data.TryGetValue("is_truncated", out object isTruncatedObj) &&
|
||||
isTruncatedObj is bool isTruncated &&
|
||||
isTruncated ?
|
||||
(data.TryGetValue("next_continuation_token", out object nextSkipObj) &&
|
||||
(nextSkipObj is string nextSkip) ?
|
||||
nextSkip : null) : null;
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetAuthorizationHeader(string kid,
|
||||
string macKey,
|
||||
string macAlgorithm,
|
||||
string method,
|
||||
string uri,
|
||||
string host,
|
||||
string port,
|
||||
int timestamp)
|
||||
{
|
||||
var nonce = new Random().Next().ToString();
|
||||
|
||||
var normalizedString = $"{timestamp}\n{nonce}\n{method}\n{uri}\n{host}\n{port}\n\n";
|
||||
|
||||
HashAlgorithm hashGenerator;
|
||||
switch (macAlgorithm)
|
||||
{
|
||||
case "hmac-sha-256":
|
||||
hashGenerator = new HMACSHA256(Encoding.ASCII.GetBytes(macKey));
|
||||
break;
|
||||
case "hmac-sha-1":
|
||||
hashGenerator = new HMACSHA1(Encoding.ASCII.GetBytes(macKey));
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException("Unsupported MAC algorithm");
|
||||
}
|
||||
|
||||
var hash = Convert.ToBase64String(hashGenerator.ComputeHash(Encoding.ASCII.GetBytes(normalizedString)));
|
||||
|
||||
var authorizationHeader = new StringBuilder();
|
||||
authorizationHeader.AppendFormat(@"id=""{0}"",ts=""{1}"",nonce=""{2}"",mac=""{3}""",
|
||||
kid, timestamp, nonce, hash);
|
||||
|
||||
return authorizationHeader.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 63d7af19c75ee4a89b130a0a0e1736e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,63 @@
|
|||
using System.Threading.Tasks;
|
||||
using TapTap.Login.Internal;
|
||||
using TapTap.Common.Internal.Utils;
|
||||
|
||||
namespace TapTap.Login
|
||||
{
|
||||
public class TapLogin
|
||||
{
|
||||
public const string TAP_LOGIN_SCOPE_BASIC_INFO = "basic_info";
|
||||
public const string TAP_LOGIN_SCOPE_PUBLIC_PROFILE = "public_profile";
|
||||
public const string TAP_LOGIN_SCOPE_USER_FRIENDS = "user_friends";
|
||||
public const string TAP_LOGIN_SCOPE_EMAIL = "email";
|
||||
|
||||
private static ITapLoginPlatform platformWrapper;
|
||||
|
||||
static TapLogin() {
|
||||
platformWrapper = BridgeUtils.CreateBridgeImplementation(typeof(ITapLoginPlatform),
|
||||
"TapTap.Login") as ITapLoginPlatform;
|
||||
}
|
||||
|
||||
public static void Init(string clientID) {
|
||||
platformWrapper.Init(clientID);
|
||||
TapTapSdk.SDKInitialize(clientID, true);
|
||||
}
|
||||
|
||||
public static void Init(string clientID, bool isCn, bool roundCorner) {
|
||||
platformWrapper.Init(clientID, isCn, roundCorner);
|
||||
TapTapSdk.SDKInitialize(clientID, isCn);
|
||||
}
|
||||
|
||||
public static void ChangeConfig(bool roundCorner, bool isPortrait) {
|
||||
platformWrapper.ChangeConfig(roundCorner, isPortrait);
|
||||
}
|
||||
|
||||
public static Task<Profile> FetchProfile() {
|
||||
return platformWrapper.FetchProfile();
|
||||
}
|
||||
|
||||
public static Task<Profile> GetProfile() {
|
||||
return platformWrapper.GetProfile();
|
||||
}
|
||||
|
||||
public static Task<AccessToken> GetAccessToken() {
|
||||
return platformWrapper.GetAccessToken();
|
||||
}
|
||||
|
||||
public static Task<AccessToken> Login() {
|
||||
return platformWrapper.Login();
|
||||
}
|
||||
|
||||
public static Task<AccessToken> Login(string[] permissions) {
|
||||
return platformWrapper.Login(permissions);
|
||||
}
|
||||
|
||||
public static void Logout() {
|
||||
platformWrapper.Logout();
|
||||
}
|
||||
|
||||
public static Task<bool> GetTestQualification() {
|
||||
return platformWrapper.GetTestQualification();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c60164586f7bc46bfb3013f5beb91f81
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
using TapTap.Common;
|
||||
|
||||
namespace TapTap.Login.Internal
|
||||
{
|
||||
public static class TapTapSdk
|
||||
{
|
||||
public const string Version = "1.2.0";
|
||||
|
||||
public static string ClientId { get; private set; }
|
||||
|
||||
public static Region CurrentRegion { get; private set; }
|
||||
|
||||
public static void SDKInitialize(string clientId, bool isCn)
|
||||
{
|
||||
ClientId = clientId;
|
||||
CurrentRegion = isCn ? (Region)new RegionCN() : new RegionIO();
|
||||
TapLocalizeManager.SetCurrentRegion(isCn);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 762c5963339fb430e974398fae5bb511
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "TapTap.Login.Runtime",
|
||||
"references": [
|
||||
"GUID:0b3f64ec33f5b4da98a17367a35b82f2"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e8754b6153389406c963cd52996cc80f
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 31c94f56cfbed4fa2af034971d6dde47
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b5994a776f5ee4f8998f23dd47cb2fef
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using TapTap.Common.Editor;
|
||||
|
||||
namespace TapTap.Login.Editor
|
||||
{
|
||||
public class TapLoginStandaloneProcessBuild : SDKLinkProcessBuild
|
||||
{
|
||||
public override int callbackOrder => 0;
|
||||
|
||||
public override string LinkPath => "TapTap/Login/link.xml";
|
||||
|
||||
public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[] {
|
||||
new LinkedAssembly { Fullname = "TapTap.Login.Runtime" },
|
||||
new LinkedAssembly { Fullname = "TapTap.Login.Standalone.Runtime" }
|
||||
};
|
||||
|
||||
public override Func<BuildReport, bool> IsTargetPlatform => (report) => {
|
||||
return BuildTargetUtils.IsSupportStandalone(report.summary.platform);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7661a47473b9c438980a7d4b0be90e2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "TapTap.Login.Standalone.Editor",
|
||||
"references": [
|
||||
"GUID:616cea76def2d4f059b94440fc8cc03d"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ff2731b992f0b4736afeff3719a96ad4
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7396550db8b6142668fe2dab2457c315
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 32e8212d1e4f3425d83ba0ecb6d9c87f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue