You can check user’s profiles and suspended status after users signed in.
Getting User Profile
When user signs in Hive, you can get the user profile data by calling getProfile()
method of AuthV4 class. Profile data contains playerId
, playerName
for display name, and playerImageUrl
for user thumbnail image.
Followings are sample codes to receive profile data.
API Reference: hive.AuthV4.getProfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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 } } }); |
API Reference: AuthV4::getProfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#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 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 will either show the suspended status popup directly or return popup content for customizing the suspended status popup.
- Useing Hive-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 below.
Suspension Popup Data Returned by Hive
If the result of calling checkBlacklist()
method is success, Hive 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
|
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)
Unity®
API Reference: hive.AuthV4.checkBlacklist
12345678910111213141516using hive;Boolean isShow = false;AuthV4.checkBlacklist(isShow, (ResultAPI result, List<AuthV4.MaintenanceInfo> maintenanceInfo) => {if (!result.isSuccess()) {// Request to check for suspension failedreturn;}if(maintenanceInfo != null){// In case of suspended user} else{// If you are a general user}});C++API Reference: AuthV4::checkBlacklist
123456789101112131415161718#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 failedreturn;}if (maintenanceInfo != null){// In case of suspended user} else {// If you are a general user}});KotlinAPI Reference: AuthV4.checkBlacklist
12345678910111213141516171819import com.hive.AuthV4import com.hive.ResultAPIval isShow = falseAuthV4.checkBlacklist(isShow, object : AuthV4.AuthV4MaintenanceListener {override fun onAuthV4Maintenance(result: ResultAPI, maintenanceInfo: ArrayList<AuthV4.AuthV4MaintenanceInfo>?) {if (!result.isSuccess) {// Request to check for suspension failedreturn}if (maintenanceInfo != null) {// In case of suspended user} else {// If you are a general user}}})JavaAPI Reference: com.hive.AuthV4.checkBlacklist
1234567891011121314151617import com.hive.AuthV4;import com.hive.ResultAPI;boolean isShow = false;AuthV4.INSTANCE.checkBlacklist(isShow, (result, maintenanceInfo) -> {if (!result.isSuccess()) {// Request to check for suspension failedreturn;}if (maintenanceInfo != null) {// In case of suspended user} else {// If you are a general user}});SwiftAPI Reference: AuthV4Interface.checkBlacklist
12345678910111213141516import HIVEServicelet isShow = falseAuthV4Interface.checkBlacklist(isShow) { result, maintenanceInfo inif !result.isSuccess() {// Request to check for suspension failedreturn}if let maintenanceInfo = maintenanceInfo {// In case of suspended user} else {// If you are a general user}}Objective-CAPI Reference: HIVEAuthV4:checkBlacklist
12345678910111213141516#import <HIVEService/HIVEService-Swift.h>BOOL isShow = NO;[HIVEAuthV4 checkBlackList: isShow handler: ^(HIVEResultAPI *result, HIVEAuthV4MaintenanceInfo *maintenanceInfo) {if (![result isSuccess]) {// Request to check for suspension failedreturn;}if (maintenanceInfo != nil) {// In case of suspended user} else {// If you are a general user}}]; - In case of using Hive SDK UI (isShow = true)
Unity®API Reference: hive.AuthV4.checkBlacklist
12345678910// 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(); }});C++API Reference: AuthV4::checkBlacklist
12345678910111213// 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); }});KotlinAPI Reference: com.hive.AuthV4.checkBlacklist
123456789101112// 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) } }})JavaAPI Reference: com.hive.AuthV4.checkBlacklist
123456789101112// 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() {@Overridepublic 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); } }});SwiftAPI Reference: HIVEAuthV4:checkBlacklist
12345678910111213// 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) inif result.isSuccess() {// In case of normal user}else if result.needExit() {// TODO: Implement the termination of the app.// Example) exit(0)}}Obj-CAPI Reference: HIVEAuthV4:checkBlacklist
12345678910// 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
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
// 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(); } }); |
API Reference: AuthV4::showSignIn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
// 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
__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); } }]; |