ส่วนเสริม
นำเข้ารายชื่อเพื่อนใน Facebook¶
วิธีการ getProviderFriendsList() จะให้ PlayerID ของเพื่อน Facebook ของผู้ใช้ที่เล่นเกมเดียวกัน ผู้ที่เล่นโดยไม่มีการซิงค์ Facebook จะไม่อยู่ในรายชื่อเพื่อน และผู้ที่เคยซิงค์ก่อนหน้านี้จะคืนค่า -1 เป็น PlayerID
Warning
Facebook ได้ปรับปรุงนโยบายที่อธิบายรายการสิทธิ์การเข้าถึงพื้นฐานสำหรับ Platform API ในเดือนพฤษภาคม 2018 เพื่อใช้ Facebook /user/friends API ตั้งแต่นี้ไป คุณต้องมีสิทธิ์ user_friends 
 ตรวจสอบแนวทางสำหรับการตรวจสอบแอป Facebook
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];    
             }    
         }    
}];
ตอบสนองต่อ COPPA¶
พระราชบัญญัติคุ้มครองความเป็นส่วนตัวของเด็กทางออนไลน์ (COPPA) เป็นกฎหมายของสหรัฐอเมริกาที่มีวัตถุประสงค์เพื่อปกป้องความเป็นส่วนตัวของเด็กที่อายุต่ำกว่า 13 ปีทางออนไลน์ เพื่อให้สอดคล้องกับ COPPA, Hive แพลตฟอร์มได้ปล่อย Hive SDK v4.10.0 ซึ่งรวมถึง API getAgeGateU13() เพื่อสอบถามว่าผู้ใช้มีอายุต่ำกว่า 13 ปีหรือไม่ API จะส่งคืน true หากอายุของผู้เล่นต่ำกว่า 13 ปี.
ตัวอย่างโค้ด¶
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
การเปลี่ยนแปลง¶
หาก ageGateU13() คืนค่า true จะมีการดำเนินการดังต่อไปนี้
- iOS- ไม่แสดงป๊อปอัพขอความยินยอมเมื่อเรียกใช้ AuthV4.setup()หรือAuth.initialize().
- Push API ยังไม่ได้รับการพัฒนา.
 
- ไม่แสดงป๊อปอัพขอความยินยอมเมื่อเรียกใช้ 
- Android- เกมเพิ่มเติม ปุ่มไม่แสดงเมื่อแสดงป๊อปอัพออก.
- ไม่สามารถรับ Remote Push ได้ และ Push API ยังไม่ได้รับการพัฒนา.
 
ตรวจสอบข้อตกลงการให้บริการสำหรับผู้ใช้ที่อายุต่ำกว่า 16 ปีในประเทศที่มีการบังคับใช้ GDPR¶
เริ่มต้นจาก Hive SDK v4 24.2.0 คุณสามารถตรวจสอบได้ว่าผู้ใช้ที่อายุต่ำกว่า 16 ปีได้ตกลงตามเงื่อนไขในประเทศที่ได้รับผลกระทบจาก GDPR (กฎระเบียบการคุ้มครองข้อมูลทั่วไป) โดยใช้วิธี Configuration.getAgeGateU16Agree() หากค่าที่ส่งกลับเป็น true หมายความว่าผู้ใช้ที่อายุต่ำกว่า 16 ปีได้ตกลงตามเงื่อนไขแล้ว; หากเป็น false หมายความว่าพวกเขายังไม่ได้ตกลง เมื่อใช้ไลบรารีของบุคคลที่สาม หากคุณต้องการจำกัดฟีเจอร์ของแอปตามว่าผู้ใช้มีอายุต่ำกว่า 16 ปีหรือไม่ คุณสามารถใช้วิธี Configuration.getAgeGateU16Agree() ได้
การตรวจสอบความยินยอมของผู้ปกครองทางกฎหมาย¶
เริ่มต้นจาก Hive SDK v4 24.3.0 หากแอปใช้เงื่อนไขการยืนยันความยินยอมจากผู้ปกครองทางกฎหมาย (legal guardian consent confirmation) คุณสามารถดึงข้อมูลว่า ผู้ใช้แอปได้รับความยินยอมจากผู้ปกครองทางกฎหมายหรือไม่ โดยการเรียกใช้เมธอด Configuration.getLegalGuardianConsentAgree() หากค่าคือ true หมายความว่ามีการให้ความยินยอมแล้ว
ขอสิทธิ์ OS ใหม่¶
รายการอนุญาตการเข้าถึงที่จำเป็นสำหรับการเล่นเกมจะถูกจัดระเบียบในไฟล์ AndroidManifest.xml ลองส่งอนุญาตบางอย่างเป็นรายการสตริงของ API ที่เกี่ยวข้องและใช้พวกเขา คุณสามารถตรวจสอบได้ว่าผู้ใช้เลือกที่จะเข้าร่วมหรือไม่เข้าร่วมในอนุญาตเฉพาะ หากมีอนุญาตที่อันตรายบางอย่างถูกปฏิเสธ ให้แน่ใจว่าแสดงป๊อปอัปที่ขอการเข้าถึงไปยัง OS อีกครั้ง อนุญาตอื่น ๆ จะถูกเลือกโดยอัตโนมัติหรือไม่เลือกตามการตั้งค่าในอุปกรณ์ของผู้ใช้ หากคุณพิมพ์อนุญาตหรือคำที่ผิด ระบบจะถือว่าอนุญาตไม่ได้ประกาศในไฟล์ AndroidManifest.xml และไม่อนุญาตให้เข้าถึงอนุญาต
Android 6.0 (API level 23) รองรับฟีเจอร์นี้ หากระบบปฏิบัติการเป็น iOS หรือระดับ API ของ Android ต่ำกว่า 23 จะส่ง ResultAPI ว่าไม่รองรับ
Note
ฟีเจอร์นี้ใช้ได้เฉพาะบน Android เท่านั้น.
ตัวอย่างโค้ด¶
เอกสารอ้างอิง API: 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 เท่านั้น    
         }    
         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) {
                                // รายการสิทธิ์ที่ได้รับการอนุมัติในหมู่คำขอ
                        }
                        if (DeniedRequests.Num() > 0) {
                                // รายการสิทธิ์ที่ถูกปฏิเสธในหมู่คำขอ
                        }
                }
                        break;
                case FHiveResultAPI::ECode::PlatformHelperOSVersionNotSupported:
                        // เวอร์ชัน Android OS ไม่ได้รับการสนับสนุน
                        break;
                default:
                        // ข้อยกเว้นอื่น ๆ
                        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    
         }    
         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()) {    
                     // รายการของสิทธิ์ที่ได้รับการอนุมัติจากคำขอ    
                 }    
                 if (!denied.isEmpty()) {    
                     // รายการของสิทธิ์ที่ถูกปฏิเสธจากคำขอ    
                 }    
                 break;    
             case PlatformHelperOSVersionNotSupported:    
                 // เวอร์ชัน Android OS ไม่รองรับ    
                 break;    
             default:    
                 // สถานการณ์ข้อยกเว้นอื่น ๆ    
                 break;    
         }    
});
ใช้บริการจัดการอุปกรณ์¶
บริการจัดการอุปกรณ์ จะถูกดำเนินการโดยอัตโนมัติเมื่อเข้าสู่ระบบตามการตั้งค่าใน Hive Console หลังจากเข้าสู่ระบบ เกมจะเรียกใช้เมธอด showDeviceManagement() ของคลาส AuthV4 และแสดงรายการการจัดการอุปกรณ์ให้กับผู้ใช้ 
 เมื่อการเข้าสู่ระบบถูกยกเลิกเนื่องจากการตรวจสอบอุปกรณ์ล้มเหลว เกมที่มีบริการจัดการอุปกรณ์ควรจัดการกับรหัส AuthV4NotRegisteredDevice ของ Result API เพื่อพยายามเข้าสู่ระบบแบบเงียบอีกครั้งหรือลงชื่อออก สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ บริการจัดการอุปกรณ์ โปรดดูที่คู่มือการใช้งาน: บทนำเกี่ยวกับบริการจัดการอุปกรณ์.
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¶
ในการทำให้เกมของคุณมีชื่อเสียงบน Google Play Games คุณจำเป็นต้องใช้งานฟังก์ชันความสำเร็จและกระดานผู้นำของ Google Play Games
หากผู้ใช้เข้าสู่ระบบเกมของคุณด้วยบัญชี Google ในกลุ่ม IdPs จะทำการเข้าสู่ระบบบริการ Play Games (PGS) โดยอัตโนมัติ ดังนั้นความสำเร็จและกระดานผู้นำจึงสามารถใช้งานได้ ในกรณีที่ผู้ใช้ลงชื่อออกจากหน้าจอการตั้งค่าของ PGS บัญชีผู้เล่นจะถูกลงชื่อออกเช่นเดียวกับกระบวนการเมื่อปุ่มลงชื่อออกในเกมถูกแตะ สำหรับข้อมูลเพิ่มเติมเกี่ยวกับฟังก์ชันของ PGS โปรดดูที่ คู่มือบริการ Google Play Games.
Note
ในกรณีที่มีการใช้งานคลาส AuthV4Helper
-  หากผู้ใช้ยกเลิกการเข้าสู่ระบบโดยอัตโนมัติไปยัง PGS ขณะโหลดเกม ระบบจะจดจำสถานะและจะไม่พยายามเข้าสู่ระบบโดยอัตโนมัติอีกครั้ง แม้ว่าการเข้าสู่ระบบอัตโนมัติจะมีให้ในขณะที่เซสชันของผู้เล่นยังใช้ได้ ระบบจะจดจำสถานะที่ถูกปฏิเสธ 
-  หากผู้ใช้ไม่ได้เข้าสู่ระบบ PGS ผลลัพธ์ของความสำเร็จจะไม่ถูกส่งไปยัง PGS. 
เนื้อหานี้เป็นไปตามแนวทางของ Google Play Games Services.
ส่ง playerID¶
หากคุณต้องการขอ PlayerID จาก Google Play Games ให้ทำการ implement เมธอด getGooglePlayerId() ในคลาส ProviderGoogle โดยการ implement เมธอดนี้จะส่ง PlayerID พร้อมกับ AuthCode ซึ่งใช้ในการตรวจสอบคีย์เซสชัน
ต่อไปนี้คือตัวอย่างโค้ด
เอกสารอ้างอิง API: hive.ProviderGoogle.getGooglePlayerId
เอกสารอ้างอิง API: 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: com.hive.ProviderGoogle.getGooglePlayerId
ความสำเร็จ¶
Implement ProviderGoogle class to use Achievement function of Google Play Games through Hive SDK.
คำขอเพื่อเปิดเผยความสำเร็จที่ซ่อนอยู่¶
เพื่อเปิดเผยความสำเร็จที่ซ่อนอยู่ให้กับผู้เล่นที่ลงชื่อเข้าใช้ในขณะนี้ ให้เรียกใช้วิธี achievementsReveal() ซึ่งจะไม่มีผลใด ๆ แต่จะเปิดเผย 0% ของความสำเร็จ ต่อไปนี้คือรหัสตัวอย่าง
API Reference: hive.ProviderGoogle.achievementsReveal
#include "HiveProviderGoogle.h"
// รหัสความสำเร็จ 
FString AchievementId = TEXT("abcdef123456");
FHiveProviderGoogle::AchievementsReveal(AchievementId, FHiveProviderGoogleOnAchievementsDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
        if (Result.IsSuccess()) {
                // การเรียก API สำเร็จ 
        }
}));
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
ขอปลดล็อกความสำเร็จ¶
ในการปลดล็อกความสำเร็จให้กับผู้เล่นที่ลงชื่อเข้าใช้ในปัจจุบัน ให้เรียกใช้วิธีการ achievementsUnlock() วิธีการนี้จะทำเครื่องหมาย 100% ของความสำเร็จไม่ว่าจะอยู่ในสถานะใดก็ตาม; ซ่อนอยู่หรือไม่ ต่อไปนี้คือตัวอย่างโค้ด
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
การขอเพิ่มความสำเร็จ¶
ในการใช้ฟังก์ชันการร้องขอเพื่อเพิ่มความสำเร็จ ให้ตั้งค่าความสำเร็จเป็นพารามิเตอร์ จากนั้นเรียกใช้วิธี achievementsIncrement() ค่า achievement คือผลรวมของค่าที่ตั้งไว้เมื่อเรียก API ที่เกี่ยวข้อง และความสำเร็จจะถูกบรรลุโดยอัตโนมัติเมื่อผลรวมสูงสุด
ต่อไปนี้คือตัวอย่างโค้ด
เอกสารอ้างอิง API: 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
ขอให้แสดงรายการความสำเร็จ (ช่วยเหลือ)¶
Note
SDK 4.7.0 มี Helper ซึ่งช่วยเปรียบเทียบบัญชีที่ลงชื่อเข้าใช้ในอุปกรณ์ของผู้ใช้และบัญชีที่ซิงค์กับ PlayerID ได้อย่างง่ายดาย หากบัญชีทั้งสองไม่เหมือนกัน ให้ดูที่หน้า IdP Sync เพื่อจัดการกับสถานการณ์นี้.
เรียกใช้เมธอด showAchievements() เพื่อขอรายการความสำเร็จจาก Google Play Games.
ต่อไปนี้คือตัวอย่างโค้ด
เอกสารอ้างอิง API: AuthV4.Helper.showAchievements
using hive;    
    AuthV4.Helper.showAchievements ((ResultAPI result, AuthV4.PlayerInfo playerInfo) => {    
      switch (result.code) {    
        case ResultAPI.Code.Success:    
          // ส่งความสำเร็จพร้อมการระบุความสำเร็จ    
          break;    
        case ResultAPI.Code.AuthV4ConflictPlayer:    
          // ข้อขัดแย้งของบัญชี    
          break;    
        case ResultAPI.Code.AuthV4GoogleLogout:    
          //TODO:    
          // หลังจากออกจาก Google Play ให้ออกจากเกม    
          // การเปิดเกมใหม่ต้องได้รับการจัดการโดยสตูดิโอพัฒนา    
          break;    
        default:    
          // สถานการณ์ข้อยกเว้นอื่น ๆ    
          break;    
      }    
});
#include "HiveAuthV4.h"
FHiveAuthV4::Helper::ShowAchievements(FHiveAuthV4HelperDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TOptional<FHivePlayerInfo>& PlayerInfo) {
        switch (Result.Code) {
                case FHiveResultAPI::ECode::Success:
                        // ส่งมอบความสำเร็จพร้อมกับการระบุความสำเร็จ
                        break;
                case FHiveResultAPI::ECode::AuthV4ConflictPlayer:
                        // ข้อขัดแย้งบัญชี
                        break;
                case FHiveResultAPI::ECode::AuthV4GoogleLogout:
                        // TODO:
                        // หลังจากออกจาก Google Play ให้ออกจากเกม
                        // การเปิดเกมใหม่ต้องจัดการโดยสตูดิโอพัฒนา
                        break;
                default:
                        // สถานการณ์ข้อยกเว้นอื่น ๆ
                        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 -> {    
                     // ส่งมอบความสำเร็จพร้อมการระบุ    
                 }    
                 ResultAPI.Code.AuthV4ConflictPlayer -> {    
                     // ข้อขัดแย้งของบัญชี    
                 }    
                 ResultAPI.Code.AuthV4GoogleLogout -> {    
                     //TODO:    
                     // หลังจากออกจาก Google Play ให้ล็อกเอาต์จากเกม    
                     // การเปิดเกมใหม่ต้องได้รับการจัดการโดยสตูดิโอพัฒนา    
                 }    
                 else -> {    
                     // สถานการณ์ข้อยกเว้นอื่น ๆ    
                 }    
             }    
         }    
})
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:    
                 // ส่งมอบความสำเร็จพร้อมการระบุความสำเร็จ    
                 break;    
             case AuthV4ConflictPlayer:    
                 // ความขัดแย้งของบัญชี    
                 break;    
             case AuthV4GoogleLogout:    
                 //TODO:    
                 // หลังจากออกจาก Google Play ให้ลงชื่อออกจากเกม    
                 // การเปิดเกมใหม่ต้องได้รับการจัดการโดยสตูดิโอพัฒนา    
                 break;    
             default:    
                 // สถานการณ์ข้อยกเว้นอื่น ๆ    
                 break;    
         }    
});
Warning
หากผู้ใช้ลงชื่อออกจากหน้าจอการตั้งค่าของ Play Games Services บัญชีผู้เล่นจะถูกลงชื่อออกและรหัสข้อผิดพลาดที่ชื่อว่า ResultAPI.Code.AuthV4GoogleLogout จะถูกส่งเป็น callback เมื่อการลงชื่อออกเสร็จสิ้น จะมีป๊อปอัพการลงชื่อออกปรากฏขึ้นและการแสดงผลจะเปลี่ยนเป็นชื่อเกม。
คำขอเพื่อแสดงรายการความสำเร็จ (Auth v4)¶
เรียกใช้วิธีการ showAchievements() เพื่อขอรายการความสำเร็จจาก Google Play Games.
ต่อไปนี้คือตัวอย่างโค้ด
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
หากผู้ใช้ลงชื่อออกจากหน้าการตั้งค่าของ Play Games Services จะมีรหัสข้อผิดพลาดชื่อ ResultAPI.Code.AuthV4GoogleLogout ถูกส่งเป็นการเรียกกลับ เมื่อส่งข้อผิดพลาดนี้แล้ว ให้แน่ใจว่าได้เขียนโค้ดเหมือนกับกระบวนการเมื่อปุ่มลงชื่อออกในเกมถูกแตะ
กระดานผู้นำ¶
Implement ProviderGoogle class to use Leaderboard function of Google Play Games through Hive SDK.
การอัปเดตคะแนนกระดานผู้นำ¶
เรียกใช้เมธอด leaderboardsSubmitScore() เพื่อขอการอัปเดตคะแนนลีดเดอร์บอร์ดของ Google Play Games.
ต่อไปนี้คือตัวอย่างโค้ด
API Reference: hive.ProviderGoogle.leaderboardsSubmitScore
#include "HiveProviderGoogle.h"
// รหัสกระดานผู้นำ
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";    
    // คะแนนอันดับ    
    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;    
    // รหัสลีดเดอร์บอร์ด    
    String leaderboardId = "12345abcde";    
    // หมายเลขคะแนนในกระดานผู้นำ    
    long score = 100;    
    ProviderGoogle.INSTANCE.leaderboardsSubmitScore(leaderboardId, score, resultAPI -> {    
         if (resultAPI.isSuccess()) {    
             // API call successful    
         }    
});
Request to show leaderboard list (Helper)¶
เรียกใช้วิธี showLeaderboards() เพื่อขอรายชื่อกระดานผู้นำของ Google Play Games. 
 ต่อไปนี้คือตัวอย่างโค้ด.
