public void CanInitWithTask() { // NSInvalidArgumentException Reason: *** -canInitWithRequest: cannot be sent to an abstract object of class NSURLProtocol: Create a concrete instance! using (var t = new NSUrlSessionTask()) { Assert.False(NSUrlProtocol.CanInitWithTask(t), "CanInitWithTask"); } }
void useWebView(NSUrlRequest request) { NSUrlProtocol.UnregisterClass(new ObjCRuntime.Class(typeof(CustomUrlProtocol))); webView.LoadRequest(request); //webview events webView.LoadStarted += (sender, e) => { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; }; webView.LoadFinished += (sender, e) => { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; }; webView.LoadError += (sender, e) => { Console.WriteLine("load error {0}", e.ToString()); UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; var alert = UIAlertController.Create("Load Error", "Error occured while loading the url", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); this.PresentViewController(alert, animated: true, completionHandler: null); }; }
public MsalAuthenticationAgentUIViewController(string url, string callback, ReturnCodeCallback callbackMethod) { this.url = url; this.callback = callback; this.callbackMethod = callbackMethod; NSUrlProtocol.RegisterClass(new ObjCRuntime.Class(typeof(CoreCustomUrlProtocol))); }
public static void Unregister() { if (urlProtocolClass != null) { NSUrlProtocol.UnregisterClass(urlProtocolClass); } }
public override bool FinishedLaunching(UIApplication application, NSDictionary options) { // Register our custom url protocol NSUrlProtocol.RegisterClass(new MonoTouch.ObjCRuntime.Class(typeof(ImageProtocol))); controller = new UIViewController(); web = new UIWebView(UIScreen.MainScreen.Bounds) { BackgroundColor = UIColor.White, ScalesPageToFit = true, AutoresizingMask = UIViewAutoresizing.All }; controller.NavigationItem.Title = "Test case"; controller.View.AutosizesSubviews = true; controller.View.AddSubview(web); web.LoadRequest(NSUrlRequest.FromUrl(NSUrl.FromFilename(NSBundle.MainBundle.PathForResource("test", "html")))); window = new UIWindow(UIScreen.MainScreen.Bounds); window.MakeKeyAndVisible(); window.RootViewController = controller; return(true); }
public AuthenticationAgentNSWindowController(string url, string callback, ReturnCodeCallback callbackMethod) : base("PlaceholderNibNameToForceWindowLoad") { _url = url; _callback = callback; _callbackMethod = callbackMethod; NSUrlProtocol.RegisterClass(new ObjCRuntime.Class(typeof(CoreCustomUrlProtocol))); }
public override void StartLoading() { //Console.WriteLine("StartLoading: " + this.Request.Url.AbsoluteString); var request = (this.Request as NSMutableUrlRequest) ?? (NSMutableUrlRequest)this.Request.MutableCopy(); NSUrlProtocol.SetProperty(BeingHandledValue, BeingHandledKey, request); connection = new NSUrlConnection(request, new UrlConnectionDelegate(this), true); }
public static void EnableJsBridge() { if (!protocolRegistered) { NSUrlProtocol.RegisterClass(new MonoTouch.ObjCRuntime.Class(typeof(AppProtocolHandler))); protocolRegistered = true; } }
public override void AwakeFromNib() { NSUrlProtocol.RegisterClass(new MonoMac.ObjCRuntime.Class(typeof(NdcProtocol))); string html = "https://developer.mozilla.org/en-US/demos/detail/guitar-chord-diagrams-html5-web-component/launch"; html = "ndc://test.html"; browser.MainFrame.LoadRequest(NSUrlRequest.FromUrl(NSUrl.FromString(html))); base.AwakeFromNib(); }
/// <summary> /// Hides the AbstractServiceLocator class static method by using the keyword new. /// </summary> /// <returns>Singleton IServiceLocator.</returns> public new static IServiceLocator GetInstance() { if (singletonServiceLocator == null) { singletonServiceLocator = new IPhoneServiceLocator(); NSUrlProtocol.RegisterClass(new MonoTouch.ObjCRuntime.Class(typeof(IPhoneNSUrlProtocol))); } return(singletonServiceLocator); }
public static bool canInitWithRequest(NSUrlRequest request) { //Console.WriteLine("canInitWithRequest: " + request.Url); if (NSUrlProtocol.GetProperty(BeingHandledKey, request) != null) { return(false); } return(true); }
public void Registration() { Class c = new Class(typeof(CustomProtocol)); bool res; res = NSUrlProtocol.RegisterClass(c); Assert.That(res, "#1"); NSUrlProtocol.UnregisterClass(c); }
public static void EnableJSBridge(IWebBrowser browser) { m_browser = browser; if (m_browser == null) { throw new ArgumentNullException("IWebBrowser cannot be null"); } if (!ProtocolRegistered) { NSUrlProtocol.RegisterClass(new Class(typeof(AppProtocolHandler))); ProtocolRegistered = true; } }
/// <summary> /// Creates a new instance of this class for the provided <see cref="UIWebView" /> with the provided string as the /// custom /// url protocol /// and passed collection of <see cref="IBridgeHandler" /> instances /// </summary> /// <param name="webView">The <see cref="UIWebView" /> to handle requests from</param> /// <param name="customProtocol"> /// The protocol to use for communication with web browser, or <see langword="null" /> to use /// defualt /// </param> /// <param name="collection">The collection of <see cref="IBridgeHandler" /> instances to add to this list</param> public UIWebViewHybridBridge(UIWebView webView, string customProtocol, IEnumerable <IBridgeHandler> collection) : base(customProtocol, collection) { WebView = webView; WebView.LoadFinished += WebView_LoadFinished; lock (HybridUrlProtocol.Bridges) { if (!HybridUrlProtocol.Bridges.Contains(this)) { HybridUrlProtocol.Bridges.Add(this); } } NSUrlProtocol.RegisterClass(new Class(typeof(HybridUrlProtocol))); }
public override void ViewDidLoad () { base.ViewDidLoad (); // Register our custom url protocol NSUrlProtocol.RegisterClass (new ObjCRuntime.Class (typeof (ImageProtocol))); var web = new WebView { AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; web.Frame = View.Bounds; View.AutoresizesSubviews = true; View.AddSubview (web); web.MainFrame.LoadRequest (NSUrlRequest.FromUrl (NSUrl.FromFilename (NSBundle.MainBundle.PathForResource ("test", "html")))); }
public override void StartLoading() { Console.WriteLine("StartLoading: " + this.Request.Url.AbsoluteString); var request = (this.Request as NSMutableUrlRequest) ?? (NSMutableUrlRequest)this.Request.MutableCopy(); NSUrlProtocol.SetProperty(BeingHandledValue, BeingHandledKey, request); connection = new NSUrlConnection(request, new UrlConnectionDelegate(this), true); //using (var response = new NSUrlResponse(Request.Url, "text/html", -1, null)) //{ // using (var data = NSData.FromString("<html><body><h1>XamUrlProcotol</h1><p>This page was generated by XamUrlProtocol.</p><body></html>")) // { // client.ReceivedResponse(this, response, NSUrlCacheStoragePolicy.NotAllowed); // client.DataLoaded(this, data); // client.FinishedLoading(this); // } //} }
/// <summary> /// Hides the AbstractServiceLocator class static method by using the keyword new. /// </summary> /// <returns>Singleton IServiceLocator.</returns> public new static IServiceLocator GetInstance() { if (singletonServiceLocator == null) { singletonServiceLocator = new IPhoneServiceLocator(); // initialize UIApplication weak delegates var tsEnumerator = typedServices.GetEnumerator(); while (tsEnumerator.MoveNext()) { var typedService = tsEnumerator.Current; if (typedService.Value is IWeakDelegateManager) { (typedService.Value as IWeakDelegateManager).InitializeWeakDelegate(); } } NSUrlProtocol.RegisterClass(new ObjCRuntime.Class(typeof(IPhoneNSUrlProtocol))); } return(singletonServiceLocator); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { NSUrlProtocol.RegisterClass(new MonoTouch.ObjCRuntime.Class(typeof(MtRnCachingUrlProtocol))); _window = new UIWindow(UIScreen.MainScreen.Bounds); var webViewControllerSwxben = new WebViewController("http://swxben.com", "SWXBEN"); var webViewControllerReadify = new WebViewController("http://readify.net", "Readify"); var webViewControllerRgrrrrrba = new WebViewController("http://rgrrrrrba.github.io", "RGRRRRRBA"); var localWebViewController = new LocalWebViewController("Content/Web/index.html", "Local"); _tabBarController = new UITabBarController(); _tabBarController.ViewControllers = new UIViewController [] { webViewControllerSwxben, webViewControllerReadify, webViewControllerRgrrrrrba, localWebViewController, }; _window.RootViewController = _tabBarController; _window.MakeKeyAndVisible(); return(true); }
public void WillClose(NSNotification notification) { NSApplication.SharedApplication.StopModal(); NSUrlProtocol.UnregisterClass(new ObjCRuntime.Class(typeof(CoreCustomUrlProtocol))); }
public void CancelledAuthenticationChallenge(NSUrlProtocol protocol, NSUrlAuthenticationChallenge challenge) { }
public void DataLoaded(NSUrlProtocol protocol, NSData data) { }
public void CachedResponseIsValid(NSUrlProtocol protocol, NSCachedUrlResponse cachedResponse) { }
public override void ViewWillDisappear(bool animated) { NSUrlProtocol.UnregisterClass(new ObjCRuntime.Class(typeof(CustomUrlProtocol))); base.ViewWillDisappear(animated); }
public void useUrlSession(NSUrlRequest request) { NSUrlProtocol.RegisterClass(new ObjCRuntime.Class(typeof(CustomUrlProtocol))); webView.LoadRequest(request); }
public void FailedWithError(NSUrlProtocol protocol, NSError error) { }
public void Redirected(NSUrlProtocol protocol, NSUrlRequest redirectedToEequest, NSUrlResponse redirectResponse) { }
public void ReceivedAuthenticationChallenge(NSUrlProtocol protocol, NSUrlAuthenticationChallenge challenge) { }
public void FinishedLoading(NSUrlProtocol protocol) { }
public override void DismissViewController(bool animated, Action completionHandler) { NSUrlProtocol.UnregisterClass(new ObjCRuntime.Class(typeof(CoreCustomUrlProtocol))); base.DismissViewController(animated, completionHandler); }
public void ReceivedResponse(NSUrlProtocol protocol, NSUrlResponse response, NSUrlCacheStoragePolicy policy) { }