Add-ons
Bring Facebook friend lists¶
getProviderFriendsList()
method provides the PlayerID of user’s Facebook friends in the same game. Those who plays without Facebook sync are not on the friend lists, and those who synced before return -1 as PlayerID.
Warning
Facebook revised the policy which explains the basic access permission items to Platform API in May, 2018. To use Facebook /user/friends
API henceforth, you need user_friends
permission.
Check the guideline for Facebook App Review
API Reference: hive.AuthV4.getProviderFriendsList
using hive;
AuthV4.ProviderType providerType = AuthV4.ProviderType.FACEBOOK;
AuthV4.getProviderFriendsList (providerType, (ResultAPI result, AuthV4.ProviderType providerType, Dictionary<String, Int64> providerUserIdList) => {
if (!result.isSuccess()) {
return;
}
if (providerUserIdList != null) {
foreach (KeyValuePair<String, Int64> providerUserId in providerUserIdList ) {
// providerUserId: providerUserId.Key
// playerId: providerUserId.Value
}
}
});
#include "HiveAuthV4.h"
EHiveProviderType TargetProviderType = EHiveProviderType::FACEBOOK;
FHiveAuthV4::GetProviderFriendsList(TargetProviderType,
FHiveAuthV4OnGetProviderFriendsListDelegate::CreateLambda([this](const FHiveResultAPI& Result, const EHiveProviderType& ProviderType, const ProviderFriendsMap& ProviderUserIdList) {
// (alias) using ProviderFriendsMap = TMap<FString, int64>;
if (!Result.IsSuccess()) {
return;
}
for (const auto& ProviderUserIdEntry : ProviderUserIdList) {
// ProviderUserId: ProviderUserIdEntry.Key;
// Player Id: ProviderUserIdEntry.Value;
}
}));
API Reference: AuthV4::getProviderFriendsList
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
ProviderType providerType = ProviderType::FACEBOOK;
AuthV4::getProviderFriendsList (providerType, [=](ResultAPI const & result, ProviderType providerType, map<string,PlayerID> providerUserIdList) {
if (!result.isSuccess()) {
return;
}
if (providerUserIdList != null) {
for(auto i = providerUserIdList.begin() ; i != providerUserIdList.end(); i++)
{
// providerUserId: ( i->first).c_str()
// playerId: i->second
}
}
});
API Reference: com.hive.AuthV4.getProviderFriendsList
import com.hive.AuthV4
import com.hive.ResultAPI
val providerType = AuthV4.ProviderType.FACEBOOK
AuthV4.getProviderFriendsList(providerType, object : AuthV4.AuthV4ProviderFriendsListener {
override fun onGetProviderFriendsList(result: ResultAPI, providerType: AuthV4.ProviderType, providerUserIdList: Map<String, Long>?) {
if (!result.isSuccess) {
return
}
providerUserIdList?.forEach {
// providerUserId: it.key
// playerId: it.value
}
}
})
API Reference: com.hive.AuthV4.getProviderFriendsList
import com.hive.AuthV4;
import com.hive.ResultAPI;
AuthV4.ProviderType type = AuthV4.ProviderType.FACEBOOK;
AuthV4.INSTANCE.getProviderFriendsList(type, (result, providerType, providerUserIdList) -> {
if (!result.isSuccess()) {
return;
}
if (providerUserIdList != null) {
for (Map.Entry<String, Long> entry : providerUserIdList.entrySet()) {
// providerUserId: entry.getKey();
// playerId: entry.getValue();
}
}
});
API Reference: AuthV4Interface.getProviderFriendsList
import HIVEService
AuthV4Interface.getProviderFriendsList(.Facebook) { result, retProviderType, providerUserIdList in
if !result.isSuccess() {
return
}
if let providerUserIdList = providerUserIdList {
for (key in providerUserIdList.keys) {
// providerUserId: key
// playerId: providerUserIdList[key]
}
}
}
API Reference: HIVEAuthV4:getProviderFriendsList
#import <HIVEService/HIVEService-Swift.h>
[HIVEAuthV4 getProviderFriendsList: HIVEProviderTypeFACEBOOK handler: ^(HIVEResultAPI *result, HIVEProviderType retProviderType, NSDictionary<NSString *,NSNumber *> *providerUserIdList) {
if (!result.isSuccess()) {
return;
}
if (providerUserIdList != nil) {
for (NSString *key in providerUserIdList) {
// providerUserId: key
// playerId: [[providerUserIdList objectForKey:key] longlongValue];
}
}
}];
Respond to COPPA¶
The Children's Online Privacy Protection Act (COPPA) is a United States feneral law, which aims to protect the privacy of children under the age of 13 on-line. To respond to COPPA, Hive platform released Hive SDK v4.10.0 including getAgeGateU13()
API to query whether users are under 13 or not. The API returns true
if the player age is under 13.
Sample code¶
API Reference: AuthV4.getAgeGateU13
API Reference: AuthV4 ::getAgeGateU13
API Reference: AuthV4.getAgeGateU13
API Reference: AuthV4.INSTANCE.getAgeGateU13
API Reference: AuthV4Interface.getAgeGateU13
API Reference: HIVEAuthV4 getAgeGateU13
What changes¶
The followings are implemented if ageGateU13()
returns true
.
- iOS
- Agreement request popup on Push notification is not displayed when calling
AuthV4.setup()
orAuth.initialize()
. - Push API is not implemented.
- Agreement request popup on Push notification is not displayed when calling
- Android
- More Games button is not displayed when showing Exit Popup.
- Unavailable to receive Remote Push, and Push API is not implemented.
Checking terms of services agreement for the users under 16 in GDPR applicable countries¶
Starting from Hive SDK v4 24.2.0, you can determine whether users under 16 years old have agreed to the terms in countries affected by GDPR (General Data Protection Regulation) using the Configuration.getAgeGateU16Agree()
method. If the returned value is true
, it means that a user under 16 has agreed to the terms; if false
, it means they have not. When using third-party libraries, if you need to restrict app features based on whether the user is under 16, you can utilize the Configuration.getAgeGateU16Agree()
method.
Checking legal guardian consent¶
Starting from Hive SDK v4 24.3.0, if the app uses the legal guardian consent confirmation terms, you can retrieve whether the app user has obtained legal guardian consent by calling the Configuration.getLegalGuardianConsentAgree()
method. If the value is true
, it indicates that consent has been given.
Re-ask OS permission¶
Access permission list required for playing game is organized in AndroidManifest.xml file. Try to send some permissions as string list of relevant API and use them. You can check whether user opts in or opts out of the specific permissions. If some of Dangerous permission are denied, make sure to display the popup which requests access to OS again. Other permissions are automatically opted in or opted out in accordance with the settings on user device. If you type wrong permissions or wrong words, the system regards as the permissions are not declared on the AndroidManifest.xml file and not allowed to access the permissions.
Android 6.0 (API level 23) supports this feature. If OS is iOS or Android API level is earlier than 23, ResultAPI is sent as not supported.
Note
This feature is for Android only.
Sample code¶
API Reference: PlatformHelper .requestUserPermissions
String[] requestArray = {"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.BLUETOOTH", "android.permission.READ_CONTACTS"};
List<String> requests = new List<String>(requestArray);
PlatformHelper.requestUserPermissions( requests, (ResultAPI result, String[] granted, String[] denied) => {
if (result.code == ResultAPI.Code.PlatformHelperOSNotSupported) {
//Android only
}
if (result.code == ResultAPI.Code.PlatformHelperOSVersionNotSupported) {
//Android OS version not supported.
}
if (granted != null && granted.Length > 0) {
foreach (String name in granted) {
// List of permissions accepted among requests
}
}
if (denied != null && denied.Length > 0) {
foreach (String name denied) {
// List of permissions denied among requests
}
}
});
#include "HivePlatformHelper.h"
TArray<FString> Requests;
Requests.Add(TEXT("android.permission.WRITE_EXTERNAL_STORAGE"));
Requests.Add(TEXT("android.permission.READ_CONTACTS"));
FHivePlatformHelper::RequestUserPermissions(Requests, FHivePlatformHelperOnUserPermissionsDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<FString>& GrantedRequests, const TArray<FString>& DeniedRequests) {
switch(Result.Code) {
case FHiveResultAPI::ECode::Success: {
if (GrantedRequests.Num() > 0) {
// List of permissions accepted among requests
}
if (DeniedRequests.Num() > 0) {
// List of permissions denied among requests
}
}
break;
case FHiveResultAPI::ECode::PlatformHelperOSVersionNotSupported:
// Android OS version not supported.
break;
default:
// Other exceptions
break;
}
}));
API Reference: PlatformHelper ::requestUserPermissions
string requestArray[] = {"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.BLUETOOTH", "android.permission.READ_CONTACTS"};
vector<string> requests(begin(requestArray), end(requestArray));
PlatformHelper::requestUserPermissions(requests, [=](ResultAPI const & result, vector<string> const & granted, vector<string> const & denied) {
if (result.code == hive::ResultAPI::PlatformHelperOSNotSupported) {
//Android only
}
if (result.code == hive::ResultAPI::PlatformHelperOSVersionNotSupported) {
//Android OS version not supported.
}
if (!granted.empty()) {
for (string name : granted) {
// List of permissions accepted among requests
}
}
if (!denied.empty()) {
for (string name : denied) {
// List of permissions denied among requests
}
}
});
API Reference: PlatformHelper.requestUserPermissions
import com.hive.PlatformHelper
import com.hive.ResultAPI
val requests = arrayListOf(
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.BLUETOOTH",
"android.permission.READ_CONTACTS"
)
PlatformHelper.requestUserPermissions(requests, object : PlatformHelper.RequestUserPermissionsListener {
override fun onRequestUserPermissions(result: ResultAPI, granted: List<String>, denied: List<String>) {
when (result.code) {
ResultAPI.Code.Success -> {
if (granted.isNotEmpty()) {
// List of permissions accepted among requests
}
if (denied.isNotEmpty()) {
// List of permissions denied among requests
}
}
ResultAPI.Code.PlatformHelperOSVersionNotSupported -> {
//Android OS version not supported.
}
else -> {
// other exception situations
}
}
}
})
API Reference: PlatformHelper .INSTANCE.requestUserPermissions
import com.hive.PlatformHelper;
import com.hive.ResultAPI;
List<String> requests = Arrays.asList(
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.BLUETOOTH",
"android.permission.READ_CONTACTS");
PlatformHelper.INSTANCE.requestUserPermissions(requests, (result, granted, denied) -> {
switch (result.getCode()) {
case Success:
if (!granted.isEmpty()) {
// List of permissions accepted among requests
}
if (!denied.isEmpty()) {
// List of permissions denied among requests
}
break;
case PlatformHelperOSVersionNotSupported:
//Android OS version not supported.
break;
default:
// other exception situations
break;
}
});
Use device management service¶
Device Management Service automatically implements upon login according to settings on Hive Console. After login, a game calls theshowDeviceManagement()
method of AuthV4 class and displays the device management list to a user.
When login is canceled due to the failure of device authentication, a game with device management service should handle the AuthV4NotRegisteredDevice
code of Result API for attempting to silent login again or carrying out to logout. For more information on the device management service, refer to the operation guide: Introduction to the device management service.
API Reference: AuthV4.showDeviceManagement
API Reference: AuthV4 ::showDeviceManagement
API Reference: AuthV4.showDeviceManagement
API Reference: AuthV4.INSTANCE .showDeviceManagement
API Reference: AuthV4Interface .showDeviceManagement
API Reference: HIVEAuthV4 showDeviceManagement
Google Play game achievement and leaderboard¶
To get your game featured on Google Play Games, you need to implement achievement and leaderboard function of Google Play Games.
If user signs in your game with Google account among IdPs, it automatically signs in Play Games Services(PGS), so achievement and leaderboard are available. In case the user signs out from the settings screen of PGS, player account is signed out as same as the process when signed-out button in game is tapped. For more information about the function of PGS, see Google Play Games Services guide.
Note
In case of implementing AuthV4Helper class,
-
If user cancelled implicit login to PGS while loading a game, system memorizes the status and does not try implicit login again. Even if auto login is available while player session is valid, the system remember the denied state.
-
If user does not sign in PGS, the result of achievement is not sent to PGS.
This contents comply with Google Play Games Services guide.
Send playerID¶
If you need to request PlayerID to Google Play Games, implement getGooglePlayerId()
method in the ProviderGoogle class. By implementing this method, it sends PlayerID as well as AuthCode, which validates session key.
Followings are sample codes.
API Reference: hive.ProviderGoogle.getGooglePlayerId
API Reference: ProviderGoogle::getGooglePlayerId
// Request the playerID from Google Play Games.
ProviderGoogle::getGooglePlayerId([=](ResultAPI const &result, std::string const &googlePlayerId, std::string const &authCode) {
if (result.isSuccess())
{
// Success in API call.
}
});
API Reference: com.hive.ProviderGoogle.getGooglePlayerId
Achievement¶
Implement ProviderGoogle class to use Achievement function of Google Play Games through Hive SDK.
Request to reveal a hidden achievement¶
To reveal a hidden achievement to the currently signed-in player, call achievementsReveal()
method. It will have no effect but uncover the 0% of achievement. Followings are sample codes.
API Reference: hive.ProviderGoogle.achievementsReveal
#include "HiveProviderGoogle.h"
// Achievement ID
FString AchievementId = TEXT("abcdef123456");
FHiveProviderGoogle::AchievementsReveal(AchievementId, FHiveProviderGoogleOnAchievementsDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// API call successful
}
}));
API Reference: ProviderGoogle::achievementsReveal
API Reference: ProviderGoogle.achievementsReveal
import com.hive.ProviderGoogle
import com.hive.ResultAPI
//Achievement ID
val achievementId = "abcdef123456"
ProviderGoogle.achievementsReveal(achievementId, object : ProviderGoogle.GoogleAchievementsListener {
override fun onAchievementsResult(resultAPI: ResultAPI) {
if (resultAPI.isSuccess) {
// call successful
}
}
})
API Reference: ProviderGoogle .INSTANCE.achievementsReveal
Request to unlock an achievement¶
To unlock an achievement to the currently signed-in player, call achievementsUnlock()
method. This method will mark 100% of achievement regardless of its status; hidden or not. Followings are sample codes.
API Reference: ProviderGoogle.achievementsUnlock
API Reference: ProviderGoogle::achievementsUnlock
API Reference: ProviderGoogle.achievementsUnlock
import com.hive.ProviderGoogle
import com.hive.ResultAPI
//Achievement ID
val achievementId = "abcdef123456"
ProviderGoogle.achievementsUnlock(achievementId, object : ProviderGoogle.GoogleAchievementsListener {
override fun onAchievementsResult(resultAPI: ResultAPI) {
if (resultAPI.isSuccess) {
// call successful
}
}
})
API Reference: ProviderGoogle .INSTANCE.achievementsUnlock
Request to increment an achievement¶
To use the request function to increment achievement, set the achievement value as a parameter, and then call achievementsIncrement()
method. The achievement value is the sum of the value set when the corresponding API is called and the achievement is automatically achieved when the total sum is max.
Followings are sample codes.
API Reference: hive.ProviderGoogle.achievementsIncrement
#include "HiveProviderGoogle.h"
//Achievement ID
FString AchievementId = TEXT("abcdef123456");
// Achievement numbers
int32 Value = 1;
FHiveProviderGoogle::AchievementsIncrement(AchievementId, Value, FHiveProviderGoogleOnAchievementsDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// call successful
}
}));
API Reference: ProviderGoogle::achievementsIncrement
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
//Achievement ID
string achievementId = "abcdef123456";
// Achievement numbers
int value = 1;
ProviderGoogle::achievementsIncrement(achievementId, value, [=](ResultAPI const & result) {
if(result.isSuccess()){
// call successful
}
});
API Reference: ProviderGoogle.achievementsIncrement
import com.hive.ProviderGoogle
import com.hive.ResultAPI
//Achievement ID
val achievementId = "abcdef123456"
// Achievement numbers
val value = 1
ProviderGoogle.achievementsIncrement(achievementId, value, object : ProviderGoogle.GoogleAchievementsListener {
override fun onAchievementsResult(resultAPI: ResultAPI) {
if (resultAPI.isSuccess) {
// call successful
}
}
})
API Reference: ProviderGoogle .INSTANCE.achievementsIncrement
Request to show achievement list (Helper)¶
Note
SDK 4.7.0 provides Helper, which easily compares signed-in account on user device and PlayerID-synced account. If two accounts are not the same, refer to IdP Sync page to handle the situation.
Call showAchievements()
method to request achievement list of Google Play Games.
Followings are sample codes.
API Reference: AuthV4.Helper.showAchievements
using hive;
AuthV4.Helper.showAchievements ((ResultAPI result, AuthV4.PlayerInfo playerInfo) => {
switch (result.code) {
case ResultAPI.Code.Success:
// Deliver Success with achievement indication
break;
case ResultAPI.Code.AuthV4ConflictPlayer:
// account conflict
break;
case ResultAPI.Code.AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
#include "HiveAuthV4.h"
FHiveAuthV4::Helper::ShowAchievements(FHiveAuthV4HelperDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TOptional<FHivePlayerInfo>& PlayerInfo) {
switch (Result.Code) {
case FHiveResultAPI::ECode::Success:
// Deliver Success with achievement indicatio
break;
case FHiveResultAPI::ECode::AuthV4ConflictPlayer:
// 계정 충돌
break;
case FHiveResultAPI::ECode::AuthV4GoogleLogout:
// TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
}));
API Reference: AuthV4 ::Helper::showAchievements
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
AuthV4::Helper::showAchievements([=](ResultAPI const & result, shared_ptr playerInfo) {
switch (result.code) {
case ResultAPI::Success:
// Deliver Success with achievement indication
break;
case ResultAPI::AuthV4ConflictPlayer:
// account conflict
break;
case ResultAPI::AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
API Reference: AuthV4.Helper.showAchievements
import com.hive.AuthV4
import com.hive.ResultAPI
AuthV4.Helper.showAchievements(object : AuthV4.Helper.AuthV4HelperListener {
override fun onAuthV4Helper(result: ResultAPI, playerInfo: AuthV4.PlayerInfo?) {
when (result.code) {
ResultAPI.Code.Success -> {
// Deliver Success with achievement indication
}
ResultAPI.Code.AuthV4ConflictPlayer -> {
// account conflict
}
ResultAPI.Code.AuthV4GoogleLogout -> {
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
}
else -> {
// other exception situations
}
}
}
})
API Reference: AuthV4.Helper.INSTANCE.showAchievements
import com.hive.AuthV4;
import com.hive.ResultAPI;
AuthV4.Helper.INSTANCE.showAchievements((result, playerInfo) -> {
switch (result.getCode()) {
case Success:
// Deliver Success with achievement indication
break;
case AuthV4ConflictPlayer:
// account conflict
break;
case AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
Warning
If user signs out from the settings screen of Play Games Services, player account is signed out and error code named ResultAPI.Code.AuthV4GoogleLogout is sent as a callback. As signed-out is completed, logout popup is shown up and display changes to game title.
Request to show achievement list (Auth v4)¶
Call showAchievements()
method to request achievement list of Google Play Games.
Followings are sample codes.
API Reference: ProviderGoogle .showAchievements
using hive;
ProviderGoogle.showAchievements((ResultAPI result) => {
switch (result.code) {
case ResultAPI.Code.Success:
// Deliver Success with achievement indication
break;
case ResultAPI.Code.AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
#include "HiveProviderGoogle.h"
FHiveProviderGoogle::ShowAchievements(FHiveProviderGoogleOnLeaderboardsDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
case FHiveResultAPI::ECode::Success:
// 업적 표시와 함께 Success 전달
break;
case FHiveResultAPI::ECode::AuthV4GoogleLogout:
// TODO:
// Google Play 로그아웃 후 게임 로그아웃 실행
// 게임 재실행은 개발 스튜디오에서 처리해야함
break;
default:
// 기타 예외 상황
break;
}));
API Reference: ProviderGoogle ::showAchievements
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
ProviderGoogle::showAchievements([=](ResultAPI const & result) {
switch (result.code) {
case ResultAPI::Success:
// Deliver Success with achievement indication
break;
case ResultAPI::AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
API Reference: ProviderGoogle.showAchievements
import com.hive.ProviderGoogle
import com.hive.ResultAPI
ProviderGoogle.showAchievements(object : ProviderGoogle.GoogleAchievementsListener {
override fun onAchievementsResult(resultAPI: ResultAPI) {
when(resultAPI.code) {
ResultAPI.Code.Success -> {
// Deliver Success with achievement indication
}
ResultAPI.Code.AuthV4GoogleLogout -> {
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
}
else -> {
// other exception situations
}
}
}
})
API Reference: ProviderGoogle.INSTANCE.showAchievements
import com.hive.ProviderGoogle;
import com.hive.ResultAPI;
ProviderGoogle.INSTANCE.showAchievements(resultAPI -> {
switch (resultAPI.getCode()) {
case Success:
// Deliver Success with achievement indication
break;
case AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
Warning
If user signs out from the settings screen of Play Games Services, error code named ResultAPI.Code.AuthV4GoogleLogout is sent as a callback. Once this error is sent, make sure to code as same as the process when signed-out button in game is tapped.
Leaderboard¶
Implement ProviderGoogle class to use Leaderboard function of Google Play Games through Hive SDK.
Leaderboard score updates¶
Call leaderboardsSubmitScore()
method to request leaderboard score updates of Google Play Games.
Followings are sample codes.
API Reference: hive.ProviderGoogle.leaderboardsSubmitScore
#include "HiveProviderGoogle.h"
// Leaderboard ID
FString LeaderboardId = TEXT("12345abcde");
// Leaderboard score number
int64 Score = 100;
FHiveProviderGoogle::LeaderboardsSubmitScore(LeaderboardId, Score, FHiveProviderGoogleOnLeaderboardsDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// API call successful
}
}));
API Reference: ProviderGoogle::leaderboardsSubmitScore
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
// Leaderboard ID
string leaderboardId = "12345abcde";
// Leaderboard score number
long score = 100;
ProviderGoogle::leaderboardsSubmitScore(leaderboardId, score, [=](ResultAPI const & result) {
if (result.isSuccess()) {
// API call successful
}
});
API Reference: ProviderGoogle.leaderboardsSubmitScore
import com.hive.ProviderGoogle
import com.hive.ResultAPI
// Leaderboard ID
val leaderboardId = "12345abcde"
// Leaderboard score number
val score = 100L
ProviderGoogle.leaderboardsSubmitScore(leaderboardId, score, object : ProviderGoogle.GoogleLeaderboardsListener {
override fun onLeaderboardsResult(resultAPI: ResultAPI) {
if (resultAPI.isSuccess) {
// API call successful
}
}
})
API Reference: com.hive.ProviderGoogle.leaderboardsSubmitScore
import com.hive.ProviderGoogle;
import com.hive.ResultAPI;
// Leaderboard ID
String leaderboardId = "12345abcde";
// Leaderboard score number
long score = 100;
ProviderGoogle.INSTANCE.leaderboardsSubmitScore(leaderboardId, score, resultAPI -> {
if (resultAPI.isSuccess()) {
// API call successful
}
});
Request to show leaderboard list (Helper)¶
Call showLeaderboards()
method to request leaderboard list of Google Play Games.
Followings are sample codes.
API Reference: hive.AuthV4.Helper.showLeaderboard
using hive;
AuthV4.Helper.showLeaderboard ((ResultAPI result, AuthV4.PlayerInfo playerInfo) => {
switch (result.code) {
case ResultAPI.Code.Success:
// Deliver Success with leaderboard display
break;
case ResultAPI.Code.AuthV4ConflictPlayer:
// account conflict
break;
case ResultAPI.CodeAuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
#include "HiveAuthV4.h"
FHiveAuthV4::Helper::ShowLeaderboard(FHiveAuthV4HelperDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TOptional<FHivePlayerInfo>& PlayerInfo) {
case FHiveResultAPI::ECode::Success:
// Deliver Success with leaderboard display
break;
case FHiveResultAPI::ECode::AuthV4ConflictPlayer:
// account conflict
break;
case FHiveResultAPI::ECode::AuthV4GoogleLogout:
// TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// 기타 예외 상황
break;
}));
API Reference: com.hive.AuthV4.Helper.showLeaderboard
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
AuthV4::Helper::showLeaderboard([=](ResultAPI const & result, shared_ptr playerInfo) {
switch (result.code) {
case ResultAPI::Success:
// Deliver Success with leaderboard display
break;
case ResultAPI::AuthV4ConflictPlayer:
// account conflict
break;
case ResultAPI::AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
break;
}
});
API Reference: Helper.showLeaderboard
import com.hive.AuthV4
import com.hive.ResultAPI
AuthV4.Helper.showLeaderboard(object : AuthV4.Helper.AuthV4HelperListener {
override fun onAuthV4Helper(result: ResultAPI, playerInfo: AuthV4.PlayerInfo?) {
when (result.code) {
ResultAPI.Code.Success -> {
// Deliver Success with leaderboard display
}
ResultAPI.Code.AuthV4ConflictPlayer -> {
// account conflict
}
ResultAPI.Code.AuthV4GoogleLogout -> {
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
}
else -> {
// other exception situations
}
}
}
})
API Reference: AuthV4.Helper.INSTANCE.showLeaderboard
import com.hive.AuthV4;
import com.hive.ResultAPI;
AuthV4.Helper.INSTANCE.showLeaderboard((result, playerInfo) -> {
switch (result.getCode()) {
case Success:
// Deliver Success with leaderboard display
break;
case AuthV4ConflictPlayer:
// account conflict
break;
case AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
Warning
If user sign out from the settings screen of Play Games Services, player account is signed out and error code named ResultAPI.Code.AuthV4GoogleLogout is sent as a callback. As signed-out is completed, logout popup is shown up and display changes to game title.
Request to show leaderboard list (Auth v4)¶
Call showLeaderboards()
method to request leaderboard list of Google Play Games.
Followings are sample codes.
API Reference: hive.ProviderGoogle.showLeaderboards
using hive;
ProviderGoogle.showLeaderboards(onLeaderboardsResult, (ResultAPI result) => {
switch (result.code) {
case ResultAPI.Code.Success:
// Deliver Success with leaderboard display
break;
case ResultAPI.CodeAuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
#include "HiveProviderGoogle.h"
FHiveProviderGoogle::ShowLeaderboard(FHiveProviderGoogleOnLeaderboardsDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
case FHiveResultAPI::ECode::Success:
// Deliver Success with leaderboard display
break;
case FHiveResultAPI::ECode::AuthV4GoogleLogout:
// TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}));
API Reference: ProviderGoogle::showLeaderboards
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
ProviderGoogle::showLeaderboard([=](ResultAPI const & result) {
switch (result.code) {
case ResultAPI::Success:
// Deliver Success with leaderboard display
break;
case ResultAPI::AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
API Reference: ProviderGoogle.showLeaderboards
import com.hive.ProviderGoogle
import com.hive.ResultAPI
ProviderGoogle.showLeaderboards(object : ProviderGoogle.GoogleLeaderboardsListener {
override fun onLeaderboardsResult(resultAPI: ResultAPI) {
when(resultAPI.code) {
ResultAPI.Code.Success -> {
// Deliver Success with leaderboard display
}
ResultAPI.Code.AuthV4GoogleLogout -> {
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
}
else -> {
// other exception situations
}
}
}
})
API Reference: com.hive.ProviderGoogle.showLeaderboards
import com.hive.ProviderGoogle;
import com.hive.ResultAPI;
ProviderGoogle.INSTANCE.showLeaderboards(resultAPI -> {
switch (resultAPI.getCode()) {
case Success:
// Deliver Success with leaderboard display
break;
case AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
Warning
If user signs out from the settings screen of Play Games Services, error code named ResultAPI.Code.AuthV4GoogleLogout is sent as a callback. Once this error is sent, make sure to code as same as the process when signed-out button in game is tapped.
Apple game center game achievement and leaderboard¶
To get your game featured on Apple Game Center, you need to apply achievement and leaderboard function of Apple Game Center.
Regardless authentication status of users, the two functions of Apple Game Center are provided by Hive SDK. That is, achievement and leaderboard uses the Apple Game Center account, but achievement and leaderboard uses the Apple Game Center account, but this account may not be linked to Hive account or differ from Hive account which the player currently signed in.
For more information about the function of Apple Game Center, see Apple Game Center Guide.
Note
iOS Enterprise does not support Apple Game Center.
Achievement¶
Implement ProviderApple class to use Achievement function of Apple Game Center through Hive SDK.
Request achievement list¶
To load an achievement list, call loadAchievements()
method.
Followings are sample codes.
API Reference: hive.ProviderApple.loadAchievements
// Request achievement list to Provider Apple
// using hive
// Callback handler managing the request for achievement list to Provider Apple
public void onLoadAchievements(ResultAPI result, List achievementList) {
Logger.log("ProviderTestView.onLoadAchievements() Callback\nresult = " + result.toString() + "\n");
if (result.isSuccess() != true)
return;
}
// Request achievement list to Provider Apple
ProviderApple.loadAchievements(onLoadAchievements);
API Reference: ProviderApple::loadAchievements
// Request achievement list to Provider Apple
ProviderApple::loadAchievements([=](ResultAPI const & result,std::vector<ProviderAppleAchievement>; const & achievements) {
// Result callback
cout<<"ProviderApple::loadAchievements() Callback"<<endl<<result.toString()<<endl;
if (result.isSuccess() != true)
return;
});
API Reference: HIVEProviderApple::showAchievements:
// Request achievement list to Provider Apple
[HIVEProviderApple loadAchievements:^(HIVEResultAPI *result, NSArray<HIVEProviderAppleAchievement *>; *achievements) {
Loggerd(@"HIVEProviderApple.loadAchievements:\nresult = %@\nachievements = %@", result, achievements);
if (result.isSuccess) {
}
else {
}
}];
Request to report an achievement¶
To report an achievement, call reportAchievement()
method with parameters set to Achievement rate and Notification banner exposure for successful achievements.
Followings are sample codes.
API Reference: hive .ProviderApple.reportAchievement
using hive;
//Achievement achieved %. Achievement completed at 100
String achievementPercent = "100";
// Whether to display the top banner when an achievement is successful. default false
Boolean isShow = true;
//Achievement Id
String achievementId = "com.hivesdk.achievement.10hit";
ProviderApple.reportAchievement(achievementPercent, isShow, achievementId, (ResultAPI result) => {
if (result.isSuccess()) {
// call successful
}
});
#include "HiveProviderApple.h"
//Achievement achieved %. Achievement completed at 100
FString Percent = TEXT("100");
// Whether to display the top banner when an achievement is successful. default false
bool bIsShow = true;
// Achievement Id
FString AchievementId = TEXT("com.hivesdk.achievement.10hit");
FHiveProviderApple::ReportAchievement(Percent, bIsShow, AchievementId, FHiveProviderAppleOnReportAchievement::CreateLambda([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// API call successful
}
}));
API Reference: ProviderApple ::reportAchievement
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
//Achievement achieved %. Achievement completed at 100
string achievementPercent = "100";
// Whether to display the top banner when an achievement is successful. default false
bool isShow = true;
//Achievement Id
string achievementId = "com.hivesdk.achievement.10hit";
ProviderApple::reportAchievement(achievementPercent, isShow, achievementId, [=](ResultAPI const & result) {
if (result.isSuccess()) {
// call successful
}
});
API Reference: ProviderApple.reportAchievement
import HIVEService
//Achievement achieved %. Achievement completed at 100
letachievementPercent = "100"
// Whether to display the top banner when an achievement is successful. default false
let isShow = true
//Achievement Id
let achievementId = "com.hivesdk.achievement.10hit"
ProviderApple.reportAchievement(achievementPercent, showsCompletionBanner: isShow, achievementIdentifier: achievementId) { result in
if result.isSuccess() {
// call successful
}
}
API Reference: HIVEProviderApple reportAchievement
#import <HIVEService/HIVEService-Swift.h>
//Achievement achieved %. Achievement complete when 100
NSString *achievementPercent = @"100";
// Whether to display the top banner when an achievement is successful. default NO
BOOL isShow = YES;
//Achievement Id
NSString *achievementId = @"com.hivesdk.achievement.10hit";
[HIVEProviderApple reportAchievement: achievementPercent showsCompletionBanner: isShow achievementIdentifier: achievementId handler: ^(HIVEResultAPI *result) {
if ([result isSuccess]) {
// call successful
}
}];
Request to show achievement UI (Helper)¶
Note
SDK 4.7.0 provides Helper, which easily compares signed-in account on user device and PlayerID-synced account. If two accounts are not the same, refer to IdP Sync page to handle the situation.
To show achievement UI, call showAchievements()
method.
Followings are sample codes.
API Reference: hive.AuthV4.Helper.showAchievements
using hive;
AuthV4.Helper.showAchievements ((ResultAPI result, AuthV4.PlayerInfo playerInfo) => {
switch (result.code) {
case ResultAPI.Code.Success:
// Deliver Success with achievement indication
break;
case ResultAPI.Code.AuthV4ConflictPlayer:
// account conflict
break;
case ResultAPI.Code.AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
#include "HiveAuthV4.h"
FHiveAuthV4::Helper::ShowAchievements(FHiveAuthV4HelperDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TOptional<FHivePlayerInfo>& PlayerInfo) {
switch (Result.Code) {
case FHiveResultAPI::ECode::Success:
// Deliver Success with achievement indication
break;
case FHiveResultAPI::ECode::AuthV4ConflictPlayer:
// account conflict
break;
default:
// other exception situations
break;
}
}));
API Reference: AuthV4 ::Helper::showAchievements
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
AuthV4::Helper::showAchievements([=](ResultAPI const & result, shared_ptr playerInfo) {
switch (result.code) {
case ResultAPI::Success:
// Deliver Success with achievement indication
break;
case ResultAPI::AuthV4ConflictPlayer:
// account conflict
break;
case ResultAPI::AuthV4GoogleLogout:
//TODO:
// After logging out of Google Play, log out of the game
// Relaunching the game must be handled by the development studio
break;
default:
// other exception situations
break;
}
});
API Reference: AuthV4Interface .helper().showAchievements
// If the currently logged in Hive account is not connected to GameCenter
// Automatically attempts to connect to GameCenter
import HIVEService
AuthV4Interface.helper().showAchievements() { result, playerInfo in
switch result.getCode() {
case .success:
// Deliver Success with achievement indication
case .authV4ConflitPlayer:
// account conflict
default:
break
}
}
API Reference: [ HIVEAuthV4 helper] showAchievements
// If the currently logged in Hive account is not connected to GameCenter
// Automatically attempts to connect to GameCenter
#import <HIVEService/HIVEService-Swift.h>
[[HIVEAuthV4 helper] showAchievements: ^(HIVEResultAPI *result, HIVEPlayerInfo *playerInfo) {
switch ([result getCode]) {
case HIVEResultAPICodeSuccess:
// Deliver Success with achievement indication
break;
case HIVEResultAPICodeAuthV4ConflictPlayer:
// account conflict
break;
default:
// other exception situations
break;
}
}];
Request to show achievement UI¶
To show achievement UI, call showAchievements()
method.
Followings are sample codes.
API Reference: ProviderApple.showAchievements
API Reference: ProviderApple::showAchievements
API Reference: ProviderApple.showAchievements
API Reference: HIVEProviderApple showAchievements
Request to reset an achievement¶
To reset an achievement, implement resetAchievements()
method.
Followings are sample codes.
API Reference: hive.ProviderApple.resetAchievements
API Reference: ProviderApple ::resetAchievements
API Reference: resetAchievements(_:)
API Reference: HIVEProviderApple showAchievements
Leaderboard¶
Implement ProviderApple class to use Leaderboard function of Apple Game Center through Hive SDK.
Request to report the leaderboard score¶
To report the leaderboard score to Apple Game Center, call reportScore()
method.
Followings are sample codes.
API Reference: hive .ProviderApple.reportScore
#include "HiveProviderApple.h"
FString PlayerScore = TEXT("1234");
FString LeaderBoardId = TEXT("com.hivesdk.leaderboard.10hit");
FHiveProviderApple::ReportScore(PlayerScore, LeaderBoardId, FHiveProviderAppleOnReportLeaderboard::CreateLambda([this](const FHiveResultAPI& Result) {
if (Result.IsSuccess()) {
// API call successful
}
}));
API Reference: ProviderApple ::reportScore
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
string playerScore = "1234";
string leaderBoardId = "com.hivesdk.leaderboard.10hit";
ProviderApple::reportScore(playerScore, leaderBoardId, [=](ResultAPI const & result) {
if (result.isSuccess()) {
// call successful
}
});
API Reference: HIVEProviderApple ::reportScore:leaderboardIdentifier:handler:
#import <HIVEService/HIVEService-Swift.h>
NSString *playerScore = @"1234";
NSString *leaderBoardId = "com.hivesdk.leaderboard.10hit";
[HIVEProviderApple reportScore: playerScore leaderboardIdentifier: leaderBoardId handler: ^(HIVEResultAPI *result) {
if ([result isSuccess]) {
// call successful
}
}];
Request to show leaderboard UI (Helper)¶
To show leaderboard UI, call showLeaderboard()
method.
Followings are sample codes.
API Reference: hive .AuthV4.Helper.showLeaderboard
// If the currently logged in Hive account is not connected to GameCenter
// Automatically attempts to connect to GameCenter
using hive;
AuthV4.Helper.showLeaderboard((ResultAPI result, AuthV4.PlayerInfo playerInfo) => {
switch (result.code) {
case ResultAPI.Code.Success:
// Deliver Success with leaderboard display
break;
case ResultAPI.Code.AuthV4ConflictPlayer:
// account conflict
break;
default:
// other exception situations
break;
}
});
API Reference: AuthV4 ::Helper::showLeaderboard
// If the currently logged in Hive account is not connected to GameCenter
// Automatically attempts to connect to GameCenter
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
AuthV4::Helper::showLeaderboard([=](ResultAPI const & result, shared_ptr<PlayerInfo> playerInfo) {
switch (result.code) {
case ResultAPI::Success:
// Deliver Success with leaderboard display
break;
case ResultAPI::AuthV4ConflictPlayer:
// account conflict
break;
default:
break;
}
});
API Reference: showLeaderboard
// If the currently logged in Hive account is not connected to GameCenter
// Automatically attempts to connect to GameCenter
import HIVEService
AuthV4Interface.helper().showLeaderboard() { result, playerInfo in
switch result.getCode() {
case .success:
// Deliver Success with leaderboard display
case .authV4ConflictPlayer:
// account conflict
default:
break
}
}
API Reference: HIVEProviderApple ::showLeaderboard:
// If the currently logged in Hive account is not connected to GameCenter
// Automatically attempts to connect to GameCenter
#import <HIVEService/HIVEService-Swift.h>
[[HIVEAuthV4 helper] showLeaderboard: ^(HIVEResultAPI *result, HIVEPlayerInfo *playerInfo) {
switch ([result getCode]) {
case HIVEResultAPICodeSuccess:
// Deliver Success with leaderboard display
break;
case HIVEResultAPICodeAuthV4ConflictPlayer:
// account conflict
break;
default:
// other exception situations
break;
}
}];
Request to show leaderboard UI¶
To show leaderboard UI, call showLeaderboard()
method.
Followings are sample codes.
API Reference: hive .ProviderApple.showLeaderboard
API Reference: ProviderApple ::showLeaderboard
API Reference: showLeaderboard(_:)
API Reference: HIVEProviderApple ::showLeaderboard:
Post photos on social media¶
Users can share and post photos on Facebook by importing photos from the gallery of their devices through a game. Followings are sample codes:
API Reference: SocialV4. sharePhoto
API Reference: SocialV4::sharePhoto
API Reference: SocialV4.sharePhoto
API Reference: SocialV4.INSTANCE. sharePhoto
API Reference: SocialV4Interface.sharePhoto
API Reference: HIVESocialV4 sharePhoto
Automatic login to PC games with community login¶
When you click the Play on PC button on the community website, the PC game will be launched through Crossplay Launcher.
At this time, the PC game is automatically logged in using the ‘login token value’ of the community.
Warning
Automatic login to PC games with community login feature only works on Windows versions of Hive SDK v4 24.0.0 and higher.
Steam implicit login (Unity Windows)¶
Starting from Hive SDK v4 Unity Windows 24.2.0, Steam implicit login is supported. If you choose to use implicit login, you must use AuthV4.Helper.signIn
and cannot use AuthV4.signIn(AUTO,...)
. As it is an implicit login, the app user logs in to the Steam only once after installing the game. When using Steam implicit login, you must implement the removal of the propFolder
folder, which stores SDK configuration data, upon app deletion.