-
Notifications
You must be signed in to change notification settings - Fork 688
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
Comments
This plugin simply utilizes native UIWebView/WKWebView for iOS and/or WebView for Android, thus each performs differently depending on OS, hardware, etc.
I tested phone links (
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
The plugin works both for |
I would like to ask the IOS permissions, where should I set it? |
Please check the followings. By adding adequate entries in Info.plist you should be able to see the 'Photo' icon for https://stackoverflow.com/questions/39465687/nscamerausagedescription-in-ios-10-0-runtime-crash/39608545#39608545 |
Regarding the Info.plist file, I have no response after the modification. I would like to ask if the path has any effect? Also add the last language question 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? |
Files under
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
I've updated #77 by replacing the argument of |
For the #77 update, the screen on my Android is like this, you can choose what content to upload. In addition, the interface between Chinese and English is found on IOS. |
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:
I said "For iOS you need to set CFBundleAllowMixedLocalizations true" in the last comment.
I don't know what happened. At least I tried http://jkorpela.fi/forms/testing.html and it worked nicely. |
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.
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. |
Thank you, he can already support the phone language. I still have a question, is WebView unable to read the HTML inside this machine? |
For Android, as the sample app does, you need to retrieve bytes by WWW, unity-webview/sample/Assets/Scripts/SampleWebView.cs Lines 119 to 123 in 03e4db4
and save them to a file under Application.persistentDataPath by yourself.
|
As I said http://jkorpela.fi/forms/testing.html at least worked nicely. Please try it at first. |
I tried the URL you provided http://jkorpela.fi/forms/testing.html |
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. |
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. |
I would like to ask about the compatibility of different mobile phones and systems. Because at present, only SONY, SAMSUNG, IPad three machines can be tested, so I don't know if they will be in other models. |
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 cf.
|
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.
|
If the Uniy's rendering also collapses, I guess those devices have issues in GPU driver/Surface manager.
SetVisibity is defined in WebViewObject.cs as below: unity-webview/plugins/WebViewObject.cs Lines 476 to 497 in 4bcc76e
and is utilized in the sample app.
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> |
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? |
Please provide a minimum sample app that reproduce your issue, based on the sample app in this repository.
The plugin simply tries to load the specifibbed URL. If any error occurs, it reports through the |
Though I haven't tested it, you should be able to disable 3D Touch with the following change. 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;
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. |
Thank you, Android's back button is working. |
Did you modify |
Yes, but no effect |
Okay, I've further investigated. Please try the following, in which I added the setting about 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];
With this setting, the plugin utilizes UIWebView instead of WKWebView. If it is okay, changing only SampleWebView.cs is sufficient. |
Thank you for his normal operation. 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? |
Have you tried |
I’m sorry to reply so long, about the URL error I said before. But according to the current situation, once the connection is successful or the failure is unified, the string is represented. 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? |
For connection errors, if you can limit the Android version 6.0 or later, you can specify the 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. |
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. |
Sorry, I may not express it very clearly. 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? |
There is no automatic display/prompt for errors. Instead, the plugin load |
Thank you, I probably have a direction. 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? |
You can utilize the unity-webview/sample/Assets/Scripts/SampleWebView.cs Lines 46 to 49 in 782b3c5
|
so and |
You can specify both callbacks, |
Sorry, I still don't quite understand what you mean. 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. |
Okay, in https://github.com/gree/unity-webview/commits/experimental/android_input_type_file, I've modified the code to call the |
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? |
I cannot understand what you ask about cookies. About the following,
I don't want to ask any, however, I guess you would like to know the URL. You can receive the URL as |
Maybe the cookie was http-only one, which could not be accessible by JavaScript. |
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. |
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. |
Sorry, because I am busy with other things, I will reply now. 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. |
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,
|
Sorry, I found the problem. 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. |
I've modified the code and updated binaries. please check the latest. |
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?
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?
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?
Can the website only read the beginning of http?
Can Http and https be case-sensitive or multiple s can be read?
The text was updated successfully, but these errors were encountered: