Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some questions about the use of this plugin #402

Open
c8970412 opened this issue Mar 16, 2019 · 53 comments
Open

Some questions about the use of this plugin #402

c8970412 opened this issue Mar 16, 2019 · 53 comments

Comments

@c8970412
Copy link

  1. There is a gap between the reading time of WebView on Android and IOS.
    Will the hardware configuration affect the display time of WebView in the case of the same network?

  2. After testing, click on the phone in WebView on Android, the mailbox does not respond, but IOS only has a phone menu and it is English.
    I would like to ask about the section to open Android and IOS permissions, where should I write the IOS phone menu font?
    Can the phone menu font on IOS be changed?

  3. Does WebView have support for selecting the inside webpage, which can be uploaded and downloaded?
    At present, there is no response to the test point selection upload. If it is downloaded, it will be packaged in the WebView. Can I use the built-in software of the mobile phone to open it?
    Does webView support file uploading? Can the download method be changed to additional call built-in software?

  4. Can the website only read the beginning of http?
    Can Http and https be case-sensitive or multiple s can be read?

@KojiNakamaru
Copy link
Member

There is a gap between the reading time of WebView on Android and IOS.
Will the hardware configuration affect the display time of WebView in the case of the same network?

This plugin simply utilizes native UIWebView/WKWebView for iOS and/or WebView for Android, thus each performs differently depending on OS, hardware, etc.

After testing, click on the phone in WebView on Android, the mailbox does not respond, but IOS only has a phone menu and it is English.
I would like to ask about the section to open Android and IOS permissions, where should I write the IOS phone menu font?
Can the phone menu font on IOS be changed?

I tested phone links (tel:) and found it didn't work on iOS when enableWKWebView = true, so I've fixed the issue in #403 . I however haven't completely understood your issue, so could you please provide a concrete example html file to reproduce the isuse?

Does WebView have support for selecting the inside webpage, which can be uploaded and downloaded?
At present, there is no response to the test point selection upload. If it is downloaded, it will be packaged in the WebView. Can I use the built-in software of the mobile phone to open it?
Does webView support file uploading? Can the download method be changed to additional call built-in software?

There is no file downloading support. For file uploading, there is an experimental version #77, though I keep it experimental as some Android versions have unavoidable bugs about the input file tag.

If you can control html pages displayed with the plugin, it is better to utilize Unity.call() in html and EvaluateJS() in C# to communicate between webview and unity. You can then perform any required tasks such as file uploading/downloading in the unity side.

Can the website only read the beginning of http?
Can Http and https be case-sensitive or multiple s can be read?

The plugin works both for http:/https:. I've not tested but it may not work if for example HTTP: is used instead of http:.

@c8970412
Copy link
Author

c8970412 commented Mar 21, 2019

I would like to ask the IOS permissions, where should I set it?
On IOS, he doesn't access the camera.

@KojiNakamaru
Copy link
Member

@c8970412
Copy link
Author

Regarding the Info.plist file, I have no response after the modification. I would like to ask if the path has any effect?
The project path for Info.plist in the example is unity-webview\plugins\Mac\Resources. The path after I use the package import is Assets\Plugins\WebView.bundle\Contents

Also add the last language question
The menu above the IOS display is like this
未命名
I want to modify which side to make it into other languages such as Chinese, Japanese, etc. This situation is also added on Android.

The last thing I want to ask is that the experimental version of the #77 upload file provided last time is limited to the image file. Can it be modified to freely select the type of uploading is image, file, music?
Before giving the APP access to the mobile phone file permission, click Upload to upload the image.
But after giving permission, uploading can select images or files but the prompt text displayed is English.

@KojiNakamaru
Copy link
Member

Regarding the Info.plist file, I have no response after the modification. I would like to ask if the path has any effect?
The project path for Info.plist in the example is unity-webview\plugins\Mac\Resources. The path after I use the package import is Assets\Plugins\WebView.bundle\Contents

Files under plugins/ are those for building this plugin's binaries and is not related to your app. If you export your app as an iOS Xcode project, you can edit your app's Info.plist from Xcode UI.

Also add the last language question
The menu above the IOS display is like this
...
I want to modify which side to make it into other languages such as Chinese, Japanese, etc. This situation is also added on Android.

