43 lines
1.7 KiB
C#
43 lines
1.7 KiB
C#
#if WEBGL_BYTEDANCE
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using StarkSDKSpace;
|
|
|
|
namespace HC
|
|
{
|
|
public class HCBytedanceAccount : HCIAccount
|
|
{
|
|
public void Login(Action<HCLoginResult> callback)
|
|
{
|
|
/// <summary>登录成功</summary>
|
|
/// <param name="code">临时登录凭证, 有效期 3 分钟。可以通过在服务器端调用 登录凭证校验接口 换取 openid 和 session_key 等信息。</param>
|
|
/// <param name="anonymousCode">用于标识当前设备, 无论登录与否都会返回, 有效期 3 分钟</param>
|
|
/// <param name="isLogin">判断在当前 APP(头条、抖音等)是否处于登录状态</param>
|
|
StarkSDK.API.GetAccountManager().Login((code, anonymousCode, login) =>
|
|
{
|
|
// 和服务器约定的code
|
|
var serverCode = $"{code},{anonymousCode}";
|
|
|
|
HCDebugger.LogDebug($"[HCBytedanceAccount] [Login] [success] code = {code} anonymousCode = {anonymousCode} login = {login}");
|
|
callback.Invoke(new HCLoginResult()
|
|
{
|
|
code = 0,
|
|
token = serverCode,
|
|
userId = serverCode,
|
|
msg = "success"
|
|
});
|
|
}, errMsg =>
|
|
{
|
|
HCDebugger.LogDebug($"[HCBytedanceAccount] [Login] [failedCallback] errMsg = {errMsg}");
|
|
callback.Invoke(new HCLoginResult()
|
|
{
|
|
code = -1,
|
|
token = "",
|
|
userId = "",
|
|
msg = errMsg
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
#endif |