API Reference: hive.AuthV4.Helper.showLeaderboard
using hive;    
    AuthV4.Helper.showLeaderboard ((ResultAPI result, AuthV4.PlayerInfo playerInfo) => {    
       switch (result.code) {    
         case ResultAPI.Code.Success:    
           // ส่งมอบความสำเร็จพร้อมการแสดงอันดับ    
           break;    
         case ResultAPI.Code.AuthV4ConflictPlayer:    
           // ความขัดแย้งของบัญชี    
           break;    
         case ResultAPI.CodeAuthV4GoogleLogout:    
    //TODO:    
           // หลังจากออกจากระบบ Google Play ให้ออกจากเกม    
           // การเปิดเกมใหม่ต้องได้รับการจัดการโดยสตูดิโอพัฒนา    
           break;    
         default:    
           // สถานการณ์ข้อยกเว้นอื่น ๆ    
           break;    
       }    
});
#include "HiveAuthV4.h"
FHiveAuthV4::Helper::ShowLeaderboard(FHiveAuthV4HelperDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TOptional<FHivePlayerInfo>& PlayerInfo) {
                case FHiveResultAPI::ECode::Success:
                        // ส่งมอบความสำเร็จพร้อมการแสดงกระดานคะแนน
                        break;
                case FHiveResultAPI::ECode::AuthV4ConflictPlayer:
                        // ข้อขัดแย้งบัญชี
                        break;
                case FHiveResultAPI::ECode::AuthV4GoogleLogout:
                        // TODO:
                        // หลังจากออกจากระบบ Google Play ให้ออกจากเกม
          // การเปิดเกมใหม่ต้องได้รับการจัดการโดยสตูดิโอพัฒนา
                        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 -> {    
                     // ส่งมอบความสำเร็จพร้อมการแสดงอันดับ    
                 }    
                 ResultAPI.Code.AuthV4ConflictPlayer -> {    
                     // ข้อขัดแย้งของบัญชี    
                 }    
                 ResultAPI.Code.AuthV4GoogleLogout -> {    
                     //TODO:    
                     // หลังจากออกจาก Google Play ให้ทำการออกจากเกม    
                     // การเปิดเกมใหม่ต้องได้รับการจัดการโดยสตูดิโอพัฒนา    
                 }    
                 else -> {    
    // สถานการณ์ข้อยกเว้นอื่น ๆ    
    }    
             }    
         }    
})
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:
            // ส่งมอบความสำเร็จพร้อมการแสดงกระดานคะแนน
            break;
        case AuthV4ConflictPlayer:
            // ความขัดแย้งของบัญชี
            break;
        case AuthV4GoogleLogout:
            //TODO:
            // หลังจากออกจาก Google Play ให้ออกจากเกม
            // การเปิดเกมใหม่ต้องได้รับการจัดการโดยสตูดิโอพัฒนา
            break;
        default:
            // สถานการณ์ข้อยกเว้นอื่น ๆ
            break;
    }
});
Warning
หากผู้ใช้ลงชื่อออกจากหน้าจอการตั้งค่าของ Play Games Services บัญชีผู้เล่นจะถูกลงชื่อออกและรหัสข้อผิดพลาดที่ชื่อว่า ResultAPI.Code.AuthV4GoogleLogout จะถูกส่งเป็นการตอบกลับ เมื่อการลงชื่อออกเสร็จสิ้น ป๊อปอัพการออกจากระบบจะแสดงขึ้นและการแสดงผลจะเปลี่ยนเป็นชื่อเกม
คำขอเพื่อแสดงรายการกระดานผู้นำ (Auth v4)¶
เรียกใช้เมธอด showLeaderboards() เพื่อขอรายการกระดานผู้นำของ Google Play Games.
ต่อไปนี้คือตัวอย่างโค้ด
เอกสารอ้างอิง API: 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
หากผู้ใช้ลงชื่อออกจากหน้าการตั้งค่าของ Play Games Services จะมีรหัสข้อผิดพลาดที่ชื่อว่า ResultAPI.Code.AuthV4GoogleLogout ถูกส่งเป็นการเรียกกลับ เมื่อส่งข้อผิดพลาดนี้แล้ว ให้แน่ใจว่ารหัสจะเหมือนกับกระบวนการเมื่อปุ่มลงชื่อออกในเกมถูกแตะ
เกมเซ็นเตอร์ของแอปเปิ้ล ความสำเร็จและกระดานคะแนน¶
เพื่อให้เกมของคุณได้รับการแสดงใน Apple Game Center คุณต้องใช้ฟังก์ชันความสำเร็จและกระดานผู้นำของ Apple Game Center
ไม่ว่าผู้ใช้จะมีสถานะการตรวจสอบสิทธิ์อย่างไร ฟังก์ชันทั้งสองของ Apple Game Center จะถูกจัดเตรียมโดย Hive SDK นั่นคือ ความสำเร็จและกระดานผู้นำจะใช้บัญชี Apple Game Center แต่ความสำเร็จและกระดานผู้นำจะใช้บัญชี Apple Game Center แต่บัญชีนี้อาจไม่เชื่อมโยงกับบัญชี Hive หรือแตกต่างจากบัญชี Hive ที่ผู้เล่นลงชื่อเข้าใช้ในขณะนี้
สำหรับข้อมูลเพิ่มเติมเกี่ยวกับฟังก์ชันของ Apple Game Center โปรดดูที่ คู่มือ Apple Game Center.
Note
iOS Enterprise ไม่รองรับ Apple Game Center.
ความสำเร็จ¶
สร้างคลาส ProviderApple เพื่อใช้ฟังก์ชัน Achievement ของ Apple Game Center ผ่าน Hive SDK.
รายการความสำเร็จ¶
ในการโหลดรายการความสำเร็จ ให้เรียกใช้เมธอด loadAchievements()
ต่อไปนี้คือตัวอย่างโค้ด
API Reference: hive.ProviderApple.loadAchievements
// ขอรายการความสำเร็จจาก Provider Apple
// ใช้ hive
// ตัวจัดการ Callback ที่จัดการคำขอสำหรับรายการความสำเร็จไปยัง Provider Apple
public void onLoadAchievements(ResultAPI result, List achievementList) {
Logger.log("ProviderTestView.onLoadAchievements() Callback\nresult = " + result.toString() + "\n");
if (result.isSuccess() != true) 
    return;
}
// ขอรายการความสำเร็จจากผู้ให้บริการ Apple
ProviderApple.loadAchievements(onLoadAchievements);
เอกสารอ้างอิง API: ProviderApple::loadAchievements
// ขอรายการความสำเร็จจาก Provider Apple
ProviderApple::loadAchievements([=](ResultAPI const & result,std::vector<ProviderAppleAchievement>; const & achievements) {
    // ผลลัพธ์การเรียกกลับ
    cout<<"ProviderApple::loadAchievements() Callback"<<endl<<result.toString()<<endl;
    if (result.isSuccess() != true)
        return;
});
เอกสารอ้างอิง API: HIVEProviderApple::showAchievements:
เอกสารอ้างอิง API: HIVEProviderApple::showAchievements:
// ขอรายการความสำเร็จจากผู้ให้บริการ Apple
[HIVEProviderApple loadAchievements:^(HIVEResultAPI *result, NSArray<HIVEProviderAppleAchievement *>; *achievements) {
    Loggerd(@"HIVEProviderApple.loadAchievements:\nresult = %@\nachievements = %@", result, achievements);
    if (result.isSuccess) {
    }
    else {
    }
    }];