For iOS you need to set CFBundleAllowMixedLocalizations true (cf. #239 (comment)). Android should be okay without any extra setting as I tested a simple link <a href="tel:1234567890">telephone</a> and it showed a popup in the current device language.

The last thing I want to ask is that the experimental version of the #77 upload file provided last time is limited to the image file. Can it be modified to freely select the type of uploading is image, file, music?

I've updated #77 by replacing the argument of setType from image/* to */* so please check it. I tested it on Nexus 7 (2013, Android 6.0.1) and it showed UI in the current device language.

@c8970412
Copy link
Author

For the #77 update, the screen on my Android is like this, you can choose what content to upload.
2222
But when you choose to upload the file, the prompt text at the top is Image Chooser. Is this normal?
Does he read the language of my phone to display text or can I change it with a program?

In addition, the interface between Chinese and English is found on IOS.
111
Does the text it displays have been written in the WebView? Can you use the program to determine the language of the menu to display the menu text it displays?
Finally, when Android clicks on the upload in WebView, the screen will suddenly flash.

@KojiNakamaru
Copy link
Member

KojiNakamaru commented Mar 27, 2019

But when you choose to upload the file, the prompt text at the top is Image Chooser. Is this normal?

Maybe, I guess it depends on each device. For example, my Nexus 7 (2013, Android 6.0.1) shows the following, correcty in Japanese without any extra setting as I said in the last comment:

sc

In addition, the interface between Chinese and English is found on IOS.

I said "For iOS you need to set CFBundleAllowMixedLocalizations true" in the last comment.

Finally, when Android clicks on the upload in WebView, the screen will suddenly flash.

I don't know what happened. At least I tried http://jkorpela.fi/forms/testing.html and it worked nicely.

@c8970412
Copy link
Author

I am looking at the part of IOS.

For the Android issue, I think you may misunderstand me.
The prompt text above the transition language is still Image Chooser
3

This is what it looks like in Google Chrome, I hope the text above can be changed with the language.
1

In addition, when you click Upload, WebView will be blank like this.
is this normal?
S__250142732

@KojiNakamaru
Copy link
Member

The prompt text above the transition language is still Image Chooser

Sorry, I rechecked the code and found "Image Chooser". I've fixed it and updated the binaries so please try the latest in the branch.

In addition, when you click Upload, WebView will be blank like this.

If the server correctly responds, the WebView should show any adequate content. As I said http://jkorpela.fi/forms/testing.html at least worked nicely.

@c8970412
Copy link
Author

c8970412 commented Apr 2, 2019

Thank you, he can already support the phone language.

I still have a question, is WebView unable to read the HTML inside this machine?
I put an index.html in StreamingAssets, Resources.
I want to get the URL from this index.html and pass it back to WebView, but there is no screen after the URL received by WebView. Is it not supported to read HTML locally?

@KojiNakamaru
Copy link
Member

For Android, as the sample app does, you need to retrieve bytes by WWW,

if (src.Contains("://")) { // for Android
var www = new WWW(src);
yield return www;
result = www.bytes;
} else {

and save them to a file under Application.persistentDataPath by yourself.
System.IO.File.WriteAllBytes(dst, result);

@c8970412
Copy link
Author

c8970412 commented Apr 3, 2019

I will try again
There is a situation when WebView uses upload, phone, and mailbox.
Click the WebView screen before clicking
S__251265038

但是當我點選電話,信箱的時候WebView的畫面整個不見了
S__251265039
S__251265040

@KojiNakamaru
Copy link
Member

As I said http://jkorpela.fi/forms/testing.html at least worked nicely. Please try it at first.
You can specify the url as below:
image
You can then specify any text file to the input in the middle of the page and submit it:
image

@c8970412
Copy link
Author

c8970412 commented Apr 8, 2019

I tried the URL you provided http://jkorpela.fi/forms/testing.html
But you can’t connect to the site either on your computer or on your phone.

@KojiNakamaru
Copy link
Member

I cannot solve your network connection trouble. If your network has any restriction, please make a simple "echo back" server in your local network and check how your client submit/receive data.

@c8970412
Copy link
Author

c8970412 commented Apr 10, 2019

This is a screen that uses Chrome to connect to the phone. After clicking the phone, the menu will appear normally and the website will operate normally.
S__253157378
But on the WebView, the entire screen of the WebView is gone as shown in the picture above.
Is there a way to improve this?

I am sorry, I want to add another one.
Regarding the reading of the native html mentioned last time, according to your statement, the WWW is used to retrieve the bytes.
I took the URL of index.html under the StreamingAssets folder and passed it back to the URL of SampleWebView, but I don't know which side of the error. WebView still doesn't display the screen. It seems that the returned URL is not correct.
According to my understanding, WebView must give the correct URL to read the screen. If the correct URL screen is blank, can the packaged html path be read and displayed?

@KojiNakamaru
Copy link
Member

Okay, now I see what you are talking and I'm sorry about the confusion. The code intentionally hides webviews on application pause for avoiding some layouting issues (#301). This is still needed but I tried to reduce your problem by hiding webviews on appplication resume instead of application pause (#411). I've updated binaries on both master and experimental/android_input_type_file so could you please try the latest.

@c8970412
Copy link
Author

I would like to ask about the compatibility of different mobile phones and systems.
What is the minimum and maximum version support for Android and IOS?
In addition, when I test on different models, I sometimes have the following conditions.
SONY is loading WebView and using EvaluateJS, Unity.call is fast and there are no errors.
SAMSUNG loading WebView is normal, but the reaction of Unity.call is sometimes very slow. When the button in WebView uses Unity.call to call the function in Unity, sometimes the call is successful once, sometimes it is pressed many times. There are also IPad
Is there a delay or delivery failure when JS and C# call each other because of the operating system and the phone model?

Because at present, only SONY, SAMSUNG, IPad three machines can be tested, so I don't know if they will be in other models.

@KojiNakamaru
Copy link
Member

The plugin utilizes native WKWebView/UIWebView/WebView components as is so that the performance totally depends on each OS/device. For iOS, additionally, Unity.call() is defined by EvaluateJS() so that you need to be careful about its availability when you call it (you can skip EvaluateJS() if you utilize only WKWebView and directly utilize window.webkit.messageHandlers.unityControl.postMessage()).

cf.

window.webkit.messageHandlers.unityControl.postMessage(msg);

@c8970412
Copy link
Author

Thanks for the answer, after various old models test, it is found that not only WebView will fail, but even Unity’s own screen will be like this.

In addition, there are 2 questions on IOS.

  1. The above mentioned that the WebView screen disappears when uploading from Android. It is related to webView.Call("SetVisibility", false). Can I use this function in IOS?

  2. IOS reads native HTML, I put 2 html, sample and test in the StreamingAssets folder
    In android, 2 html can be read, but in IOS he can only read the sample html, the other he has no screen at all.
    Is he deciding which file name to read only?

@KojiNakamaru
Copy link
Member

If the Uniy's rendering also collapses, I guess those devices have issues in GPU driver/Surface manager.

  1. The above mentioned that the WebView screen disappears when uploading from Android. It is related to webView.Call("SetVisibility", false). Can I use this function in IOS?

SetVisibity is defined in WebViewObject.cs as below:

public void SetVisibility(bool v)
{
#if UNITY_WEBPLAYER
Application.ExternalCall("unityWebView.setVisibility", name, v);
#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
//TODO: UNSUPPORTED
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
if (webView == IntPtr.Zero)
return;
_CWebViewPlugin_SetVisibility(webView, v);
#elif UNITY_IPHONE
if (webView == IntPtr.Zero)
return;
_CWebViewPlugin_SetVisibility(webView, v);
#elif UNITY_ANDROID
if (webView == null)
return;
mVisibility = v;
webView.Call("SetVisibility", v);
#endif
visibility = v;
}

and is utilized in the sample app.

webViewObject.SetVisibility(true);

  1. IOS reads native HTML, I put 2 html, sample and test in the StreamingAssets folder
    In android, 2 html can be read, but in IOS he can only read the sample html, the other he has no screen at all.
    Is he deciding which file name to read only?

The iOS implementation can read any html file. By the following change, for the sample app, you can load sample.html and test.html by tapping the rightmost '*' button.

diff --git a/sample/Assets/Scripts/SampleWebView.cs b/sample/Assets/Scripts/SampleWebView.cs
index c0de193..175696f 100644
--- a/sample/Assets/Scripts/SampleWebView.cs
+++ b/sample/Assets/Scripts/SampleWebView.cs
@@ -113,6 +113,9 @@ public class SampleWebView : MonoBehaviour
             };
             foreach (var ext in exts) {
                 var url = Url.Replace(".html", ext);
+                if (ext == ".html") {
+                    url = url.Replace("sample", prefixReplacement);
+                }
                 var src = System.IO.Path.Combine(Application.streamingAssetsPath, url);
                 var dst = System.IO.Path.Combine(Application.persistentDataPath, url);
                 byte[] result = null;
@@ -149,6 +152,8 @@ public class SampleWebView : MonoBehaviour
     }
 
 #if !UNITY_WEBPLAYER
+    string prefixReplacement = "sample";
+
     void OnGUI()
     {
         GUI.enabled = webViewObject.CanGoBack();
@@ -170,6 +175,7 @@ public class SampleWebView : MonoBehaviour
             if (g != null) {
                 Destroy(g);
             } else {
+                prefixReplacement = (prefixReplacement == "sample") ? "test" : "sample";
                 StartCoroutine(Start());
             }
         }
diff --git a/sample/Assets/StreamingAssets/test.html b/sample/Assets/StreamingAssets/test.html
new file mode 100644
index 0000000..4fd2c6e
--- /dev/null
+++ b/sample/Assets/StreamingAssets/test.html
@@ -0,0 +1,10 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <title>Test</title>
+  </head>
+  <body>
+    <h1>Test</h1>
+    <p><img src="sample.jpg"/> (local image)</p>
+  </body>
+</html>

@c8970412
Copy link
Author

c8970412 commented Apr 18, 2019

The IOS provided above to read the html way I will try again

The result I expected was that some locales would switch the scene to specify the html of the machine to load the WebView, and other places would be the html of the network. This works fine on Android, but there is no picture on IOS.

The situation is similar to whether the phone is connected to the network after opening. If there is a network to give the URL and then load the WebView, if not, directly specify the local html to load the WebView.

In addition, would you like to ask WebView for support site judgment?
For example, if the URL is wrong, it can detect the prompt message saying the wrong URL.
Similar to www.isdone, you can know if it is loaded.

@KojiNakamaru
Copy link
Member

The result I expected was that some locales would switch the scene to specify the html of the machine to load the WebView, and other places would be the html of the network. This works fine on Android, but there is no picture on IOS.
...

Please provide a minimum sample app that reproduce your issue, based on the sample app in this repository.

if the URL is wrong

The plugin simply tries to load the specifibbed URL. If any error occurs, it reports through the err: callback. Otherwise the ld: callback is called.

@c8970412
Copy link
Author

I remember that I mentioned that the plugin does not support the download function, and the IOS itself has a mechanism for long-pressing images and downloading images, as shown below.
S__255590417
In the test file, once you select Save Image, the entire program will jump. Is there a way to disable the IOS long-press download function in WevView?

In addition, this plugin has the function of supporting return, there is a virtual button on Android, as shown below
S__255598596
Can WebView eat back the effect? No response is currently pressed.

@KojiNakamaru
Copy link
Member

Is there a way to disable the IOS long-press download function in WevView?

Though I haven't tested it, you should be able to disable 3D Touch with the following change.
cf. turbolinks/turbolinks-ios#95 (comment)

diff --git a/plugins/iOS/WebView.mm b/plugins/iOS/WebView.mm
index bc56d6e..0e9dd5f 100644
--- a/plugins/iOS/WebView.mm
+++ b/plugins/iOS/WebView.mm
@@ -31,6 +31,7 @@ extern "C" void UnitySendMessage(const char *, const char *, const char *);
 @property (nonatomic, getter=isOpaque) BOOL opaque;
 @property (nullable, nonatomic, copy) UIColor *backgroundColor UI_APPEARANCE_SELECTOR;
 @property (nonatomic, getter=isHidden) BOOL hidden;
+@property (nonatomic, getter=isAllowsLinkPreview) BOOL allowsLinkPreview;
 @property (nonatomic) CGRect frame;
 @property (nullable, nonatomic, assign) id <UIWebViewDelegate> delegate;
 @property (nullable, nonatomic, weak) id <WKNavigationDelegate> navigationDelegate;
@@ -168,6 +169,7 @@ static WKProcessPool *_sharedProcessPool;
         webView.opaque = NO;
         webView.backgroundColor = [UIColor clearColor];
     }
