Xamarin Dynamic Links using Google Firebase

firebase

Xamarin is a fast-growing development platform for developing cross-platform applications. Xamarin allows developers to develop Android, IOS and windows applications. As times change there are changes in functionalities of hyperlinks like instances where an application need’s to be launched by clicking a hyperlink or prompt the user for installation of application if he doesn’t have it installed.

Firebase is Google’s mobile platform that helps you quickly develop high-quality apps and grow your business. The above scenario can be done in Xamarin platform using firebase dynamic links. There are very rare tutorials in explaining how to implement dynamic links in Xamarin using firebase. So I thought I would write one, briefly explaining the implementation:

Step 1: Create a simple project in Xamarin Android which uses the Internet .

Step 2: Navigate over to Android.Manifest.xml and paste in the following code in the application section:

<receiver

     android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"

     android:exported="false"

     />

   <receiver

     android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"

     android:exported="true"

     android:permission="com.google.android.c2dm.permission.SEND"

     />

Step 3: Go to https://firebase.google.com/

   I.          Create an account and go to console view

   II.         Click on add new project

   III.        Enter your Project details like project name and Click next

   IV.         Navigate to Dynamic links on the left drawer

    V.          Click on the platform as android

   VI.        Enter your application details. Please note to include the same package name as you defined in the Android Xamarin project.

  VII.           Now you will be asked an SHA-1 Certificate key along with the app details. To find your SHA-1 key refer:

https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/keystore-signature?tabs=vswin

 VIII.           Click on Register app and continue. You will be asked to download a config file of google services. Download and keep the file.

  IX.           Skip the next Steps. (Ignore run to verify app installation)

  X.           Now click on dynamic links and add a new link. You will be asked to set up a short URL and click next.

  XI.           Next would be to input a deep link which should be navigated when your app is not there, example in desktop.

 XII.           After this yours would be asked to specify the behavior of the link in Android and IOS, select the appropriate and click on create dynamic link

Step 4: Go back to your Xamarin android project and right click the solution and paste the config file we have downloaded.

Step 5: Ensure you have an internet connection to the emulator or phone and run the application.

Step 6: Now paste the link (Short URL we created in firebase (Step 3: XI) ) in a separate browser in your mobile and Tadaaa!!!! You are all set.

Please note that this is also useful in establishing a connection with firebase through Xamarin and you can further do all firebase has to offer and these steps are the base for it. For any doubts and queries feel free to message me.