1
votes

I saw some other questions with same title, but my question is different.

Yesterday, I uploaded my App to TestFlight and after a while, Apple sent me this warning:

ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs. See https://developer.apple.com/documentation/uikit/uiwebview for more information.

I am using WebView for showing HTML data in my app. Also, I have used WebView for playing audio and video. So is this warning reject my app when submitting for review or should I change these features with some other APIs?

In this link provided by AppStore, telling about use WKWebView instead of UIWebView, I tried that and no such property found on XAML. Should I need to install any packages for getting that feature? Also, by using WKWebView, is it possible to play audio, video and showing HTML data in the app?

Update 1

Getting System.ArumentNullException when work with the custom renderer. Am I missing something?

enter image description here

Update 2: Renderer Codes PCL

public class MyWebView : WebView
{
    public static readonly BindableProperty UrlProperty = BindableProperty.Create(
        propertyName: "Url",
        returnType: typeof(string),
        declaringType: typeof(MyWebView),
        defaultValue: default(string));

    public string Url
    {
        get { return (string)GetValue(UrlProperty); }
        set { SetValue(UrlProperty, value); }
    }
}

The custom renderer for this class on iOS:

[assembly: ExportRenderer(typeof(MyWebView), typeof(MyWebViewRenderer))]
namespace WKWebViewDemo.iOS
{
    public class MyWebViewRenderer : ViewRenderer<MyWebView, WKWebView>
    {
        WKWebView _wkWebView;
        protected override void OnElementChanged(ElementChangedEventArgs<MyWebView> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                var config = new WKWebViewConfiguration();
                _wkWebView = new WKWebView(Frame, config);
                SetNativeControl(_wkWebView);
            }
            if (e.NewElement != null)
            {
                Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Url)));
            }
        }
    }
}

XAML

<StackLayout>
    <local:MyWebView Url="https://www.microsoft.com" VerticalOptions="FillAndExpand"/>
</StackLayout>
1
I create a new project and add your codes there, it works on my side. Is there any other codes in your project? - Jack Hua
@JackHua-MSFT No other codes added, can you share a sample? - Sreejith Sree
You can check the sample here, let me know if it works for you. - Jack Hua
@JackHua-MSFT I tested your sample code, it is working fine. I have used exactly the same code on my project, but showing the exception. I am using the XF version: 4.3.0.778476-pre1, is there any other reason for this exception? - Sreejith Sree
I test my sample under 4.3.0.778476-pre1 and it also works. I can check it for you if can share me your project. - Jack Hua

1 Answers

1
votes

Update

This issue has been solved and the solution can be found in the below answer

ITMS-90909: Deprecated API Usage with iOS in Xamarin Forms app

This is an open bug with Xamarin.Forms at Github

As of now, I do not see any workaround or something on the thread but you can wait for it to be fixed with the next releases of Xamarin.Forms

Update: saw a workaround which might work check this out https://github.com/xamarin/Xamarin.Forms/issues/7323#issuecomment-527294907