身份验证服务
Hive平台提供身份验证服务,以符合韩国合规要求。身份验证服务包括身份认证、成人验证和家长同意功能,并支持Hive SDK(以下简称SDK)的Android、iOS和Windows目标,以便在移动和PC游戏中使用。在移动游戏环境中,即使游戏屏幕以横向显示,身份验证服务的用户界面也以纵向显示。
身份认证¶
身份认证是一项功能,允许使用用户的手机号码进行身份验证,以限制游戏内的滥用或限制特定年龄组的用户。由于SDK可以在游戏登录时机无论如何调用身份认证API,因此可以在开始进入商店或进入地下城等服务之前进行身份认证。因此,它可以用于仅允许已完成身份认证的用户继续后续的游戏过程。
当SDK调用身份验证API并完成身份验证时,手机号码、出生日期和DI(重复加入验证信息)哈希值作为结果获得。此时,DI哈希值与当前登录无关,也与PlayerID无关。
调用身份验证API的示例代码如下:
API 参考: hive.AuthV4.showIdentityVerification
using hive;
AuthV4.showIdentityVerification((ResultAPI result, Identity identity) => {
if (result.isSuccess()) {
// API 调用成功
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE 在设置之前被调用
// CANCELED 窗口在接收身份验证结果之前关闭
// RESPONSE_FAIL 异常响应
// DEVELOPER_ERROR, CommonLibraryMissing 未能引用身份验证库
}
});
#include "HiveAuthV4.h"
FHiveAuthV4::showIdentityVerification(FHiveAuthV4OnIdentityVerificationDelegate::CreateLambda([this](const FHiveResultAPI& Result, FHiveIdentity& identity) {
if (Result.IsSuccess()) {
// API调用成功
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE在设置之前被调用
// CANCELED窗口在接收身份验证结果之前关闭
// RESPONSE_FAIL异常响应
// DEVELOPER_ERROR, CommonLibraryMissing未能引用身份验证库
}
}));
API 参考: AuthV4::showIdentityVerification
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
AuthV4::showIdentityVerification([=](ResultAPI result, Identity identity) {
if (result.isSuccess()) {
// API 调用成功
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE 在设置之前被调用
// CANCELED 窗口在接收身份验证结果之前关闭
// RESPONSE_FAIL 异常响应
// DEVELOPER_ERROR, CommonLibraryMissing 未能引用身份验证库
}
});
API 参考: AuthV4.showIdentityVerification
import com.hive.AuthV4
import com.hive.ResultAPI
AuthV4.showIdentityVerification(object : AuthV4.AuthV4ShowIdentityVerificationListener {
override fun onAuthV4ShowIdentityVerification(result: ResultAPI, identity: Identity?) {
if (result.isSuccess) {
// API 调用成功
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE 在设置之前被调用
// CANCELED 窗口在接收身份验证结果之前关闭
// RESPONSE_FAIL 异常响应
// DEVELOPER_ERROR, CommonLibraryMissing 无法引用身份验证库
}
}
})
API 参考: AuthV4.showIdentityVerification
import com.hive.AuthV4;
import com.hive.ResultAPI;
AuthV4.showIdentityVerification(result, identity -> {
if (result.isSuccess()) {
// API 调用成功
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE 在设置之前被调用
// CANCELED 窗口在接收身份验证结果之前关闭
// RESPONSE_FAIL 异常响应
// DEVELOPER_ERROR, CommonLibraryMissing 无法引用身份验证库
}
});
API 参考: AuthV4Interface.showIdentityVerification
import HIVEService
AuthV4Interface.showIdentityVerification() { result, identity in
if result.isSuccess() {
// API 调用成功
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE 在设置之前被调用
// CANCELED 窗口在接收身份验证结果之前关闭
// RESPONSE_FAIL 异常响应
// DEVELOPER_ERROR, CommonLibraryMissing 未能引用身份验证库
}
}
API参考: HIVEAuthV4:showIdentityVerification
#import <HIVEService/HIVEService-Swift.h>
[HIVEAuthV4 showIdentityVerification: ^(HIVEResultAPI *result, HIVEIdentity *> *identity) {
if ([result isSuccess]) {
// API调用成功
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE 在设置之前被调用
// CANCELED 窗口在接收身份验证结果之前关闭
// RESPONSE_FAIL 异常响应
// DEVELOPER_ERROR, CommonLibraryMissing 未能引用身份验证库
}
}];
成人验证¶
被归类为“非青少年使用”的游戏必须限制19岁以下未成年人的访问。Hive平台提供了一项成人验证功能,只有在通过手机身份认证验证成人身份后才能访问游戏。成人验证的有效期为1年,之后将自动进行重新认证过程。
如果在控制台 [身份验证 > 成人身份验证 > 启用设置] 中启用了成人验证功能,则可以在游戏登录期间执行成人验证,而无需在 SDK 中实现单独的代码。
Warning
身份认证和成人验证只能由拥有居民登记号码或外国登记号码并持有自己名下手机的韩国用户进行。
成人验证失败时的响应¶
当未成年人尝试成人验证并失败时,他们会收到 ResultAPI.CANCELED(-6) 和 ResultAPI.Code.AgeLimit(-1200067), "因年龄限制而失败。" 的响应。游戏公司可以利用此响应以他们希望的方式引导游戏中的未成年用户。
获取DI哈希值¶
完成成人验证后,在SDK中调用AuthV4.getHashedDi方法可以获得一个DI哈希值,该值可以识别经过成人验证的用户。哈希DI的原因是出于安全考虑,游戏公司可以直接使用这个哈希值。由于这个DI哈希值在登录后与PlayerID相关联,因此可以将哈希值用作经过成人验证的用户的标识符。
调用AuthV4.getHashedDi方法以获取与PlayerID关联的DI哈希值的示例代码如下:
API 参考: hive.AuthV4.getHashedDi
using hive;
AuthV4.getHashedDi((ResultAPI result, String hashedDi) => {
if (result.isSuccess()) {
// API call successful
} else {
// NEED_INITIALIZE called before setup
// INVALID_SESSION called before signIn
// DEVELOPER_ERROR, CommonLibraryMissing failed to reference adult verification library
}
});
#include "HiveAuthV4.h"
FHiveAuthV4::getHashedDi(FHiveAuthV4OnHashedDiDelegate::CreateLambda([this](const FHiveResultAPI& Result, FString& hashedDi) {
if (Result.IsSuccess()) {
// API 调用成功
} else {
// NEED_INITIALIZE 在设置之前被调用
// INVALID_SESSION 在登录之前被调用
// DEVELOPER_ERROR, CommonLibraryMissing 无法引用成人验证库
}
}));
API 参考: AuthV4::getHashedDi
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
AuthV4::getHashedDi([=](ResultAPI result, string hashedDi) {
if (result.isSuccess()) {
// API call successful
} else {
// NEED_INITIALIZE called before setup
// INVALID_SESSION called before signIn
// DEVELOPER_ERROR, CommonLibraryMissing failed to reference adult verification library
}
});
API 参考: AuthV4.getHashedDi
import com.hive.AuthV4
import com.hive.ResultAPI
AuthV4.getHashedDi(object : AuthV4.AuthV4GetHashedDiListener {
override fun onAuthV4GetHashedDi(result: ResultAPI, hashedDi: String?) {
if (result.isSuccess) {
// API 调用成功
} else {
// NEED_INITIALIZE 在设置之前被调用
// INVALID_SESSION 在登录之前被调用
// DEVELOPER_ERROR, CommonLibraryMissing 无法引用成人验证库
}
}
})
API 参考: AuthV4.getHashedDi
API 参考: AuthV4Interface.getHashedDi
API Reference: HIVEAuthV4:getHashedDi
家长同意¶
根据《未成年人保护法》,19岁以下的未成年人只能在获得父母同意的情况下加入和使用游戏。SDK提供了通过手机身份认证获取父母同意的功能,当未成年人加入PC游戏时。此外,在向父母提供游戏使用详情时,未成年人的出生日期和父母的电子邮件地址会传递给游戏应用。
获取父母同意信息¶
要获取父母同意信息,您必须在完成父母同意后调用getParentalConsentInfo()方法。getParentalConsentInfo方法提供在父母同意期间提供的用户(未成年人)的出生日期和父母的电子邮件地址。
获取父母同意信息的示例代码如下:
