앱 내 웹 콘텐츠 호출
웹 콘텐츠를 앱 내에서 호출 할 수 있는 기능을 제공합니다. 즉, 사용자가 앱에서 이탈할 필요 없이 외부 브라우저나 웹뷰를 이용할 수 있습니다. 앱 내 웹 콘텐츠 호출 기능은 사용자 이탈률 감소 뿐만 아니라, 보다 나은 사용자 경험을 제공합니다.
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 "HivePlatformHelper.h"
FString URL = TEXT("https://developers.withhive.com/");
FHiveInAppBrowserParam Param(URL);
Param.NavigationColor = TEXT("3891f0");
Param.ButtonColor = TEXT("#FFFFFF");
Param.UrlBarHiding = true;
Param.AutoRedirectToExternalBrowser = true;
FHivePlatformHelper::ShowInAppBrowser(Param, FHivePlatformHelperOnShowInAppBrowserDelegate::CreateLambda([this](const FHiveResultAPI& 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 호출 성공
        }
}];
앱 내 웹뷰 호출¶
앱 내 웹뷰를 호출합니다. useUserSession로 인앱 로그인 세션을 웹뷰에 전송할 수 있으며, postData로 앱 개발사에서 원하는 부가 정보를 전송할 수 있습니다.
설정 기능¶
InAppWebViewParam로 설정 가능한 기능은 아래와 같습니다.
| 기능 | 내용 | 기본 설정값 | 필수 여부 | 
|---|---|---|---|
| useUserSession | 인앱 로그인 세션 정보입니다. player_id와player_token을 포함한 JSON 데이터입니다. | false | X | 
| postData | 앱 개발사에서 전송할 부가 정보를 담은 데이터입니다. 웹뷰에서 보여주기 원하는 부가적인 정보가 있을 때 사용합니다. | null | X | 
Warning
useUserSession 사용 시 postData는 반드시 JSON 포맷이어야 합니다.
예제 코드¶
InAppWebViewParam을 이용한 기능 설정 예제 코드는 아래와 같습니다.
#include "HivePlatformHelper.h"
FString URL = TEXT("https://developers.withhive.com/");
FHiveInAppWebViewParam Param(URL);
Param.UseUserSession = true;
FHivePlatformHelper::ShowInAppWebView(Param, FHivePlatformHelperOnShowInAppWebViewDelegate::CreateLambda([this](const FHiveResultAPI& Result) {
        if (Result.IsSuccess()) {
                // API 호출 성공
        }
}));
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
InAppWebViewParam *param = new InAppWebViewParam("https://developers.withhive.com/");
param->useUserSession = true;
PlatformHelper::showInAppWebView(*param, [=](ResultAPI const & result) {
        if (result.isSuccess()) {
                // API 호출 성공
        }
});
import com.hive.PlatformHelper;
import com.hive.ResultAPI;
PlatformHelper.InAppWebViewParam param = new PlatformHelper.InAppWebViewParam.Builder("https://developers.withhive.com/")
                                .setUseUserSession(true)
                                .build();
PlatformHelper.showInAppWebView(param, result -> {
        if (result.isSuccess()) {
                // API 호출 성공
        }     
});
import com.hive.PlatformHelper;
import com.hive.ResultAPI;
val param = PlatformHelper.InAppWebViewParam.Builder("https://developers.withhive.com/")
                                        .setUseUserSession(true)
                                        .build()
PlatformHelper.showInAppWebView(param, object : PlatformHelper.InAppWebViewListener {
        override fun onInAppWebView(result: ResultAPI) {
                if (result.isSuccess) {
                        // API 호출 성공
                }
        }
})
#import <HIVEService/HIVEService-Swift.h>
HiveInAppWebViewParamBuilder *builder = [[HiveInAppWebViewParamBuilder alloc] initWithUrl: @"https://developers.withhive.com/"];
HiveInAppWebViewParam *inAppWebViewParam = [[builder setUseUserSession: @YES]
                                                        build];
[HIVEPlatformHelper showInAppWebView: inAppWebViewParam handler: ^(HIVEResultAPI *result) {
        if ([result isSuccess]) {
                // API 호출 성공
        }
}];