TapBootstrap-Unity/Documentation/README.md

84 lines
1.9 KiB
Markdown
Raw Normal View History

# 使用 TapTap.Bootstrap
2021-04-12 11:24:42 +08:00
## 使用前提
使用 TapTap.Bootstrap 前提是必须依赖以下库:
* [TapTap.Common](https://github.com/TapTap/TapCommon-Unity.git)
* [TapTap.Login](https://github.com/TapTap/TapLogin-Unity.git)
* [LeanCloud.Storage](https://github.com/leancloud/csharp-sdk)
2021-04-12 11:24:42 +08:00
## 命名空间
```c#
2021-04-12 11:24:42 +08:00
using TapTap.Bootstrap;
```
2021-04-12 11:24:42 +08:00
## 接口描述
2021-05-07 16:57:54 +08:00
### 1.初始化
#### TapBootstrap 会根据 TapConfig 中的 TapDBConfig 配置来进行 TapDB 的自动初始化。
2021-05-07 16:57:54 +08:00
##### 开启 TapDB
```c#
2021-07-17 10:37:46 +08:00
var config = new TapConfig.Builder()
.ClientID("client_id")
2021-07-17 11:30:13 +08:00
.ClientToken("client_token")
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
.RegionType(RegionType.CN)
.TapDBConfig(true,"channel","gameVersion",true)
.Builder();
2021-05-07 16:57:54 +08:00
```
##### 关闭 TapDB
2021-05-07 16:57:54 +08:00
```c#
2021-07-17 10:37:46 +08:00
var config = new TapConfig.Builder()
2021-05-07 16:57:54 +08:00
.ClientID("client_id")
2021-07-17 11:30:13 +08:00
.ClientToken("client_token")
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
2021-05-07 16:57:54 +08:00
.RegionType(RegionType.CN)
//# .TapDBConfig(false,null,null,false)
2021-05-07 16:57:54 +08:00
.EnableTapDB(false)
.Builder();
```
##### 初始化
2021-05-07 16:57:54 +08:00
```c#
TapBootstrap.Init(config);
```
### 2.账户系统
> 登陆成功之后,都会得到一个 `TDSUser` 实例
2021-07-15 14:04:16 +08:00
#### 使用 TapTap OAuth 授权结果直接登陆/注册账户系统
```c#
var tdsUser = await TDSUser.LoginWithTapTap();
```
#### 游客登陆
2021-07-15 14:04:16 +08:00
```c#
var tdsUser = await TDSUser.LoginAnonymously();
```
2021-07-15 14:04:16 +08:00
#### 使用第三方平台授权登录/注册账户
```c#
var tdsUser = await TDSUser.LoginWithAuthData(Dictionary<string, object> authData, string platform,
LCUserAuthDataLoginOption option = null);
```
2021-07-15 14:04:16 +08:00
#### 绑定第三方平台授权
```c#
await TDSUser.AssociateAuthData(Dictionary<string, object> authData, string platform);
```
#### 退出登陆
2021-07-15 14:04:16 +08:00
```c#
TDSUser.Logout();
```