+    webView.allowsLinkPreview = false;
     webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
     webView.hidden = YES;
     

this plugin has the function of supporting return

It is not caused by the plugin. The back button should be supported by any android app and in Unity you need to handle the escape key event.
cf. https://answers.unity.com/questions/25535/android-back-button-event.html

@c8970412
Copy link
Author

Thank you, Android's back button is working.
But the IOS part added the allowsLinkPreview in WebView.mm according to the method provided above.
But still not disabled to 3D Touch, is there any more to set up X Code?

@KojiNakamaru
Copy link
Member

Did you modify Assets/Plugins/iOS/WebView.mm?

@c8970412
Copy link
Author

Yes, but no effect
But just found in SampleWebView.cs, as long as you change enableWKWebView: true to false, you can disable 3D Touch. If you disable it, please follow the above to modify WebView.mm or just change SampleWebView.cs?

@KojiNakamaru
Copy link
Member

Okay, I've further investigated. Please try the following, in which I added the setting about webkitTouchCallout.

diff --git a/plugins/iOS/WebView.mm b/plugins/iOS/WebView.mm
index bc56d6e..61105a3 100644
--- a/plugins/iOS/WebView.mm
+++ b/plugins/iOS/WebView.mm
@@ -31,6 +31,7 @@ extern "C" void UnitySendMessage(const char *, const char *, const char *);
 @property (nonatomic, getter=isOpaque) BOOL opaque;
 @property (nullable, nonatomic, copy) UIColor *backgroundColor UI_APPEARANCE_SELECTOR;
 @property (nonatomic, getter=isHidden) BOOL hidden;
