1 min read

Guides and customisations

Android App Links available on Android 6.0 (API level 23) and higher allows an app to designate itself as the default handler of a given type of link.

To add support for App links in your App:

  1. Add the links that your app can handle into your manifest.
  2. Create and store in the right location assetlinks.json file

LinksViewModel will handle the resolution of your web link, thanks to a backend links resolver API call, into a DeepLink model.

If your String contains App links or deep links, you need to:

  1. Call LinksViewModel.processDeeplink with your String:
    linksViewModel.processDeeplink(PoqResult.Success({YourString}))
  2. Obtain your deep link from the LiveData linksViewModel.deepLink or an error from linksViewModel.error.

If your String only contains deep links, you need to:

  1. Create a UriLink. You can use UriValidator to do it.
  2. Call GetCategoryDeepLink with your new UriLink.
    getDeepLinkFromUriLink(UriLink(uriValidator.createValidUri(deepLink), null))

To navigate with a DeepLink you can use LinksNavigator:

private val linksNavigator: LinksNavigator by inject { parametersOf(context.getFragmentActivity()) }
...
linksNavigator.navigate({yourDeepLink}})

To add your own deep links, you need to:

  1. Create a custom deep link model with all your custom deep links.
    sealed class CustomDeepLink {
    object CustomScreenDeepLink : CustomDeepLink()
    }
  2. Create a new implementation of Mapper<DeepLink.ClientDeepLink?, UriLink>, which transforms a String into your custom deep link or returns null if the Link SDK should handle that String.
    class CustomClientDeepLinkMapper (
    private val uriHelper: UriHelper
    ) : Mapper<DeepLink.ClientDeepLink?, UriLink>
    private companion object {
    const val CUSTOM_DEEPLINK = "customdeeplink"
    }
    override fun map(origin: UriLink): DeepLink.ClientDeepLink? {
    return if (uriHelper.getHost(origin.uri) == CUSTOM_DEEPLINK) {
    DeepLink.ClientDeepLink(CustomDeepLink.DeepLink)
    } else {
    null
    }
    }
    }
  3. Provide your new mapper via Koin using the name clientDeepLinkMapperName.
  4. Create a new implementation of ClientLinksNavigator.
    class CustomClientLinksNavigator(
    private val activity: Activity
    ) : ClientLinksNavigator {
    override fun navigate(deepLink: DeepLink.ClientDeepLink) { ... }
    }
  5. Provide your new navigator via Koin.
    factory<ClientLinksNavigator>(override = true) { (activity: Activity) -> CustomClientLinksNavigator(activity) }

How to add a new DeepLinkProvider

If you need to resolve deep links diferently, for example, for a new universal link provider, you need to: