การเรียกดูภายนอกในเกม
เริ่มต้นด้วย Hive SDK v4 24.0.0, ความสามารถในการเรียกใช้เบราว์เซอร์ภายนอกภายในเกมได้รับการจัดเตรียมไว้แล้ว นี่หมายความว่าผู้ใช้สามารถใช้เบราว์เซอร์ภายนอกขณะเล่นเกมโดยไม่ต้องออกจากเกม
ฟังก์ชันการเรียกดูเบราว์เซอร์ภายนอกในเกมไม่เพียงแต่ลดอัตราการออกจากระบบของผู้ใช้ แต่ยังมอบประสบการณ์การใช้งานที่ดียิ่งขึ้น
Note
สำหรับข้อมูลเพิ่มเติม โปรดดูเอกสาร Android Custom tabs และ iOS SFSafariViewController
การใช้¶
คำแนะนำเกี่ยวกับวิธีการใช้ฟีเจอร์การเรียกเบราว์เซอร์ภายนอกในเกม
ฟังก์ชันการตั้งค่า¶
ฟังก์ชันที่สามารถตั้งค่าด้วย InAppBrowserParam มีดังต่อไปนี้
| ฟีเจอร์ | เนื้อหา | การตั้งค่าเริ่มต้น | 
|---|---|---|
| NavigationColor | กำหนดสีของพื้นที่การนำทางด้านบน | สีเริ่มต้นของ OS | 
| ButtonColor (รองรับเฉพาะ iOS) | กำหนดสีของปุ่มในพื้นที่การนำทางด้านบน | สีเริ่มต้นของ OS | 
| UrlBarHiding | เมื่อเกิดเหตุการณ์เลื่อน พื้นที่การแสดง URL ด้านบนจะถูกซ่อน | true | 
| AutoRedirectToExternalBrowser (เฉพาะ Android) | หากแอปเบราว์เซอร์ที่ตั้งค่าในแอปเริ่มต้นของอุปกรณ์ไม่รองรับ การเชื่อมต่อกับเบราว์เซอร์ภายนอกจะถูกสนับสนุนโดยอัตโนมัติ | true | 
ตัวอย่างโค้ด¶
โค้ดตัวอย่างสำหรับการตั้งค่าฟังก์ชันโดยใช้ InAppBrowserParam มีดังนี้
using hive;
InAppBrowserParam param = new InAppBrowserParam.Builder("https://developers.withhive.com/")
                                                                        .setNavigationColor("#3891f0")
                                                                        .setButtonColor("#ffffff")
                                                                        .setUrlBarHiding(true)
                                                                        .setAutoRedirectToExternalBrowser(true)
                                                                        .build();
    PlatformHelper.showInAppBrowser(param, (ResultAPI result) => {
            if (result.isSuccess()) {
                    // API 호출 성공
            }
    });
    #include <HIVE_SDK_Plugin/HIVE_CPP.h>
    using namespace std;
    using namespace hive;
    InAppBrowserParam *param = new InAppBrowserParam("https://developers.withhive.com/");
    param->navigationColor = "3891f0";
    param->buttonColor = "#ffffff";
    param->urlBarHiding = true;
    param->autoRedirectToExternalBrowser = true;
    PlatformHelper::showInAppBrowser(*param, [=](ResultAPI const & result) {
            if (result.isSuccess()) {
                    // API 호출 성공
            }
    });
    import com.hive.PlatformHelper;
    import com.hive.ResultAPI;
    PlatformHelper.InAppBrowserParam param = new PlatformHelper.InAppBrowserParam.Builder("https://developers.withhive.com/")
                                    .setNavigationColor("#3891f0")
                                    .setUrlBarHiding(true)
                                    .setAutoRedirectToExternalBrowser(true)
                                    .build();
    PlatformHelper.showInAppBrowser(param, result -> {
            if (result.isSuccess()) {
                    // API 호출 성공
            }
    });
import com.hive.PlatformHelper
import com.hive.ResultAPI
val param = PlatformHelper.InAppBrowserParam.Builder("https://developers.withhive.com/")
                                        .setNavigationColor("#3891f0")
                                        .setUrlBarHiding(true)
                                        .setAutoRedirectToExternalBrowser(true)
                                        .build()
PlatformHelper.showInAppBrowser(param, object : PlatformHelper.InAppBrowserListener {
        override fun onInAppBrowser(result: ResultAPI) {
                if (result.isSuccess) {
                        // API เรียกสำเร็จ
                }
        }
})
import HIVEService
let inAppBrowserParam = InAppBrowserParam.Builder(url: "https://developers.withhive.com/")
                                                .setNavigationColor("#3891f0")
                                                .setButtonColor("#ffffff")
                                                .setUrlBarHiding(true)
                                                .setAutoRedirectToExternalBrowserbuild(true)
                                                .build()
PlatformHelperInterface.showInAppBrowser(inAppBrowserParam) { resultAPI in
    if result.isSuccess() {
                // API เรียกสำเร็จ
        }
};
#import <HIVEService/HIVEService-Swift.h>
HiveInAppBrowserParamBuilder *builder = [[HiveInAppBrowserParamBuilder alloc] initWithUrl: @"https://developers.withhive.com/"];
HiveInAppBrowserParam *inAppBrowserParam = [[[[[builder setNavigationColor: @"#3891f0"]
                                                                                                                    setButtonColor: @"#ffffff"]
                                                                                                                    setUrlBarHiding: YES]
                                                                                                                    setAutoRedirectToExternalBrowser: YES]
                                                                                                                    build];
[HIVEPlatformHelper showInAppBrowser: inAppBrowserParam handler: ^(HIVEResultAPI *result) {
        if ([result isSuccess]) {
                // API 호출 성공
        }
}];