Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
How to display a SharePoint page in an iOS mobile app with Xamarin, WebView control and NTLM authentication - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

2017-05-11

In this post, we will see an example of how to display a SharePoint page in the IOS mobile app using the WebView control using NTLM authentication. For this example, I have used my local SharePoint 2016 environment with a self-signed certificate and the Visual Studio for Mac.

Steps:

  1. Add a WebView control to the ViewController.
  2. Create a ConnectionDelegate to handle the SSL and Authentication. Please include the below section as a code sample:
    public class ConnectionDelegate : NSUrlConnectionDelegate
    {
        private readonly UIWebView _webView;
        private NSUrlRequest _request;
     
        public ConnectionDelegate(UIWebView parent, NSUrlRequest request)
        {
            _webView = parent;
            _request = request;
        }
     
        public override void WillSendRequestForAuthenticationChallenge(NSUrlConnection connection,
                     NSUrlAuthenticationChallenge challenge)
        {
                     
            if (challenge.ProtectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodNTLM)
            {
     
             var credential = new NSUrlCredential("domain\\userid", "password", NSUrlCredentialPersistence.ForSession);
                         challenge.Sender.UseCredential(credential, challenge);
                         challenge.Sender.ContinueWithoutCredential(challenge);
     
                     }
            else if (challenge.ProtectionSpace.AuthenticationMethod == NSUrlProtectionSpace.AuthenticationMethodServerTrust)
            {
               challenge.Sender.UseCredential(NSUrlCredential.FromTrust(challenge.ProtectionSpace.ServerSecTrust), challenge);
                         challenge.Sender.ContinueWithoutCredential(challenge);
            }
     
            return;
         }
     
     }
  3. Attach the custom delegate class to the WebView to handle the authentication.
    var urlComponents = new NSUrlComponents("https://portal.contoso.com");
    WebView.ShouldStartLoad = (webView, request, navType) =>
                 {
     
                     var urlConnection = NSUrlConnection.FromRequest(request, new ConnectionDelegate(webView, request));
                     urlConnection.Start();
     
                     return true;
                 };
                 
    WebView.LoadRequest(new NSUrlRequest(urlComponents.Url));
  4. Run the application to display the SharePoint page within the webview.

 

(Visited 422 times, 1 visits today)

About the author 

Balamurugan Kailasam

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.