Xamarin, Xamarin Essentials

Launching Apps in Xamarin Forms

I imagine that at some point when you are developing an application you have faced a requirement that it needs to open another application from within the one you are developing. This type of requirements that involve the call of third-party applications is very common, for example when the user wants to make some kind of connection with social networks or applications that have a direct communication with the user such as Uber, Lyft between others. ?‍♀

That’s why in this post we will be learning about how to Launching Apps in Xamarin Forms!


First, let’s learn some important concepts!

.

✔ What is a DeepLinking?

Is a type of link that send users directly to an app instead of a website or a store.

An example with which we can apply this type of action is when we want to send the user directly to a specific location within the application, saving time to locate particular sessions. This significantly improves the user experience. You can read more about this here.

✔ What is a Launcher?

Xamarin Essentials gives us the Launcher class, which enables an application to open a URI by the system. This is often used when deep linking into another application’s custom URI schemes. ?

It’s important not to confuse Open Apps and Open Browsers,  Launcher is just for Apps if you want to open browser you can read this article.


Let’s learn!

To start, Launcher class bring to us some important Async methods that we need to know:

➖  CanOpenAsync: It allow us to know is the App can be opened. Returns a Bool value.  Receives a string or Uri as parameters.

➖ OpenAsync: Is responsible to Open our wished App even files!. Receives the following parameters: Uri, string or OpenFileRequest.

➖  TryOpenAsync: This method allow us to Open our wished App and returns if it was supported or not. Receives a string or Uri as parameters.

Practicing the knowledge obtained above, let’s code! ?

In this example we are going to open the Facebook application and this is where Deeplinking enters the stage, since it is the data that will allow us to open the application needed.

⚠ You can search for the Deeplinking they need by searching the developer page of the desired App.

Let’s add a simple Button:

Now, let’s call to the action in an Event:


Additional Platform Setup

This image has an empty alt attribute; its file name is if_apple-ios-system-platform-os-mac-linux_652586.png

In your Info.plist add LSApplicationQueriesSchemes as an Array value and then add the scheme value of your App. In the case of the Facebook scheme is: “fb”. (The ‘fb” was obtained from the deeplinking: fb://)

This image has an empty alt attribute; its file name is LaunchingAppSample1-1024x101.png

 This image has an empty alt attribute; its file name is if_android_313085.png and    This image has an empty alt attribute; its file name is if_windows_386506.png doesn’t need additional settings.


And done! you can open your App!

This image has an empty alt attribute; its file name is LaunchingFBApp.gif


Spanish post: https://medium.com/@reyes.leomaris/lanzando-aplicaciones-en-xamarin-forms-7a3d52d08668?sk=bdb44fe93aed2295d1bae18e46a2b83c

References: https://channel9.msdn.com/Shows/XamarinShow/Launcher-XamarinEssentials-API-of-the-Week

Thanks for reading !!! ?

Tagged ,

1 thought on “Launching Apps in Xamarin Forms

Leave a Reply

Your email address will not be published. Required fields are marked *