Check user data
If you have successfully logged in, you can check the profile information and suspension information of the logged-in user.
User profile exposure¶
Hive SDK provides the functionality to expose user profiles in a web view within the app. To display the profile screen, you must follow these steps.
- The developer implements a button or UI element that can expose the profile in the app.
- When the user selects this button or UI element in the app, the app utilizes the Hive SDK authentication feature to call
AuthV4.showProfile
.
Calling AuthV4.showProfile
will display the profile screen provided by the Hive SDK. Users can view and change their profile image and nickname on the profile screen.
This is an example code that exposes the profile.
API Reference: AuthV4.showProfile
API Reference: AuthV4::showProfile
API Reference: AuthV4.showProfile
API Reference: AuthV4.INSTANCE.showProfile
API Reference: AuthV4Interface.showProfile
API Reference: [HIVEAuthV4 showProfile]
The use of the profile screen is fundamentally at the discretion of the developer. However, if you provide a Hive Membership IdP, you must implement showProfile()
. This is because the Hive membership provides password change and withdrawal features in the Hive account settings on the profile screen as shown below.
Hive Membership IdP Integration Status Profile | Guest and Other IdP Integration Status Profile |
---|---|
![]() | ![]() |
Even if Hive provides only IdPs other than the membership IdP, displaying the profile screen can provide security features such as blocking overseas logins, full logout, and checking login history. Therefore, it is recommended to implement the profile screen display using showProfile()
.
Note
When integrated with an IdP that returns profile images and nicknames, such as Facebook, the images and nicknames provided by that IdP will be automatically loaded into the profile.
User profile check¶
If you have completed the login, you can use the AuthV4 class's getProfile()
method to retrieve the user's profile information. The profile information includes playerId
, the user's nickname that will be displayed externally as playerName
, and the user's thumbnail image as playerImageUrl
.
The following is an example code for obtaining user profile information.
API Reference: hive.AuthV4.getProfile
using hive;
List<Int64> playerIdList = new List();
playerIdList.Add(0123);
playerIdList.Add(4567);
AuthV4.getProfile(playerIdList, (ResultAPI result, List profileInfoList) => {
if (!result.isSuccess()) {
return;
}
if (profileInfoList != null) {
foreach (ProfileInfo profileInfo in profileInfoList) {
// PlayerName: profileInfo.playerName
// PlayerId: profileInfo.playerId
}
}
});
#include "HiveAuthV4.h"
TArray<int64> PlayerIdArray;
PlayerIdArray.Add(1234);
PlayerIdArray.Add(5678);
FHiveAuthV4::GetProfile(PlayerIdArray, FHiveAuthV4OnGetProfileDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<FHiveProfileInfo> ProfileInfoArray) {
if (!Result.IsSuccess()) {
return;
}
for (const auto& ProfileInfo : ProfileInfoArray)
{
// PlayerName: ProfileInfo.PlayerName;
// PlayerId : ProfileInfo.ProfileInfo;
}
}));
API Reference: AuthV4::getProfile
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
vector<PlayerID> playerIdList;
playerIdList.push_back(0123);
playerIdList.push_back(4567);
AuthV4::getProfile(playerIdList, [=](ResultAPI const & result, vector<ProfileInfo> const & profileInfoList) {
if (!result.isSuccess()) {
return;
}
if (profileInfoList != null) {
for (auto profileInfo : profileInfoList) {
// PlayerName: profileInfo.playerName
// PlayerId: profileInfo.playerId
}
}
});
API Reference: AuthV4.getProfile
import com.hive.AuthV4
import com.hive.ResultAPI
val playerIdList = arrayListOf<Long>(
1234,
4567
)
AuthV4.getProfile(playerIdList, object : AuthV4.AuthV4GetProfileListener {
override fun onAuthV4GetProfile(result: ResultAPI, profileInfoList: ArrayList<AuthV4.ProfileInfo>?) {
if (!result.isSuccess) {
return
}
if (profileInfoList != null) {
for (i in 0 until profileInfoList.size) {
// PlayerName: profileInfoList[i].playerName
// PlayerId: profileInfoList[i].playerId
}
}
}
})
API Reference: com.hive.AuthV4.getProfile
import com.hive.AuthV4;
import com.hive.ResultAPI;
ArrayList<Long> playerIdList = new ArrayList<>(Arrays.asList(
1234L,
5678L
));
AuthV4.INSTANCE.getProfile(playerIdList, (result, profileInfoList) -> {
if (!result.isSuccess()) {
return;
}
if (profileInfoList != null) {
for (AuthV4.ProfileInfo profileInfo : profileInfoList) {
// PlayerName: profileInfo.getPlayerName();
// PlayerId: profileInfo.getPlayerId();
}
}
});
API Reference: AuthV4Interface.getProfile
import HIVEService
var playerIdList = [Int64]()
playerIdList.append(0123)
playerIdList.append(4567)
AuthV4Interface.getProfile(playerIdList) { result, profileInfoList in
if !result.isSuccess() {
return
}
if let profileInfoList = profileInfoList {
for (profileInfo in profileInfoList) {
// PlayerName: profileInfo.playerName
// PlayerId: profileInfo.playerId
}
}
}
API Reference: HIVEAuthV4:getProfile
#import <HIVEService/HIVEService-Swift.h>
NSMutableArray<NSNumber *> *playerIdList = [[[NSMutableArray] alloc] init];
[playerIdList addObject: [NSNumber numberWithLongLong:0123]];
[playerIdList addObject: [NSNUmber numberWithLongLong:4567]];
[HIVEAuthV4 getProfile: playerIdList handler: ^(HIVEResultAPI *result, NSArray<HIVEProfileInfo *> *profileInfoList) {
if (![result isSuccess]) {
return;
}
if (profileInfoList != nil) {
for (HIVEProfileInfo *profileInfo in profileInfoList) {
// PlayerName: profileInfo.playerName
// PlayerId: profileInfo.playerId
}
}
}];
Checking blacklist¶
When user signs in or syncs with IdP, Hive SDK automatically checks the blacklist and suspends the user from playing game. If you need to check the status of user suspension during the game, use the checkBlacklist()
method to check the suspended status of the user in real time and restrict the game play. Depending on the value of the isShow parameter at the time of checkBlacklist()
call, Hive SDK will either show the suspended status popup directly or return popup content for customizing the suspended status popup.
- Useing Providing suspension popups: Set
isShow
parameter astrue
. -
Using Customized suspension popups: Set
isShow
parameter asfalse
. For more information about popup data, see suspension popup Data Returned by Hive SDK below. -
Example screen of suspension popup
Suspension popup data returned by Hive SDK¶
If the result of calling checkBlacklist()
method is success, Hive SDK returns the values in the following table through AuthV4MaintenanceInfo
object.
Field Name | Description | Type |
---|---|---|
title | Popup title | String |
message | Popup contents | String |
button | Text on the label of popup button | String |
action | Action type when a user taps the popup button * OPEN_URL: Execute URL passed by external browser * EXIT: End the app * DONE: Just close maintenance popup | Enumeration type of AuthV4MaintenanceActionType |
url | URL displayed by external browser. This is valid when the value of action field is OPEN_URL | String |
remainingTime | Remaining time until maintenance completion (Unit: second). Time refreshes in real time and when it becomes zero, app is terminated. | Integer |
Followings are sample codes to check the users under suspension.
- In case of using no Hive SDK UI (isShow = false)
API Reference: hive.AuthV4.checkBlacklist
using hive;
Boolean isShow = false;
AuthV4.checkBlacklist(isShow, (ResultAPI result, List<AuthV4.MaintenanceInfo> maintenanceInfo) => {
if (!result.isSuccess()) {
// Request to check for suspension failed
return;
}
if(maintenanceInfo != null){
// In case of suspended user
} else{
// If you are a general user
}
});
#include "HiveAuthV4.h"
bool bIsShow = false;
FHiveAuthV4::CheckBlacklist(bIsShow,
FHiveAuthV4OnMaintenanceInfoDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<FHiveAuthV4MaintenanceInfo>& AuthV4MaintenanceInfoArray) {
if (!Result.IsSuccess()) {
// Request to check for suspension failed
return;
}
if (AuthV4MaintenanceInfoArray.Num() > 0) {
// In case of suspended user
} else {
// If you are a general user
}
}));
API Reference: AuthV4.checkBlacklist
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
bool isShow = false;
AuthV4::checkBlacklist(isShow, [=](ResultAPI const & result, vector<AuthV4MaintenanceInfo> const & maintenanceInfo) {
if(!result.isSuccess) {
// Request to check for suspension failed
return;
}
if (maintenanceInfo != null){
// In case of suspended user
} else {
// If you are a general user
}
});
API Reference: AuthV4.checkBlacklist
import com.hive.AuthV4
import com.hive.ResultAPI
val isShow = false
AuthV4.checkBlacklist(isShow, object : AuthV4.AuthV4MaintenanceListener {
override fun onAuthV4Maintenance(result: ResultAPI, maintenanceInfo: ArrayList<AuthV4.AuthV4MaintenanceInfo>?) {
if (!result.isSuccess) {
// Request to check for suspension failed
return
}
if (maintenanceInfo != null) {
// In case of suspended user
} else {
// If you are a general user
}
}
})
API Reference: com.hive.AuthV4.checkBlacklist
import com.hive.AuthV4;
import com.hive.ResultAPI;
boolean isShow = false;
AuthV4.INSTANCE.checkBlacklist(isShow, (result, maintenanceInfo) -> {
if (!result.isSuccess()) {
// Request to check for suspension failed
return;
}
if (maintenanceInfo != null) {
// In case of suspended user
} else {
// If you are a general user
}
});
API Reference: AuthV4Interface.checkBlacklist
API Reference: HIVEAuthV4:checkBlacklist
#import <HIVEService/HIVEService-Swift.h>
BOOL isShow = NO;
[HIVEAuthV4 checkBlackList: isShow handler: ^(HIVEResultAPI *result, HIVEAuthV4MaintenanceInfo *maintenanceInfo) {
if (![result isSuccess]) {
// Request to check for suspension failed
return;
}
if (maintenanceInfo != nil) {
// In case of suspended user
} else {
// If you are a general user
}
}];
- In case of using Hive SDK UI (isShow = true)
API Reference: hive.AuthV4.checkBlacklist
// If isShow is true, Hive SDK displays suspension popup.
Boolean isShow = true;
// Hive SDK AuthV4 requests to check whether suspended user or not.
AuthV4.checkBlacklist(isShow, (ResultAPI result, List<AuthV4.MaintenanceInfo> maintenanceInfo)=>{
if (result.isSuccess()) {
// In case of normal user
} else if (result.needExit()) {
// TODO: Implement the termination of the app.
// Example) Application.Quit(); }});
#include "HiveAuthV4.h"
// If isShow is true, Hive SDK displays suspension popup.
bool bIsShow = true;
// Hive SDK AuthV4 requests to check whether suspended user or not.
FHiveAuthV4::CheckBlacklist(bIsShow,
FHiveAuthV4OnMaintenanceInfoDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<FHiveAuthV4MaintenanceInfo>& AuthV4MaintenanceInfoArray) {
if (Result.IsSuccess()) {
// In case of normal user
} else if (Result.NeedExit() {
// TODO: Implement the termination of the app.
// Ex) UKismetSystemLibrary::QuitGame(GetWorld(), nullptr, EQuitPreference::Quit, false);
}
}));
API Reference: AuthV4.checkBlacklist
// If isShow is true, Hive SDK displays suspension popup.
bool isShow = true;
// Hive SDK AuthV4 requests to check whether suspended user or not.
AuthV4::checkBlacklist(isShow, [=](ResultAPI const & result,std::vector<AuthV4MaintenanceInfo> const & maintenanceInfolist){
if (result.isSuccess()) {
// In case of normal user
} else if (result.needExit()) {
// TODO: Implement the termination of the app.
// Users of the Cocos2d-x engine
// ex) exit(0);
// Unreal engine users
// Example) UKismetSystemLibrary::QuitGame(GetWorld(), nullptr, EQuitPreference::Quit, false); }});
API Reference: AuthV4.checkBlacklist
// If isShow is true, Hive SDK displays suspension popup.
val isShow = true
// Hive SDK AuthV4 requests to check whether suspended user or not.
AuthV4.checkBlacklist(isShow, object : AuthV4.AuthV4MaintenanceListener {
override fun onAuthV4Maintenance(
result: ResultAPI,
maintenanceInfo: ArrayList<AuthV4.AuthV4MaintenanceInfo>? ) { if (result.isSuccess) {
// In case of normal user
} else if (result.needExit()) {
// TODO: Implement the termination of the app.
// Example) exitProcess(0) } }})
API Reference: com.hive.AuthV4.checkBlacklist
// If isShow is true, Hive SDK displays suspension popup.
boolean isShow = true;
// Hive SDK AuthV4 requests to check whether suspended user or not.
AuthV4.checkBlacklist(isShow, new AuthV4.AuthV4MaintenanceListener() {
@Override
public void onAuthV4Maintenance(ResultAPI result, ArrayList<AuthV4.AuthV4MaintenanceInfo> maintenanceInfo) {
if (result.isSuccess()) {
// In case of normal user
} else if (result.needExit()) {
// TODO: Implement the termination of the app.
// Example) System.exit(0); } }});
API Reference: AuthV4Interface.checkBlacklist
// If isShow is true, Hive SDK displays suspension popup.
let isShow = true
// Hive SDK AuthV4 requests to check whether suspended user or not.
AuthV4Interface.checkBlacklist(isShow) { (result, maintenanceInfolist) in
if result.isSuccess() {
// In case of normal user
}
else if result.needExit() {
// TODO: Implement the termination of the app.
// Example) exit(0)
}
API Reference: HIVEAuthV4:checkBlacklist
// If isShow is YES, Hive SDK displays suspension popup.
BOOL isShow = YES;
// Hive SDK AuthV4 requests to check whether suspended user or not.
[HIVEAuthV4 checkBlacklist:isShow handler:^(HIVEResultAPI *result, NSArray<HIVEAuthV4MaintenanceInfo *> *maintenanceInfolist) {
if (result.isSuccess) {
// In case of normal user
} else if (result.needExit) {
// TODO: Implement the termination of the app.
// Example) exit(0); }}];
Use the email address of users¶
Game companies provide a function to collect email information in the logged in user profile information. To collect email information, you must enable the feature in the Hive Console.
First, you must obtain permission to collect emails from the ‘IDPs that can collect emails’ from the IDP list below.
- IdPs available for email collection: Google, Facebook, Huawei (Android), membership, Apple (iOS)
- Email cannot be collected from IdPs: Google Play Games, Apple Game Center, QQ, VK, WeChat, Line, Weverse, Steam, X
After calling the Explicit Login API, you can get the email address of a logged-in user via referencing providerInfoData
in PlayerInfo
class instance, which is returned in the callback.
Use ProviderType
as the key in providerInfoData
to get the ProviderInfo. For more details, see the example codes below.
API Reference: hive.AuthV4.showSignIn
// Request Hive SDK AuthV4 Authentication UI
AuthV4.showSignIn((ResultAPI result, AuthV4.PlayerInfo playerInfo)=>{
if (result.isSuccess()) {
// authentication success
// playerInfo: Authenticated user information
// the example of getting email information
foreach (KeyValuePair<AuthV4.ProviderType , AuthV4.ProviderInfo> entry in playerInfo.providerInfoData) {
AuthV4.ProviderInfo providerInfo = entry.Value;
if(providerInfo.providerEmail != null && providerInfo.providerEmail != "") {
string email = providerInfo.providerEmail;
break;
}
}
}
else if (result.needExit()) {
// TODO: Implement the termination of the app
// Example) Application.Quit();
}
});
#include "HiveAuthV4.h"
// Request Hive SDK AuthV4 Authentication UI
FHiveAuthV4::ShowSignIn(FHiveAuthV4OnSignInDelegate::CreateLambda([this](const FHiveResultAPI& Result, const FHivePlayerInfo& PlayerInfo) {
if (Result.IsSuccess()) {
// authentication success
// playerInfo: Authenticated user informatio
// the example of getting email information
for (const auto& ProviderInfoEntry : PlayerInfo.ProviderInfoData) {
FHiveProviderInfo ProviderInfo = ProviderInfoEntry.Value;
FString Email = ProviderInfo.ProviderEmail;
}
} else if (Result.NeedExit()) {
// TODO: Implement the termination of the app
// Users of the Cocos2d-x engine
// ex) UKismetSystemLibrary::QuitGame(GetWorld(), nullptr, EQuitPreference::Quit, false);
}
}));
API Reference: AuthV4::showSignIn
// Request Hive SDK AuthV4 Authentication UI
AuthV4::showSignIn([=](ResultAPI const & result, PlayerInfo const & playerInfo) {
if (result.isSuccess()) {
// authentication success
// playerInfo: Authenticated user information
// the example of getting email information
for(auto it = playerInfo.providerInfoData.begin(); it != playerInfo.providerInfoData.end(); ++it) {
hive::ProviderInfo providerInfo = it->second;
if(!providerInfo.providerEmail.empty()) {
std::string email = providerInfo.providerEmail;
break;
}
}
}
else if (result.needExit()) {
// TODO: Implement the termination of the app
// Users of the Cocos2d-x engine
// ex) exit(0);
// Unreal engine users
// Example) UKismetSystemLibrary::QuitGame(GetWorld(), nullptr, EQuitPreference::Quit, false);
}
});
API Reference: com.hive.AuthV4.showSignIn
// Request Hive SDK AuthV4 Authentication UI
AuthV4.showSignIn(object : AuthV4.AuthV4SignInListener{
override fun onAuthV4SignIn(result: ResultAPI, playerInfo: AuthV4.PlayerInfo?) {
if (result.isSuccess) {
// authentication success
// playerInfo: Authenticated user information
// the example of getting email information
playerInfo?.let {
for ((key, value) in it.providerInfoData) {
var providerInfo: AuthV4.ProviderInfo = value
if(providerInfo.providerEmail.isNotEmpty()) {
val email = providerInfo.providerEmail
break
}
}
}
} else if (result.needExit()) {
// TODO: Implement the termination of the app
// ex) exitProcess(0)
}
}
})
API Reference: com.hive.AuthV4.showSignIn
// Request Hive SDK AuthV4 Authentication UI
AuthV4.showSignIn(new AuthV4.AuthV4SignInListener() {
@Override
public void onAuthV4SignIn(ResultAPI result, AuthV4.PlayerInfo playerInfo) {
if (result.isSuccess()) {
// authentication success
// playerInfo: Authenticated user information
// the example of getting email information
if(playerInfo != null) {
for (Map.Entry<AuthV4.ProviderType , AuthV4.ProviderInfo> entry : playerInfo.getProviderInfoData().entrySet()) {
AuthV4.ProviderInfo providerInfo = entry.getValue();
if (providerInfo.getProviderEmail() != "") {
String email = providerInfo.getProviderEmail();
break;
}
}
}
}
else if (result.needExit()) {
// TODO: Implement the termination of the app
// Example) System.exit(0);
}
}
});
API Reference: HIVEAuthV4:showSignIn
var email = String()
// Request Hive SDK AuthV4 Authentication UI
AuthV4Interface.showSignIn { (result, playerInfo) in
if result.isSuccess() {
// authentication success
// playerInfo: Authenticated user information
// the example of getting email information
if let playerInfo = playerInfo {
// find providerInfo that the providerEmail exists (the provider of the current sign-in)
for key in playerInfo.providerInfoData.keys {
if let providerInfo = playerInfo.providerInfoData[key],
providerInfo.providerEmail.count > 0 {
// providerEmail != ""
email = providerInfo.providerEmail
break
}
}
}
} else if result.needExit() {
// TODO: Implement the termination of the app
// Example) exit(0)
}
}
API Reference: HIVEAuthV4:showSignIn
__block NSString* email = @"";
// Request Hive SDK AuthV4 Authentication UI
[HIVEAuthV4 showSignIn:^(HIVEResultAPI *result, HIVEPlayerInfo *playerInfo) {
if([result isSuccess]){
// authentication success
// playerInfo: Authenticated user information
// the example of getting email information
if(playerInfo != nil) {
// find providerInfo that the providerEmail exists (the provider of the current sign-in)
for (NSString* key in playerInfo.providerInfoData.allKeys) {
HIVEProviderInfo* providerInfo = playerInfo.providerInfoData[key];
if (providerInfo != nil && providerInfo.providerEmail.length > 0) {
// providerEmail != ""
email = providerInfo.providerEmail;
break;
}
}
}
} else if ([result needExit]) {
// TODO: Implement the termination of the app
// ex) exit(0);
}
}];
Note
The guest login and the custom login does not have the email information in the ProviderInfo
. It is returned as an empty character ("").
If there is no user email information, the email information in the ProviderInfo
is returned as an empty character ("").