+@property (nonatomic, getter=isAllowsLinkPreview) BOOL allowsLinkPreview;
 @property (nonatomic) CGRect frame;
 @property (nullable, nonatomic, assign) id <UIWebViewDelegate> delegate;
 @property (nullable, nonatomic, weak) id <WKNavigationDelegate> navigationDelegate;
@@ -149,6 +150,10 @@ static WKProcessPool *_sharedProcessPool;
         WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
         WKUserContentController *controller = [[WKUserContentController alloc] init];
         [controller addScriptMessageHandler:self name:@"unityControl"];
+        [controller addUserScript:[[WKUserScript alloc]
+                                      initWithSource:@"document.documentElement.style.webkitTouchCallout='none';"
+                                       injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
+                                    forMainFrameOnly:NO]];
         configuration.userContentController = controller;
         configuration.allowsInlineMediaPlayback = true;
         configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
@@ -170,6 +175,7 @@ static WKProcessPool *_sharedProcessPool;
     }
     webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
     webView.hidden = YES;
+    webView.allowsLinkPreview = NO;
     
     [webView addObserver:self forKeyPath: @"loading" options: NSKeyValueObservingOptionNew context:nil];
     

enableWKWebView: true to false

With this setting, the plugin utilizes UIWebView instead of WKWebView. If it is okay, changing only SampleWebView.cs is sufficient.

