Background
I'm using Google Play Install Referrer Library in my native Android app to track some UTM parameters. To test my implementation, I use Google Play URL Builder to generate test URLs for my app (which is on Internal Testing by the way).
Problem
On the ReferrerDetails
object, getting installReferrer
returns an incomplete URL i.e. a URL with only the query parameters and nothing else e.g. utm_source=google&utm_medium=cpc&utm_term=myUtmTerm&utm_content=myUtmContent&utm_campaign=myCampaignName&anid=admob
. I cannot really call Uri.parse()
to convert this into a URI and get the query parameters directly (the query parameters are null if I try to do that since it's not a valid URI). My other option is to use a custom parser built just for this that I'm trying to avoid for my convenience. Is there another way around it?
Here is the code block that I am using to get this UTM data.
//other code
...
referrerClient = InstallReferrerClient.newBuilder(context).build()
referrerClient.startConnection(object : InstallReferrerStateListener {
override fun onInstallReferrerSetupFinished(responseCode: Int) {
when (responseCode) {
InstallReferrerClient.InstallReferrerResponse.OK -> {
val response: ReferrerDetails = referrerClient.installReferrer
val referrerUrl: String = response.installReferrer
referrerClient.endConnection()
}
...
}
}