Get in-app web contents
This feature allows web content to be called within the app. In other words, users can access external browsers or web views without leaving the app. The ability to call web content within the app not only reduces user churn but also provides a better user experience.
Note
For more information on external browsers, please refer to the Android Custom tabs and iOS SFSafariViewController documentation.
Calling External Browsers Within the App¶
This section provides guidance on how to use the external browser calling feature within the app.
Settings function¶
The functions that can be set with InAppBrowserParam
are as follows.
Features | Content | Default setting |
---|---|---|
NavigationColor | Specifies the top navigation area color. | OS default color |
ButtonColor (iOS only supported) | Specifies the top navigation area button color. | OS default color |
UrlBarHiding | When a scroll event occurs, the top URL exposure area is hidden. | true |
AutoRedirectToExternalBrowser (Android only) | If the browser app set in the terminal's default app is not supported, an external browser connection is automatically supported. | true |
Example code¶
The example code for setting the function using InAppBrowserParam
is as follows.
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 call successful
}
});
#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 call successful
}
}));
#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 call successful
}
});
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 call successful
}
});
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 call successful
}
}
})
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 call successful
}
};
#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 call successful
}
}];
Calling Webview Within the App¶
This section explains how to call a webview within the app. You can send the in-app login session using useUserSession
, and additional information desired by the app developer can be sent using postData
.
Configurable Features¶
The features that can be set with InAppWebViewParam
are as follows:
Feature | Description | Default Value | Required |
---|---|---|---|
useUserSession | In-app login session information. JSON data including player_id and player_token . | false | X |
postData | Data containing additional information to be sent by the app developer. Used when there is additional information to be displayed in the webview. | null | X |
Warning
When using useUserSession
, postData
must be in JSON format.
Example Code¶
Here is an example code for setting features using 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 call successful
}
}));
#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 call successful
}
});
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 call successful
}
});
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 call successful
}
}
})
#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 call successful
}
}];