ขอรายงานความสำเร็จ¶
ในการรายงานความสำเร็จ ให้เรียกใช้วิธี reportAchievement() โดยตั้งค่าพารามิเตอร์เป็น อัตราความสำเร็จ และ การแสดงแบนเนอร์การแจ้งเตือนสำหรับความสำเร็จที่สำเร็จ.
ต่อไปนี้คือตัวอย่างโค้ด
เอกสารอ้างอิง API: hive .ProviderApple.reportAchievement
using hive;    
    //ความสำเร็จที่ได้รับ %. ความสำเร็จเสร็จสิ้นที่ 100    
    String achievementPercent = "100";    
    // แสดงแบนเนอร์ด้านบนเมื่อความสำเร็จสำเร็จหรือไม่ ค่าเริ่มต้นคือ false    
    Boolean isShow = true;    
    //รหัสความสำเร็จ    
    String achievementId = "com.hivesdk.achievement.10hit";    
    ProviderApple.reportAchievement(achievementPercent, isShow, achievementId, (ResultAPI result) => {    
         if (result.isSuccess()) {    
             // call successful    
         }    
});
#include "HiveProviderApple.h"
//ความสำเร็จที่บรรลุ %. ความสำเร็จเสร็จสิ้นที่ 100 
FString Percent = TEXT("100");
// ว่าจะแสดงแบนเนอร์ด้านบนเมื่อความสำเร็จสำเร็จหรือไม่ ค่าเริ่มต้นคือ false  
bool bIsShow = true;
// รหัสความสำเร็จ
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;    
    //ความสำเร็จที่ได้รับ %. ความสำเร็จเสร็จสิ้นที่ 100    
    string achievementPercent = "100";    
    // ไม่ว่าจะต้องแสดงแบนเนอร์ด้านบนเมื่อความสำเร็จสำเร็จหรือไม่ ค่าเริ่มต้นคือ false    
    bool isShow = true;    
    //รหัสความสำเร็จ    
    string achievementId = "com.hivesdk.achievement.10hit";    
    ProviderApple::reportAchievement(achievementPercent, isShow, achievementId, [=](ResultAPI const & result) {    
         if (result.isSuccess()) {    
             // call successful    
         }    
});
เอกสาร API: ProviderApple.reportAchievement
import HIVEService    
    //ความสำเร็จที่ได้รับ %. ความสำเร็จเสร็จสมบูรณ์ที่ 100    
    letachievementPercent = "100"    
    // ไม่ว่าจะต้องแสดงแบนเนอร์ด้านบนเมื่อความสำเร็จสำเร็จหรือไม่ ค่าเริ่มต้นคือ false    
    let isShow = true    
    //รหัสความสำเร็จ    
    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>    
    //ความสำเร็จที่ได้รับ %. ความสำเร็จจะสมบูรณ์เมื่อ 100    
    NSString *achievementPercent = @"100";    
    // ว่าจะแสดงแบนเนอร์ด้านบนเมื่อความสำเร็จสำเร็จหรือไม่ ค่าเริ่มต้นคือ NO    
    BOOL isShow = YES;    
    //รหัสความสำเร็จ    
    NSString *achievementId = @"com.hivesdk.achievement.10hit";    
    [HIVEProviderApple reportAchievement: achievementPercent showsCompletionBanner: isShow achievementIdentifier: achievementId handler: ^(HIVEResultAPI *result) {    
         if ([result isSuccess]) {    
             // call successful    
         }    
}];
ขอให้แสดง UI ความสำเร็จ (ผู้ช่วย)¶
Note
SDK 4.7.0 มี Helper ซึ่งช่วยเปรียบเทียบบัญชีที่ลงชื่อเข้าใช้บนอุปกรณ์ของผู้ใช้และบัญชีที่ซิงค์ด้วย PlayerID ได้อย่างง่ายดาย หากบัญชีทั้งสองไม่เหมือนกัน โปรดดูที่หน้า IdP Sync เพื่อจัดการกับสถานการณ์นี้。
เพื่อแสดง UI ความสำเร็จ ให้เรียกใช้เมธอด showAchievements()
ต่อไปนี้คือตัวอย่างโค้ด
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:
                        // ส่งมอบความสำเร็จพร้อมการระบุความสำเร็จ 
                        break;
                case FHiveResultAPI::ECode::AuthV4ConflictPlayer:
                        // ความขัดแย้งของบัญชี 
                        break;
                default:
                        // สถานการณ์ข้อยกเว้นอื่น ๆ
                        break;
        }
}));
เอกสารอ้างอิง API: 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
// หากบัญชี Hive ที่เข้าสู่ระบบอยู่ในขณะนี้ไม่ได้เชื่อมต่อกับ GameCenter    
    // จะพยายามเชื่อมต่อกับ GameCenter โดยอัตโนมัติ    
    import HIVEService    
    AuthV4Interface.helper().showAchievements() { result, playerInfo in    
         switch result.getCode() {    
             case .success:    
                 // ส่งความสำเร็จพร้อมกับการระบุความสำเร็จ    
             case .authV4ConflitPlayer:    
                 // ข้อขัดแย้งของบัญชี    
             default:    
                 break    
         }    
}
API Reference: [ HIVEAuthV4 helper] showAchievements
// หากบัญชี Hive ที่เข้าสู่ระบบอยู่ในขณะนี้ไม่ได้เชื่อมต่อกับ GameCenter    
    // จะพยายามเชื่อมต่อกับ 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;    
         }    
}];
คำขอเพื่อแสดง UI ความสำเร็จ¶
เพื่อแสดง UI ความสำเร็จ ให้เรียกใช้วิธีการ showAchievements()
ต่อไปนี้คือตัวอย่างโค้ด
API Reference: ProviderApple.showAchievements
API Reference: ProviderApple::showAchievements
เอกสารอ้างอิง API: ProviderApple.showAchievements
API Reference: HIVEProviderApple showAchievements
ขอรีเซ็ตความสำเร็จ¶
ในการรีเซ็ตความสำเร็จ ให้ใช้วิธีการ resetAchievements()
ต่อไปนี้คือตัวอย่างโค้ด
API Reference: hive.ProviderApple.resetAchievements
เอกสารอ้างอิง API: ProviderApple ::resetAchievements
เอกสาร API: resetAchievements(_:)
API Reference: HIVEProviderApple showAchievements
กระดานผู้นำ¶
สร้างคลาส ProviderApple เพื่อใช้ฟังก์ชัน Leaderboard ของ Apple Game Center ผ่าน Hive SDK.
ขอให้รายงานคะแนนในตารางคะแนน¶
เพื่อรายงานคะแนนในกระดานผู้นำไปยัง Apple Game Center ให้เรียกใช้วิธี reportScore() 
 ต่อไปนี้คือตัวอย่างโค้ด
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: HIVEProviderApple::reportScore:leaderboardIdentifier:handler:
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    
         }    
}];
คำขอเพื่อแสดง UI ของกระดานผู้นำ (ผู้ช่วย)¶
เพื่อแสดง UI ของกระดานคะแนน ให้เรียกใช้วิธีการ showLeaderboard()
ต่อไปนี้คือตัวอย่างโค้ด
API Reference: hive .AuthV4.Helper.showLeaderboard
// หากบัญชี Hive ที่เข้าสู่ระบบในขณะนี้ไม่ได้เชื่อมต่อกับ GameCenter    
    // จะพยายามเชื่อมต่อกับ GameCenter โดยอัตโนมัติ    
    ใช้ hive;    
    AuthV4.Helper.showLeaderboard((ResultAPI result, AuthV4.PlayerInfo playerInfo) => {    
         switch (result.code) {    
             case ResultAPI.Code.Success:    
                 // ส่งความสำเร็จพร้อมการแสดงกระดานคะแนน    
                 break;    
             case ResultAPI.Code.AuthV4ConflictPlayer:    
                 // ข้อขัดแย้งของบัญชี    
                 break;    
             default:    
                 // สถานการณ์ข้อยกเว้นอื่น ๆ    
                 break;    
         }    
});
API Reference: AuthV4 ::Helper::showLeaderboard
// หากบัญชี Hive ที่เข้าสู่ระบบอยู่ในขณะนี้ไม่ได้เชื่อมต่อกับ GameCenter
// จะพยายามเชื่อมต่อกับ 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: showLeaderboard
// หากบัญชี Hive ที่เข้าสู่ระบบอยู่ในขณะนี้ไม่ได้เชื่อมต่อกับ GameCenter    
    // จะพยายามเชื่อมต่อกับ GameCenter โดยอัตโนมัติ    
    import HIVEService    
    AuthV4Interface.helper().showLeaderboard() { result, playerInfo in    
         switch result.getCode() {    
             case .success:    
                 // ส่งความสำเร็จพร้อมการแสดงกระดานผู้นำ    
             case .authV4ConflictPlayer:    
                 // ข้อขัดแย้งของบัญชี    
             default:    
                 break    
         }    
}
API Reference: HIVEProviderApple ::showLeaderboard:
// หากบัญชี Hive ที่เข้าสู่ระบบอยู่ในขณะนี้ไม่ได้เชื่อมต่อกับ GameCenter    
    // จะพยายามเชื่อมต่อกับ 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;    
         }    
}];
คำขอเพื่อแสดง UI ของกระดานผู้นำ¶
ในการแสดง UI ของกระดานคะแนน ให้เรียกใช้วิธี showLeaderboard()
ต่อไปนี้คือตัวอย่างโค้ด
API Reference: hive .ProviderApple.showLeaderboard
API Reference: ProviderApple ::showLeaderboard
API Reference: showLeaderboard(_:)
API Reference: HIVEProviderApple ::showLeaderboard:
โพสต์รูปภาพบนโซเชียลมีเดีย¶
ผู้ใช้สามารถแชร์และโพสต์รูปภาพบน Facebook โดยการนำเข้ารูปภาพจากแกลเลอรีของอุปกรณ์ของตนผ่านเกม ตัวอย่างรหัสมีดังนี้:
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
การเข้าสู่ระบบอัตโนมัติสำหรับเกม PC ด้วยการเข้าสู่ระบบของชุมชน¶
เมื่อคุณคลิกปุ่มเล่นบน PC บนเว็บไซต์ชุมชน เกม PC จะถูกเปิดผ่าน Crossplay Launcher.
ในขณะนี้ เกม PC จะเข้าสู่ระบบโดยอัตโนมัติด้วย ‘ค่าโทเค็นการเข้าสู่ระบบ’ ของชุมชน
Warning
ฟีเจอร์การเข้าสู่ระบบอัตโนมัติสำหรับเกม PC ด้วยการเข้าสู่ระบบของชุมชน ใช้งานได้เฉพาะใน Windows เวอร์ชันของ Hive SDK v4 24.0.0 ขึ้นไป.
Steam implicit login (Unity Windows)¶
เริ่มต้นจาก Hive SDK v4 Unity Windows 24.2.0, การเข้าสู่ระบบแบบปริยายของ Steam ได้รับการสนับสนุน. หากคุณเลือกที่จะใช้การเข้าสู่ระบบแบบปริยาย คุณต้องใช้ AuthV4.Helper.signIn และไม่สามารถใช้ AuthV4.signIn(AUTO,...). เนื่องจากเป็นการเข้าสู่ระบบแบบปริยาย ผู้ใช้แอปจะเข้าสู่ระบบ Steam เพียงครั้งเดียวหลังจากติดตั้งเกม เมื่อใช้การเข้าสู่ระบบแบบปริยายของ Steam คุณต้องดำเนินการลบโฟลเดอร์ propFolder ซึ่งเก็บข้อมูลการกำหนดค่าของ SDK เมื่อแอปถูกลบออก