Xamarin iOS WebView Demo

Step to create basic webview app for iOS on iPad.

  1. VS2015 > New Project > iOS > iPad > WebView App.
  2. Setup Mac Agent
    ( Needed a Mac installed with Xamarin Studio/iOS with the same version with your visual studio xamarin iOS version )
    Suggest you update to latest stable version.
  3. You may use a mac within your LAN as mac agent
    a. real mac
    b. VM mac
    c.  H***intosh / CustoM**
    Tips for you:  setup another VPN server within the same network with your remote mac agent, then you will able to reach the mac agent ‘s network with VPN like what I am doing.
    You may VNC / Teamviewer back the mac agent to view the iOS semulator and compiled result.

 

Snippet

public override void ViewDidLoad()
 {
 base.ViewDidLoad();

 // Intercept URL loading to handle native calls from browser
 WebView.ShouldStartLoad += HandleShouldStartLoad;

 // Render the view from the type generated from RazorView.cshtml
 // var model = new Model1 { Text = "Text goes here" };
 // var template = new RazorView { Model = model };
 //var page = template.GenerateString();
 
 /** you may use any HTTPS url as your content **/ 
 //var page = "https://redoomph.com";

 /** for http only protocol, you need to add ATS exception for iOS 9 **/
 var page = "http://ethanliew.com";Snippet

4. Edit Info.plist file with any text editor

     /* add ATS NSAppTransportSecurity Exception for IOS 9 at Info.plist
 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     <plist version="1.0">
     <dict>
        ----- your exception key start here ----
 <key>NSAppTransportSecurity</key>
 <dict>
 <key>NSExceptionDomains</key>
 <dict>
 <key> ----- your domain here e.g: ethanliew.com ------ </key>
 <dict>
 <key>NSExceptionMinimumTLSVersion</key>
 <string>TLSv1.0</string>
 <key>NSExceptionRequiresForwardSecrecy</key>
 <false/>
 <key>NSExceptionAllowsInsecureHTTPLoads</key>
 <true/>
 <key>NSIncludesSubdomains</key>
 <true/>
 </dict>
 </dict>
 </dict>

---------- end here --------------

     </dict>
     </plist>

20160701-xamarin-webview-1

Create additional SqlAzure user

Use Master Db ( You may need MSSQL management studio and select [Master] db at the db dropdown )

CREATE LOGIN username WITH password='password';

Create the new User in the database
Switch to the actual database (again via the available databases drop down, or a new connection)

CREATE USER username FROM LOGIN username;

 

Now add the user to relevant security roles

EXEC sp_addrolemember N'db_owner', N'username'