What I had to achieve here was to fire up Phone dialer when I click on the link which contains
tel:. This is something similar to
mailto: which will trigger your email client to open up and you can write email to the address specified.
Using the Code
Well just adding the link doesn't work in the Webview. So we need to create an Intent to start the Phone dialer. The solution below has been implemented in Android for now and not on iOS. Will put an addendum once done.
So to do this, we use Dependency Injection like this:
- Create an Interface in your PCL:
public interface IAppIntents
void HandleWebviewUri(string uri);
- Now create a class in your Android project to implement the above
public class AppIntents_Droid : IAppIntents
public void HandleWebviewUri(string uri)
var appUri = Android.Net.Uri.Parse(uri);
var appIntent = new Intent(Intent.ActionView, appUri);
- Whenever user clicks on a link in Webview, a
Navigating event is fired which we need to capture and call the above method:
void WvMain_Navigating(object sender, WebNavigatingEventArgs e)
Pretty simple right!
Points of Interest
Xamarin is a wonderful framework to work with if you have a craving to develop Web apps. With Webview, you can extend your existing Web developer skills to develop great mobile apps. Do let me know if you implement it in your project and if you find this article helpful.