Created
April 16, 2017 11:41
-
-
Save jfversluis/6ec06800ac1f6c86451a4cb12242575c to your computer and use it in GitHub Desktop.
Codebehind for the mainpage of my application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void WebView_OnNavigating (object sender, WebNavigatingEventArgs e) | |
{ | |
var url = e.Url.ToLowerInvariant (); | |
if (url.Contains ("thirdparty.com") || url.Contains ("vimeo.com") || url.Contains ("bid.g.doubleclick.net")) { | |
// Do nothing, links are loaded as embedded | |
} else if (url.StartsWith ("https://getmypdfurl.com", StringComparison.Ordinal)) { | |
e.Cancel = true; | |
if (Device.OS == TargetPlatform.Windows) | |
Device.OpenUri (new Uri (e.Url)); | |
else | |
Navigation.PushAsync (new ShowPdfPage (e.Url)); | |
} else if (!url.StartsWith ("https://ourwebapplication.com", StringComparison.Ordinal)) { | |
e.Cancel = true; | |
if (Device.OS == TargetPlatform.iOS) { | |
try { | |
DependencyService.Get<IWebBrowserService> ().OpenUrl (e.Url); | |
} catch { | |
Device.OpenUri (new Uri (WebUtility.UrlDecode (e.Url))); | |
} | |
return; | |
} | |
Device.OpenUri (new Uri (WebUtility.UrlDecode (e.Url))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment