身份驗證服務
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 call successful
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE called before setup
// CANCELED window closed before receiving authentication result
// RESPONSE_FAIL abnormal response
// DEVELOPER_ERROR, CommonLibraryMissing failed to reference identity authentication library
}
});
#include "HiveAuthV4.h"
FHiveAuthV4::showIdentityVerification(FHiveAuthV4OnIdentityVerificationDelegate::CreateLambda([this](const FHiveResultAPI& Result, FHiveIdentity& identity) {
if (Result.IsSuccess()) {
// API call successful
// identity.phoneCode, phoneNumber, dateOfBirth, hashedDi
} else {
// NEED_INITIALIZE called before setup
// CANCELED window closed before receiving authentication result
// RESPONSE_FAIL abnormal response
// DEVELOPER_ERROR, CommonLibraryMissing failed to reference identity authentication library
}
}));
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 參考: HIVEAuthV4:getHashedDi
家長同意¶
根據《青少年保護法》,未滿19歲的人只能在父母同意的情況下參加和使用遊戲。該SDK提供了通過手機身份認證獲取父母同意的功能,當未成年人參加PC遊戲時。此外,在向父母提供遊戲使用詳情時,未成年人的出生日期和父母的電子郵件地址會傳送到遊戲應用程式。
獲取家長同意資訊¶
要獲取父母同意資訊,您必須在完成父母同意後調用getParentalConsentInfo()方法。getParentalConsentInfo方法提供在父母同意期間提供的用戶(未成年人)的出生日期和父母的電子郵件地址。
獲取家長同意信息的示例代碼如下:
