parseReferrerUrl

fun parseReferrerUrl(referrerUrl: String): LinkDetails?

Parse referrer URL and return LinkDetails for the deferred deep link. To use the install referrer API for handling deferred deep links, refer to Google's Install Referrer Library documentation.

Add the following code to your main activity onCreate method that handles deep link:

private lateinit var referrerClient: InstallReferrerClient

referrerClient = InstallReferrerClient.newBuilder(this).build()
referrerClient.startConnection(object : InstallReferrerStateListener {

override fun onInstallReferrerSetupFinished(responseCode: Int) {
when (responseCode) {
InstallReferrerResponse.OK -> {
// Connection established.
referrerClient?.installReferrer?.installReferrer?.let { referrerUrl ->
FlyBuyLinks.parseReferrerUrl(referrerUrl)?.let {
// Handle deep link in your code
handleDeepLink(null, Uri.parse(it.url))
}
}
}
InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> {
// API not available on the current Play Store app.
}
InstallReferrerResponse.SERVICE_UNAVAILABLE -> {
// Connection couldn't be established.
}
}
}

override fun onInstallReferrerServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
})