Huawei Developers
Published in

Huawei Developers

Intermediate: Integration of Huawei App Linking in Xamarin(Android)

Introduction

Huawei App Linking provides features to create cross-platform link, which can be used to open specific content in Android, iOS app and on the web. If user has installed the app, it will navigate to particular screen, otherwise it will open the App Gallery to download the app. After downloading, it will navigate to proper screen.

It increases our app’s traffic after sharing the link, user can easily navigate to the app content which increases our apps screen views. Also users not need to search for the same app on the App Gallery.

You can create App Link in 3 ways.

1. Creating App link from App Gallery Connect.

2. Manually Creating App link.

3. Creating App link using code implementation.

This article explains about creating App Link using code implementation.

Let us start with the project configuration part:

Step 1: Create an app on App Gallery Connect.

Step 2: Select My projects.

Step 3: Click Add project and create your app.

Step 4: Enable the App Linking in Manage APIs tab.

Step 5: Enable App Linking.

Step 6: Apply for URL Prefix and this url will be used in code implementation.

Step 7: Create new Xamarin (Android) project.

Step 8: Change your app package name same as AppGallery app’s package name.

a) Right click on your app in Solution Explorer and select properties.

b) Select Android Manifest on lest side menu.

c) Change your Package name as shown in below image.

Step 9: Generate SHA 256 key.

a) Select Build Type as Release.

b) Right click on your app in Solution Explorer and select Archive.

c) If Archive is successful, click on Distribute button as shown in below image.

d) Select Ad Hoc.

e) Click Add Icon.

f) Enter the details in Create Android Keystore and click on Create button.

g) Double click on your created keystore and you will get your SHA 256 key. Save it.

f) Add the SHA 256 key to App Gallery.

Step 10: Sign the .APK file using the keystore for both Release and Debug configuration.

a) Right-click on your app in Solution Explorer and select properties.

b) Select Android Packaging Signing and add the Keystore file path and enter details as shown in image.

Step 11: Download agconnect-services.json from App Gallery and add it to Asset folder.

Step 12: Right-click on References> Manage Nuget Packages > Browse and search Huawei.Agconnect.Applinking and install it.

Now configuration part done.

Let us start with the implementation part:

Step 1: Create the HmsLazyInputStream.cs which reads agconnect-services.json file.

Step 2: Initialize the configuration in MainActivity.cs.

Step 3: create the activity_main.xml for UI.

Step 4: Generate App Long Link after button click.

Step 5: Share App Link after share button click.

Step 6: Add an Intent-filter to MainActivity.cs for deep link to work.

MainAcitvity.cs

Now Implementation part done.

Result

Tips and Tricks

1. Do not forget to add agconnect-services.json file into Asset folder.

2. Add Huawei.Agconnect.Applinking NuGet package properly.

Conclusion

In this article, we have learnt about creating App link through code. This helps to increase our application traffic after sharing the link with other users. This also helps users to navigate to exact screen in the app rather than searching for the screen.

Thanks for reading! If you enjoyed this story, please provide Likes and Comments.

Reference

App Linking Implementation Xamarin

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store