@c8970412
Copy link
Author

Thank you for his normal operation.
There is a problem here to discuss with you. I said that this plugin will only lead to the specified URL. Even if the specified URL does not exist and is wrong, there will be no hints on the screen.

Then there is a way for WebView to determine that the URL does not exist before loading. As long as the website is connected too slowly or if the website suddenly has errors, it will jump out of "Website timeout" or "Cannot connect to the website." "Is the error message?

@KojiNakamaru
Copy link
Member

Have you tried err: callback described in #402 (comment) ? This is basically everything the plugin provides for errors. If you want to determine whether a url is correct before loading it, you should utilize UnityWebRequest and/or WWW before calling LoadURL(), etc.

@c8970412
Copy link
Author

c8970412 commented Jun 6, 2019

I’m sorry to reply so long, about the URL error I said before.
I originally expected that if the specified URL does not exist, the page will pop up a website error like 404. When the connection time is too long, the page will also jump out of the screen.

But according to the current situation, once the connection is successful or the failure is unified, the string is represented.
I will think about this part to see how to do it.

There is a place I want to ask and discuss with you. If you jump out of the APP framework for a while and then come back when uploading the file, uploading the file will fail. Is there a function to support the resume?

@KojiNakamaru
Copy link
Member

KojiNakamaru commented Jun 10, 2019

