身份驗證服務
Hive平台提供身份驗證服務,以符合韓國的合規要求。身份驗證服務包括身份認證、成人驗證和家長同意功能,並在Hive SDK(以下簡稱SDK)的Android、iOS和Windows目標上提供支持,以便在移動和PC遊戲中使用。在移動遊戲環境中,即使遊戲畫面以橫向顯示,身份驗證服務的用戶界面仍以豎向顯示。
身份認證¶
身份驗證是一項功能,允許使用者透過手機號碼進行身份驗證,以限制遊戲內的濫用或限制特定年齡組的使用者。由於SDK可以在任何遊戲登錄時間調用身份驗證API,因此可以在開始進入商店或進入地下城等服務之前進行身份驗證。因此,它可以用來允許只有完成身份驗證的使用者繼續後續的遊戲過程。
當SDK調用身份驗證API並完成身份驗證時,將獲得電話號碼、出生日期和DI(重複加入驗證信息)哈希值作為結果。此時,DI哈希值與當前登錄無關,並且不與PlayerID相關聯。
如果在調用API後未能獲取結果值,您可以通過再次調用身份驗證API來重試。
呼叫身份驗證 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 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方法提供在父母同意期間提供的用戶(未成年人)的出生日期和父母的電子郵件地址。
獲取父母同意信息的示例代碼如下:
