|
|
@@ -126,7 +126,6 @@ public static class AppRuntimes
|
|
|
|
|
|
public static void SetInteface(IDialog dialog, ILoading loading)
|
|
|
{
|
|
|
- // Dialogs always use the native system UI. Keep this signature for existing callers.
|
|
|
Loading = loading;
|
|
|
}
|
|
|
|
|
|
@@ -185,7 +184,7 @@ public static class AppRuntimes
|
|
|
|
|
|
public static async UniTask<bool> CheckVersion()
|
|
|
{
|
|
|
- if (await CheckEnabled())
|
|
|
+ if(await CheckEnabled())
|
|
|
{
|
|
|
InitFB();
|
|
|
var platform = await Platform();
|
|
|
@@ -210,7 +209,7 @@ public static class AppRuntimes
|
|
|
{
|
|
|
var ts = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
|
|
var url = string.Format("{0}?v={1}", PrivacyUrl, ts);
|
|
|
- Debug.Log(url);
|
|
|
+ Log(url);
|
|
|
using var handler = UnityWebRequest.Get(url);
|
|
|
var result = await handler.SendWebRequest();
|
|
|
PrivacyContent = result.downloadHandler.text;
|
|
|
@@ -266,7 +265,7 @@ public static class AppRuntimes
|
|
|
string requestBody = GetRequestBody(body);
|
|
|
var requestFailed = false;
|
|
|
var res = await Https.POST<PlatformResponse>(url, requestBody, _ => requestFailed = true);
|
|
|
- // Failed requests return a default response. Do not decrypt it first.
|
|
|
+
|
|
|
if (!requestFailed)
|
|
|
return ClientCrypto.DecryptJson(res.data);
|
|
|
|
|
|
@@ -294,7 +293,6 @@ public static class AppRuntimes
|
|
|
catch (ArgumentException e)
|
|
|
{
|
|
|
Debug.LogError(e);
|
|
|
- // Some devices can report an invariant or neutral culture.
|
|
|
}
|
|
|
|
|
|
//Debug.LogFormat("region:{0} sysLang:{1}", region, Application.systemLanguage);
|
|
|
@@ -311,7 +309,6 @@ public static class AppRuntimes
|
|
|
private static UniTask<bool> ShowNetworkError()
|
|
|
{
|
|
|
#if UNITY_IOS || UNITY_ANDROID || UNITY_EDITOR
|
|
|
- // Credentials and platform requests can fail together. Share one dialog.
|
|
|
if (NetworkErrorCompletion != null)
|
|
|
return NetworkErrorCompletion.Task;
|
|
|
|
|
|
@@ -349,9 +346,6 @@ public static class AppRuntimes
|
|
|
var backgroundColor = Color.black;
|
|
|
CreateWebViewBackground(webViewGameObject, backgroundColor);
|
|
|
|
|
|
- // Native content insets do not constrain fixed-position HTML elements
|
|
|
- // and can make their visual and touch positions differ. Keep them off
|
|
|
- // and constrain the native web view itself to the iOS safe area.
|
|
|
webView.SetContentInsetAdjustmentBehavior(UniWebViewContentInsetAdjustmentBehavior.Never);
|
|
|
webView.BackgroundColor = backgroundColor;
|
|
|
ApplyWebViewSafeAreaFrame(webView);
|
|
|
@@ -364,8 +358,6 @@ public static class AppRuntimes
|
|
|
webView.OnShouldClose += (view) => false;
|
|
|
webView.OnPageStarted += (view, loadingUrl) =>
|
|
|
{
|
|
|
- // UniWebView is a native view and is always rendered above Unity UI.
|
|
|
- // Hide it while loading so the Loading prefab can be seen.
|
|
|
view.Hide();
|
|
|
SetWebLoading(true);
|
|
|
};
|
|
|
@@ -392,12 +384,10 @@ public static class AppRuntimes
|
|
|
|
|
|
webView.OnChannelMessageReceived += (view, message) =>
|
|
|
{
|
|
|
- //Debug.Log($">>>> webView OnChannelMessage action:{message.action} data:{message.data}");
|
|
|
switch (message.action)
|
|
|
{
|
|
|
case "openWindow":
|
|
|
var url = SafeJson<UrlParams>(message.data).url;
|
|
|
- //Debug.Log($"openWindow url:{url}");
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
{
|
|
|
Application.OpenURL(url);
|
|
|
@@ -416,7 +406,6 @@ public static class AppRuntimes
|
|
|
|
|
|
private static void ApplyWebViewSafeAreaFrame(UniWebView webView)
|
|
|
{
|
|
|
- // UniWebView uses a top-left origin; Screen.safeArea uses bottom-left.
|
|
|
var safeArea = Screen.safeArea;
|
|
|
webView.Frame = new Rect(
|
|
|
safeArea.xMin,
|
|
|
@@ -491,9 +480,6 @@ public static class AppRuntimes
|
|
|
{
|
|
|
JToken token = JToken.Parse(json);
|
|
|
|
|
|
- // The web side may JSON.stringify the data before passing it to
|
|
|
- // UniWebView, producing a JSON string which itself contains JSON.
|
|
|
- // Unwrap such string layers before mapping to the target type.
|
|
|
for (var i = 0; i < 3 && token.Type == JTokenType.String; i++)
|
|
|
{
|
|
|
var innerJson = token.Value<string>();
|