For connection errors, if you can limit the Android version 6.0 or later, you can specify the httpErr: callback which was introduced by #335 .

There is no auto-recovery mechanism for uploading. If you want to provide it, it is better to handle uploading by yourself in Unity C# code.

@c8970412
Copy link
Author

Did you say that going back to the tune will make the WebView image become like this?
Or is it the same callback?
6aa10b742aa85a3604472c63d6c05df6
1560153102692

@KojiNakamaru
Copy link
Member

What is "the tune"? Also I cannot understand the screenshot with Chinese strings.

I said nothing about what happens on the Webview image when any error occurs (I guess it depends on Android and/or Webview versions). I simply said that any error would be sent to the callback on the Unity side if it occurred and a corresponding callback was called in Java.

Please note that this plugin is basically a thin wrapper for system WebView components and it doesn't do much about errors. Instead it send them to the Unity side.

@c8970412
Copy link
Author

Sorry, I may not express it very clearly.
I mean, when you connect to any website on your computer, if there is an error, such as the website cannot be connected or closed, the network speed is too slow and the connection is overdue, then there will be an error message on the website page. Code like HTTP 404

My current situation is to use err to verify that WebView seems to only determine whether the URL exists. If the URL is correct, it will be directly connected to the website. If it is wrong, err tells me ERR_ADDRESS_UNREACHABLE and the screen is blank when the website is connected. Did not return any prompt when the line time was too long

According to your website, the error of the website is returned to Unity in the form of a string. It does not have any representation in the WebView screen. If I want to do the same as the website on the computer, I can use it on the WebView screen. Does it show that HTTP 404 and the connection timeout picture can be done?

@KojiNakamaru
Copy link
Member

There is no automatic display/prompt for errors. Instead, the plugin load about:blank for an error (as the default webview shows an error page for developers, not for end users) and inform it to the Unity side, so for example you can load an adequate error page by LoadHTML() and/or EvaluateJS(). If you need to make the timeout shorter, you need to check it on the Unity side by timing the duration since LoadURL(), for example.

@c8970412
Copy link
Author

Thank you, I probably have a direction.
When Unity receives the error message, I directly read the html page that has been prepared so that the user can clearly know the current connection status.

But there is a place for monitoring the LoadURL. I don't know if I am in the wrong direction or there is an error in my practice. My monitoring of LoadURL is only useful when I load it for the first time, but the result I expect is After loading, you can receive a message whether you jump to any page or return to the home page.

For example, pressing "Back to Home" on a certain page will trigger a timer, and then the timer will be over 5 seconds to inform the user that "the connection time is too long". If it is less than 5 seconds, it will return to the home page smoothly. The timer is 0, regardless of any page, just jump to other pages will trigger this timer

Is there a way to capture the message before the jump?

@KojiNakamaru
Copy link
Member

You can utilize the started: callback:

started: (msg) =>
{
Debug.Log(string.Format("CallOnStarted[{0}]", msg));
},

@c8970412
Copy link
Author

so
Started: (msg) =>
  {
      Debug.Log(string.Format("CallOnStarted[{0}]", msg));
  },
Is triggered every time the page is converted

and
Ld: (msg) =>
{
     Debug.Log(string.Format("CallOnLoaded[{0}]", msg));
}
Is it determined that the loading is completed after the conversion?

@KojiNakamaru
Copy link
Member

You can specify both callbacks, started: for page loading start and ld: for page loading end.

@c8970412
Copy link
Author

Sorry, I still don't quite understand what you mean.
I started the timer in started, stopped the timer and returned to 0 when I was ld, but she didn't achieve the effect I expected.
When I passed the string of started and ld to the text box, I found that when loading other pages, started and ld did not return the URL to me, but at the moment when the loading was completed, started and ld were returned almost simultaneously. URL

