跳到主要内容

开发指南

引入方式

"com.xd.sdk.report": "6.23.4"

举报

var reporter = new ReportParams.ReporterInfo(new Dictionary<string, object>
{
// 举报者附加信息,e.g.:
{ "roleId", "gameRoleId" },
{ "userLevel", 100 }

var reportee = new ReportParams.ReporteeInfo(xdid, new Dictionary<string, object>
{
// 被举报者附加信息,e.g.:
{ "roleId", "gameRoleId" },
{ "userLevel", 100 }
});

var reasons = new List<ReportParams.ReasonInfo>
{
new ReportParams.ReasonInfo(1, "言语辱骂", new Dictionary<string, object>
{
// 举报原因附加信息,e.g.:
{"roleId", "gameRoleId"},
{"userLevel", 100}
}),
new ReportParams.ReasonInfo(2, "使用外挂", new Dictionary<string, object>
{
// 举报原因附加信息,e.g.:
{"roleId", "gameRoleId"},
{"userLevel", 100}
})
};

var evidenceList = new List<string>
{
"{PC 文件绝对路径}",
"{Android 文件绝对路径}",
"{iOS 文件绝对路径"
};

var reportParams = new ReportParams.Builder()
.SetReporter(reporter)
.SetReportee(reportee)
.SetReasons(testReasons)
.SetUserDescription("这个人不仅使用外挂打游戏,还言语辱骂队友!!!我要举报 TA!")
.SetEvidenceList(evidenceList)
.SetExtras(new Dictionary<string, object>
{
// 举报附加信息,e.g.:
{"roleId", "gameRoleId"},
{"userLevel", 100}
})
.Build();

XD.SDK.Report.XDGReport.Report(reportParams, result => {
if (result.Success)
{
Console.WriteLine("Report successfully");
}
else
{
Console.WriteLine($"Report failed: {result.XdException?.error_msg}");
}
});

数据结构定义

public class ReportParams
{
public ReporterInfo Reporter { get; } // 举报人
public ReporteeInfo Reportee { get; } // 被举报人
public List<ReasonInfo> Reasons { get; } // 举报原因
public string UserDescription { get; } // 玩家描述
public List<string> EvidenceList { get; } // 玩家添加的附件(本地文件绝对路径)
public Dictionary<string, object> Extras { get; } // 附加信息补充玩家信息,透传给使用方

public class ReporterInfo
{
public Dictionary<string, object> Extras { get; } // 举报人附加信息
}

public class ReporteeInfo
{
public string XdId { get; } // 被举报人 XDID
public Dictionary<string, object> Extras { get; } // 被举报人附加信息
}

public class ReasonInfo
{
public long ID { get; } // 举报原因 ID,后台配置
public string Title { get; } // 原因名称
public Dictionary<string, object> Extras { get; } // 附加信息补充玩家信息,透传给使用方
}
}