public void OpenURI(string selectedText) { NSString searchText = new NSString(selectedText); searchText = searchText.CreateStringByAddingPercentEscapes(NSStringEncoding.UTF8); Foundation.NSUrl url = new Foundation.NSUrl($"https://www.google.com/search?q={searchText}"); UIApplication.SharedApplication.OpenUrl(url); }
partial void WikiButtonClick(NSObject sender) { var term = SearchTerm.Trim(); var urlString = "https://www.google.com/search?q=" + term; NSString stringURL = new NSString(urlString); stringURL = stringURL.CreateStringByAddingPercentEscapes(NSStringEncoding.UTF8); NSUrl url = new NSUrl(stringURL.ToString()); if (url != null) { NSWorkspace.SharedWorkspace.OpenUrl(url); } }
public static NSString UrlEncode(this string url) { NSString displayUrl = new NSString(url); return(displayUrl.CreateStringByAddingPercentEscapes(NSStringEncoding.ASCIIStringEncoding)); }
private async Task BegingDownloading(RequestData requestData, EventHandler<DownloadEventArgs> downloadedAction, Guid taskGuid) { NSUrlSession session = GetSession(requestData, downloadedAction); NSUrlSessionDownloadTask task; if (requestData.Type == RequestData.RequestType.Get) { NSString urlSting = new NSString(requestData.Url); urlSting = urlSting.CreateStringByAddingPercentEscapes(NSStringEncoding.UTF8); task = session.CreateDownloadTask(NSUrl.FromString(urlSting)); } else { NSMutableUrlRequest request = new NSMutableUrlRequest(NSUrl.FromString(requestData.Url)) { Body = FormatBody(requestData.Body), HttpMethod = "POST" }; task = session.CreateDownloadTask(request); } if (task != null) { task.TaskDescription = await JsonParser.SerializeToJsonString(new Dictionary<string, JsonValueInfo> { { "request", new JsonValueInfo(requestData.ToJson(), false) }, { "guid", new JsonValueInfo(taskGuid) } }); task.Resume(); } else { downloadedAction(this, new DownloadEventArgs("", taskGuid, requestData, "Can't create NSUrlSessionDownloadTask.")); } }