I initially thought that when I load the page, started will be sent back to the URL I want to load, and ld will be returned when the loading is complete.

@KojiNakamaru
Copy link
Member

Okay, in https://github.com/gree/unity-webview/commits/experimental/android_input_type_file, I've modified the code to call the started: callback also in shouldOverrideUrlLoading() so that it will be called at earlier timing. Please note the started callback may be called multiple times before the corresponding ld: callback is called.

@c8970412
Copy link
Author

Thank you, he is working properly.

There are some places in the cookie that I would like to discuss and read other articles about cookies. I found that if I want to get a cookie, I can only get it from JS and throw it back to Unity, but because the cookie that JS takes out is not complete, on the website. You can see three pieces of information on the cookie, but only 2 pieces of information are taken out, and one of the articles is about clearing the cookie. Would you like to ask where the URL of the WebView is stored when loading the website? He is Only http?

@KojiNakamaru
Copy link
Member

I cannot understand what you ask about cookies. About the following,

Would you like to ask where the URL of the WebView is stored when loading the website

I don't want to ask any, however, I guess you would like to know the URL. You can receive the URL as started: callback's argument.

@c8970412
Copy link
Author

Sorry, I revisited the situation with the person in charge of JS.

What he means is that the cookies available on the web page are like this.
1561099001874
However, he said that JS could not take out the three materials completely, only two of them could be taken out. Therefore, I would like to ask if WebView has the function of accessing cookies. Let us use Unity to retrieve the data in the figure.

If not, should it be accepted by Unity by JS's lost cookies?

@KojiNakamaru
Copy link
Member

Maybe the cookie was http-only one, which could not be accessible by JavaScript.
I've added GetCookies(url) method in #433 and merged the change into https://github.com/gree/unity-webview/tree/experimental/android_input_type_file . Though I've not tested much, could you please try the latest binaries in the branch.

@c8970412
Copy link
Author

c8970412 commented Jun 26, 2019

Thank you, he works fine on Android, but there are some doubts on the IOS.

IOS and Android do not match the behavior of cookies. Android can obtain cookies before loading the website. However, IOS can't be obtained immediately before and after loading, but it will be closed after the application is turned off several times.
Does IOS have certain mechanisms that block cookies?

@KojiNakamaru
Copy link
Member

Yes, iOS WKWebView seems not to save cookies immediately. I've modified the code further based on https://stackoverflow.com/questions/33156567/getting-all-cookies-from-wkwebview/49744695#49744695 , so could you please try the latest again.

@c8970412
Copy link
Author

c8970412 commented Aug 29, 2019

Sorry, because I am busy with other things, I will reply now.
Thank you, he is working properly.
There is another place I want to propose to discuss with you. Android can input the text box when reading the local html, but if you load html from A-Scene to B-Scene, the text box cannot be input, it seems to be No focus on the text box, but shrinking the app and going back to the screen will be fine.
In the figure, the left side is the case where A-Scene jumps to B-Scene, and the right side is the case where there is no jump to the Scene to open the direct loading of html.

未命名

The text in the text box cannot be deleted on the left side and no text can be entered. The right side is normal operation.

@KojiNakamaru
Copy link
Member

Please provide a more concrete example based on the sample app. I cannot understand A-Scene and/or B-Scene. At least with the sample app,

  1. opening https://google.com and inputting youtube work okay
  2. after moving to https://youtube.com, searching test works okay

@c8970412
Copy link
Author

Sorry, I found the problem.
In the UNITY_WEBPLAYER inside SampleWebView.cs, I added a code to detect the html loading and jump out of the small pattern, because the program code caused the UNITY_WEBPLAYER part of the program to be executed without interruption, the small pattern program After the code is removed, everything works fine.

In addition, the two APIs of IOS WKWebView and UIWebView want to confirm, because Apple official has abandoned the UIWebView API, so it is reasonable to say that the function of using UIWebView will be invalid, but the actual test function on IOS is normal. So whether all functions use WKWebView instead of UIWebView, you can see WKWebView and UIWebView in WebView.mm, I think UIWebView related code does not use him.

@KojiNakamaru
Copy link
Member

I've modified the code and updated binaries. please check the latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants