URL not opening iOS webview custom renderer Xamarin forms

Bhuwan
251
Reputation points
Hi
I am facing an issue on the WebView URL renderer on iOS after the render page displays blank and the same page will be visible on Android devices. On Url getting some console error like some images not working.
Below function is deprecated on iOS version or change method means if page not working or not renderer then how to display message in place of blank page.
webViewWebContentProcessDidTerminate
below the iOS custom view renderer.
[assembly: ExportRenderer(typeof(CustomWebView), typeof(CustomWebViewRenderer))]
namespace Yuro.iOS.Controls
{
/// <summary>
/// CustomWebViewRenderer
/// </summary>
public class CustomWebViewRenderer : ViewRenderer<CustomWebView, WKWebView>
{
/// <summary>
/// _wkWebView
/// </summary>
WKWebView _wkWebView;
/// <summary>
/// OnElementChanged
/// </summary>
/// <param name="e"></param>
protected override void OnElementChanged(ElementChangedEventArgs<CustomWebView> e)
{
try
{
base.OnElementChanged(e);
if (Control == null)
{
var config = new WKWebViewConfiguration();
config.AllowsInlineMediaPlayback = true;
config.MediaPlaybackRequiresUserAction = false;
_wkWebView = new WKWebView(Frame, config);
SetNativeControl(_wkWebView);
}
if (e.NewElement != null)
{
Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Url)));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
{count} votes
Hi @Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.)
My question is if i am using WebView in Xamarin forms iOS from render Url and this getting some issue like missing images or not load java script or any image content then this page is not visible on iOS WebView but at same time this Url is working on Android. so how to handle this type of URLs in iOS and display content with missing java script or image content.
and how to use this method webViewWebContentProcessDidTerminate in xmarin forms
can you give me some example
Would you mind sharing the URLs for testing so that I can reproduce the issue? Do you want to invoke the js method from c#? Are there some html/js files in the project? or you mean the js contained in the URL? What did you try? I'm not sure why the content was missing, it's easier to help you if you provide more code snippets, error messages and so on. Besides, you can refer to Customizing a WebView - Xamarin | Microsoft Learn
1.Set the delegate in OnElementChanged method in your WKWebviewRenderer
Hi @Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.)
url shared before updated comment
Thanks.
I got it, I will test it as soon as possible.
Hi @Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.)
please update me if your is working or not in your end if not working then how to fix this.
I reproduce your issue, the webview is blank. I found the content will display on the screen when I reload page by WebInspector via Safari. And it won't trigger the failed delegate method of WKWebview(but it shows timeout in WebInspector under debug mode).
You could try to enable Web Inspector and debug this webview, and try to modify the timeout time in your js file to check if it works.
Hi
how to enable Web Inspector and debug this webview and how to modify the timeout time in your js file. can you suggest me.
and also can you suggest me how to fix this issue permanent or handle this issue when coming in future.
Hi got it can you please remove above comment as per Url privacy.
Yes, I have edited the comment and hide the link. I will delete the comment and make an answer for direction. In addition, since the link is privacy, it is recommended to open a support ticket for this. Please contact our paid phone support at MS Support. You will get 1:1 support on that.
Thanks, i will connect above paid support.
Sign in to comment
Hello,
This issue is caused by the server side. The picture links are not responding. You can refer to the above link to enable Web Inspector and debug this webview via Safari, then adjust the content on server side.
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Sign in to comment
0 additional answers
Sort by: Most helpful
Activity