Search code examples
c#cordovaxamarin.formsinappbrowserequivalent

Xamarin Forms - Equivalent of cordova-plugin-inappbrowser?


I have developed a cross platform app using Phonegap (and some other technologies). Recently, we have made the switch to Xamarin, and are looking to find the equivalent of a feature we used in Phonegap.

In the phonegap build, we were using Cordova In App Browser. We were able to open the map, phone, email, and web browsers of the users choice, pre-populated with locations, phone numbers, email addresses, and urls respectively. This was a good solution because it enabled us to open these as the user would normally expect, and it worked on both platforms (iOS and android). This meant that on an Android device, if they were using a different browser or email client, it would open using whatever they had set to their default.

What is the Xamarin Forms equivalent of this?

  • Opening 'Phone' application with a number filled in
  • Opening 'Email' application with an email address filled in
  • Opening 'Web Browser' application to a specified URL

Thanks!


Solution

  • Consider using Xamarin Form's OpenUri() function for this. Here are some examples:

    Device.OpenUri(new Uri(String.Format("tel:{0}", "+49000000")));
    Device.OpenUri(new Uri(String.Format("sms:{0}", "+49000000")));
    Device.OpenUri(new Uri(String.Format("mailto:{0}", "myCoolHotmail@hotmail.com")));