TapBootstrap-Unity/Documentation/README.md

75 lines
1.8 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#
var config = new TapConfig.TapConfigBuilder()
.ClientID("client_id")
.ClientSecret("client_secret")
.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#
var config = new TapConfig.TapConfigBuilder()
.ClientID("client_id")
.ClientSecret("client_secret")
.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` 实例
#### 使用 TapTap OAuth 授权结果直接登陆账户系统
```c#
var tdsUser = await TDSUser.LoginWithTapTap();
```
#### 游客登陆
```c#
var tdsUser = await TDSUser.LoginAnonymously();
```
#### 绑定第三方平台账号
```c#
var tdsUser = await TDSUser.LoginWithAuthData(Dictionary<string, object> authData, string platform,
LCUserAuthDataLoginOption option = null);
```
#### 退出登陆
```c#
TDSUser.Logout();
```