question

GordonS-9701 avatar image
0 Votes"
GordonS-9701 asked JessieZhang-2116 commented

Xamarin Forms WebView doesn't work for my specific URL

I have an iOS app (and Android, which works fine) where I use a WebView to load a specific URL.

It works if I use "https://google.com" but not if I use the required one which is

 https://sandbox.nuapay.com/tpp-ui/redirect?userInterfacePaymentId=1234567890  

I have tried adding various settings for NSAppTransportSecurity but I can't find a clear explanation of what the options are or what they specifically do.

I tried this, but it didn't seem to help:

  <key>NSAppTransportSecurity</key>  

<dict>
<key>NSExceptionDomains</key>
<dict>
<key>nuapay.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true />
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true />
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
</dict>
</dict>



Is there a way, when debugging, to see what the problem is?

Edit:

I added a handler for WebView.Navigated and the Status is "Success", so it seems to be a problem with the content just not showing in WebView.

Edit 2;

OK, so I added the following to the WebView definition:

                          WidthRequest="500"
                          HeightRequest="1000"
                          MinimumWidthRequest="1000"
                          MinimumHeightRequest="1000"
                          HorizontalOptions="FillAndExpand"
                          VerticalOptions="FillAndExpand"

And now I can see the content ... however the WebView is now way too big, so I can only see the edge. How do I make the WebView size itself to the full space available in the App - and make the content size itself to the size of the WebView?!

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JessieZhang-2116 avatar image
0 Votes"
JessieZhang-2116 answered JessieZhang-2116 commented

Hello,


Welcome to our Microsoft Q&A platform!

This is App Transport Security issue , just add the following line into Info.plist and try again.

 <key>NSAppTransportSecurity</key>
 <dict>
     <key>NSAllowsArbitraryLoads</key>
     <true/>
 </dict>

Best Regards,


Jessie Zhang


If the response is helpful, please click "Accept Answer" and upvote it.



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.



· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I tried that but it made no difference unfortunately.

0 Votes 0 ·

I have updated my question. I added a WebView.Navigated handler and have found that the result is "Success", which is good, but I still don't know why the content is not displaying.

0 Votes 0 ·

Hi @GordonS-9701 ,sorry, we couldn't reproduce this problem on our side. Could you please post a video so that we can better pinpoint where the problem is?

0 Votes 0 ·

Sorry for not updating this post. It turned out that the page was displaying, the problem was that on iOS didn't handle sizing the content to the WebView very well.

Our front-end guy reworked the XAML and by using a grid (and other stuff?!) removed the need to specify width or height values. The content now displays correctly on both Android and iOS.

0 Votes 0 ·

Congrats, and thanks for your support for xamarin. Have a nice day. :)

1 Vote 1 ·
PRASANTMOHANTY-6840 avatar image
0 Votes"
PRASANTMOHANTY-6840 answered GordonS-9701 commented

I will try myself and give a solution to you.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have updated my question, with further information gained

0 Votes 0 ·