androidhuawei-mobile-servicesapplinkshuawei-developersandroid-app-links

How to support app linking on Huawei devices with HMS


For now on by saying Huawei devices, we understand devices release after may 16 2019, that are released without Google Mobile Services

During the development to support app links on Huawei, several problems have been occurred and following questions raised:

  1. Why google app links doesn't work on Huawei?
  2. How to support them on Huawei devices?
  3. How to get data shared via app link

Solution

  • Q: Why google app links doesn't work on Huawei?

    A: App links are considered to be deep links with an extra check. That extra check done by GMS, which requires assetlinks.json file to be under your domain, in order your domain be authorized to directly open the app, more info here.

    Q: How to support them on Huawei devices?

    A: You need to have account on AG Connect, then apply for any prefix you like. Then AG Connect will generate a URL for you, which will be something like https://YOUR_PREFIX_HERE.dra.agconnect.link. After having this, you should add deeplink parameter to your URL which should be exact same app link URL that you were using for devices with GMS. Important thing is that it should be URL encoded e.g. https://YOUR_PREFIX_HERE.dra.agconnect.link?deeplink=urlencoded(https.my-host-here.my_prefix-if-I-have&some-data-toshare= SOME-DATA-IN-BASE-64).

    Having the same url used for GMS app link, as a deep link in case of HMS, makes you to have single intent filter to handle both app links.

    In short: HMS.applink = https://YOUR_PREFIX_HERE.dra.agconnect.link?deeplink=urlencoded(GMS.applink).

    Q: How to get data shared via app link

    A: In the HMS documentation it suggests to ad AG Connect applinking library to the project and use appropriate classes. But fortunately we can do it in the same way as we do for GMS app links: we can get data from Intents.